/// <summary> /// Writes the given <see cref="Polygon2l"/> to an <see cref="Ibasa.IO.BinaryWriter">. /// </summary> public static void Write(this Ibasa.IO.BinaryWriter writer, Polygon2l polygon) { var array = polygon.ToArray(); writer.Write(array.Length); foreach (var point in array) { writer.Write(point); } }
/// <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 Linel Project(Polygon2l polygon, Vector2l axis) { var min = long.MaxValue; var max = long.MinValue; for (int i = 0; i < polygon.Count; ++i) { var proj = Vector.Dot((Vector2l)polygon[i], axis); min = Functions.Min(min, proj); max = Functions.Max(max, proj); } return(new Linel(min, max)); }
/// <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(Polygon2l left, Polygon2l right) { return(left == right); }