Skip to main content
Post Undeleted by Carl Woll
Fix bug
Source Link
Carl Woll
  • 131.7k
  • 6
  • 246
  • 359

Another possibility is to use TransformedRegion with RegionProduct. Here is a function that does this:

Options[MinkowskiSum] = Options[BoundaryDiscretizeRegion];

MinkowskiSum[r1_, r2_, opts:OptionsPattern[]] := Module[{d1, d2, vfunc,bounds},
    d1 = RegionEmbeddingDimension[r1];d1=RegionEmbeddingDimension[r1];
    d2 = RegionEmbeddingDimension[r2];d2=RegionEmbeddingDimension[r2];
    (
    v = Evaluate[Array[Slotfunc=Evaluate[Array[Slot, 3]d1] + Array[Slot, 3d1, 4]]&;d1+1]]&;
    BoundaryDiscretizeRegion[bounds=RegionBounds[r1]+RegionBounds[r2];
    Quiet[
    TransformedRegion[    BoundaryDiscretizeRegion[
            RegionProduct[r1TransformedRegion[RegionProduct[r1, r2], func],
            vbounds,
            opts
        ],
        optsBoundaryDiscretizeRegion::brepl
    ]
    ) /; d1 === d2d1===d2
]

Your examples:

MinkowskiSum[Circle[{0,0}, 1], Line[{{0,0},{3,5}}], Axes->True, ImageSize->200]

enter image description here

MinkowskiSum[
    Sphere[{0,0,0}, 1],
    Line[{{0,0,0},{3,5,4}}],
    Axes->True,
    ImageSize->200
]

enter image description here

Another possibility is to use TransformedRegion with RegionProduct. Here is a function that does this:

Options[MinkowskiSum] = Options[BoundaryDiscretizeRegion];

MinkowskiSum[r1_, r2_, opts:OptionsPattern[]] := Module[{d1, d2, v},
    d1 = RegionEmbeddingDimension[r1];
    d2 = RegionEmbeddingDimension[r2];
    (
    v = Evaluate[Array[Slot, 3] + Array[Slot, 3, 4]]&;
    BoundaryDiscretizeRegion[
        TransformedRegion[
            RegionProduct[r1, r2],
            v
        ],
        opts
    ]
    ) /; d1 === d2
]

Your examples:

MinkowskiSum[Circle[{0,0}, 1], Line[{{0,0},{3,5}}], Axes->True, ImageSize->200]

enter image description here

MinkowskiSum[
    Sphere[{0,0,0}, 1],
    Line[{{0,0,0},{3,5,4}}],
    Axes->True,
    ImageSize->200
]

enter image description here

Another possibility is to use TransformedRegion with RegionProduct. Here is a function that does this:

Options[MinkowskiSum] = Options[BoundaryDiscretizeRegion];

MinkowskiSum[r1_, r2_, opts:OptionsPattern[]] := Module[{d1,d2,func,bounds},
    d1=RegionEmbeddingDimension[r1];
    d2=RegionEmbeddingDimension[r2];
    (
    func=Evaluate[Array[Slot, d1] + Array[Slot, d1, d1+1]]&;
    bounds=RegionBounds[r1]+RegionBounds[r2];
    Quiet[
        BoundaryDiscretizeRegion[
            TransformedRegion[RegionProduct[r1, r2], func],
            bounds,
            opts
        ],
        BoundaryDiscretizeRegion::brepl
    ]
    ) /; d1===d2
]

Your examples:

MinkowskiSum[Circle[{0,0}, 1], Line[{{0,0},{3,5}}], Axes->True, ImageSize->200]

enter image description here

MinkowskiSum[
    Sphere[{0,0,0}, 1],
    Line[{{0,0,0},{3,5,4}}],
    Axes->True,
    ImageSize->200
]

enter image description here

Post Deleted by Carl Woll
Source Link
Carl Woll
  • 131.7k
  • 6
  • 246
  • 359

Another possibility is to use TransformedRegion with RegionProduct. Here is a function that does this:

Options[MinkowskiSum] = Options[BoundaryDiscretizeRegion];

MinkowskiSum[r1_, r2_, opts:OptionsPattern[]] := Module[{d1, d2, v},
    d1 = RegionEmbeddingDimension[r1];
    d2 = RegionEmbeddingDimension[r2];
    (
    v = Evaluate[Array[Slot, 3] + Array[Slot, 3, 4]]&;
    BoundaryDiscretizeRegion[
        TransformedRegion[
            RegionProduct[r1, r2],
            v
        ],
        opts
    ]
    ) /; d1 === d2
]

Your examples:

MinkowskiSum[Circle[{0,0}, 1], Line[{{0,0},{3,5}}], Axes->True, ImageSize->200]

enter image description here

MinkowskiSum[
    Sphere[{0,0,0}, 1],
    Line[{{0,0,0},{3,5,4}}],
    Axes->True,
    ImageSize->200
]

enter image description here