/// <summary> /// Gets oriented bounding box of this polygon /// </summary> public static Polygon2d ComputeOrientedBoundingBox(this Polygon2d polygon) { var rot = polygon.ComputeMinAreaEnclosingBoxRotation(); var rotInv = rot.Transposed; var bbGlobal = new Box2d(polygon.Points.Select(p => rot * p)); return(new Polygon2d(bbGlobal.ComputeCornersCCW().Apply(p => rotInv * p))); }