示例#1
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 Linef Project(Polygon2f polygon, Vector2f axis)
        {
            var min = float.MaxValue;
            var max = float.MinValue;

            for (int i = 0; i < polygon.Count; ++i)
            {
                var proj = Vector.Dot((Vector2f)polygon[i], axis);
                min = Functions.Min(min, proj);
                max = Functions.Max(max, proj);
            }
            return(new Linef(min, max));
        }
示例#2
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(Polygon2f left, Polygon2f right)
 {
     return(left == right);
 }