<commit_before>/*
This file is part of MatterSlice. A commandline utility for
generating 3D printing GCode.

Copyright (C) 2013 <NAME>
Copyright (c) 2014, <NAME>

MatterSlice is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
The integer point classes are used as soon as possible and represent microns in 2D or 3D space.
Integer points are used to avoid floating point rounding errors, and because ClipperLib uses them.
*/

using ClipperLib;

//Include Clipper to get the ClipperLib::IntPoint definition, which we reuse as Point definition.
using System;
using System.Collections.Generic;

using static System.Math;

namespace MatterHackers.MatterSlice
{
	using Polygon = List<IntPoint>;

	using Polygons = List<List<IntPoint>>;

	public struct Point3
	{
		public long x, y, z;

		public IntPoint XYPoint { get { return new IntPoint(x, y); } }

		public Point3(IntPoint xy, long z)
		{
			this.x = xy.X;
			this.y = xy.Y;
			this.z = z;
		}

		public Point3(double _x, double _y, double _z)
			: this((int)(_x + .5), (int)(_y + .5), (int)(_z + .5))
		{
		}

		public Point3(int _x, int _y, int _z = 0)
		{
			this.x = _x;
			this.y = _y;
			this.z = _z;
		}

		public static Point3 operator -(Point3 left, Point3 right)
		{
			return new Point3(left.x - right.x, left.y - right.y, left.z - right.z);
		}

		public static Point3 operator *(Point3 left, long right)
		{
			return new Point3(left.x * right, left.y * right, left.z * right);
		}

		public static Point3 operator /(Point3 left, long right)
		{
			return new Point3(left.x / right, left.y / right, left.z / right);
		}

		public static bool operator !=(Point3 left, Point3 right)
		{
			return left.x != right.x || left.y != right.y || left.z != right.z;
		}

		public static Point3 operator /(Point3 point, int i)
		{
			return new Point3((int)(point.x / i + .5), (int)(point.y / i + .5), (int)(point.z / i + .5));
		}

		public static Point3 operator +(Point3 left, Point3 right)
		{
			return new Point3(left.x + right.x, left.y + right.y, left.z + right.z);
		}

		public bool ShorterThen(long len)
		{
			if (x > len || x < -len)
				return false;
			if (y > len || y < -len)
				return false;
			if (z > len || z < -len)
				return false;
			return LengthSquared() <= len * len;
		}

		public static bool operator ==(Point3 left, Point3 right)
		{<commit_msg>let .net do the rounding.<commit_after>/*
This file is part of MatterSlice. A commandline utility for
generating 3D printing GCode.

Copyright (C) 2013 <NAME>
Copyright (c) 2014, <NAME>

MatterSlice is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
The integer point classes are used as soon as possible and represent microns in 2D or 3D space.
Integer points are used to avoid floating point rounding errors, and because ClipperLib uses them.
*/

using ClipperLib;

//Include Clipper to get the ClipperLib::IntPoint definition, which we reuse as Point definition.
using System;
using System.Collections.Generic;

using static System.Math;

namespace MatterHackers.MatterSlice
{
	using Polygon = List<IntPoint>;

	using Polygons = List<List<IntPoint>>;

	public struct Point3
	{
		public long x, y, z;

		public IntPoint XYPoint { get { return new IntPoint(x, y); } }

		public Point3(IntPoint xy, long z)
		{
			this.x = xy.X;
			this.y = xy.Y;
			this.z = z;
		}

		public Point3(double _x, double _y, double _z)
			: this(Convert.ToInt32(_x), Convert.ToInt32(_y), Convert.ToInt32(_z))
		{
		}

		public Point3(int _x, int _y, int _z = 0)
		{
			this.x = _x;
			this.y = _y;
			this.z = _z;
		}

		public static Point3 operator -(Point3 left, Point3 right)
		{
			return new Point3(left.x - right.x, left.y - right.y, left.z - right.z);
		}

		public static Point3 operator *(Point3 left, long right)
		{
			return new Point3(left.x * right, left.y * right, left.z * right);
		}

		public static Point3 operator /(Point3 left, long right)
		{
			return new Point3(left.x / right, left.y / right, left.z / right);
		}

		public static bool operator !=(Point3 left, Point3 right)
		{
			return left.x != right.x || left.y != right.y || left.z != right.z;
		}

		public static Point3 operator /(Point3 point, int i)
		{
			return new Point3(Convert.ToInt32(point.x / (double)i), Convert.ToInt32(point.y / (double)i), Convert.ToInt32(point.z / (double)i));
		}

		public static Point3 operator +(Point3 left, Point3 right)
		{
			return new Point3(left.x + right.x, left.y + right.y, left.z + right.z);
		}

		public bool ShorterThen(long len)
		{
			if (x > len || x < -len)
				return false;
			if (y > len || y < -len)
				return false;
			if (z > len || z < -len)
				return false;
			return LengthSquared() <= len * len;
		}

		public static bool operator ==(Point3 left, Point3 right)
		{
{'fraction_non_alphanumeric': 0.10694822888283378, 'fraction_numerical': 0.01600817438692098, 'mean_word_length': 3.2404332129963898, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4069876', 'n_tokens_mistral': 2151, 'n_tokens_neox': 1915, 'n_words': 750}