public void AlignedBox() { var polygon = new Polygon ( new[] { new Vector3(5.0, 1.0), new Vector3(5.0, 5.0), new Vector3(2.0, 5.0) } ); var box = polygon.AlignedBox(); Assert.Contains(new Vector3(3.92, 6.44, 0.0), box.Vertices); Assert.Contains(new Vector3(6.92, 2.44, 0.0), box.Vertices); Assert.Contains(new Vector3(2.0, 5.0, 0.0), box.Vertices); Assert.Contains(new Vector3(5.0, 1.0, 0.0), box.Vertices); }
/// <summary> /// Returns a list of Vector3 points representing the corners of the Polygon's aligned bounding box. /// </summary> public static List <Vector3> AlignedBoxCorners(this Polygon polygon) { return(polygon.AlignedBox().Vertices.ToList()); }
/// <summary> /// The ratio of the longer side to the shorter side of the Polygon's bounding box. /// </summary> public static double AlignedAspectRatio(this Polygon polygon) { var segments = polygon.AlignedBox().Segments().OrderBy(s => s.Length()); return(segments.Last().Length() / segments.First().Length()); }