Beispiel #1
0
		/// <summary>
		/// Writes the given <see cref="Polygon2i"/> to an <see cref="Ibasa.IO.BinaryWriter">.
		/// </summary>
		public static void Write(this Ibasa.IO.BinaryWriter writer, Polygon2i polygon)
		{
			var array = polygon.ToArray();
			writer.Write(array.Length);
			foreach(var point in array)
			{
				writer.Write(point);
			}
		}
Beispiel #2
0
		/// <summary>
		/// Projects a polygon onto an axis.
		/// </summary>
		/// <param name="polygon">The polygon to project.</param>
		/// <param name="axis">The axis to project onto.</param>
		/// <returns>The interval on the axis that the polygon projects onto.</returns>
		public static Linei Project(Polygon2i polygon, Vector2i axis)
		{
			var min = int.MaxValue;
			var max = int.MinValue;
			for (int i=0; i < polygon.Count; ++i)
			{
				var proj = Vector.Dot((Vector2i)polygon[i], axis);
				min = Functions.Min(min, proj);
				max = Functions.Max(max, proj);
			}
			return new Linei(min, max);
		}
Beispiel #3
0
		/// <summary>
		/// Returns a value that indicates whether two polygons are equal.
		/// </summary>
		/// <param name="left">The first polygon to compare.</param>
		/// <param name="right">The second polygon to compare.</param>
		/// <returns>true if the left and right are equal; otherwise, false.</returns>
		public static bool Equals(Polygon2i left, Polygon2i right)
		{
			return left == right;
		}