Exemple #1
0
        public static IEnumerable <Polygon2d> Union(this Box2d b0, Box2d b1)
        {
            Polygon2d p0 = new Polygon2d(b0.ComputeCornersCCW());
            Polygon2d p1 = new Polygon2d(b1.ComputeCornersCCW());

            return(p0.Union(p1));
        }
        /// <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)));
        }