Hello all I'm working on my own game engine, and I'm trying to wrap my mind around collision detection. I found this gem https://math.stackexchange.com/a/2203231/1098790 , but there is one thing I don't understand. It says "the Minkowski sum of 2 polygons can be obtained just by sliding arroud (sic) the edges of the original polygons" but I don't know what this means. By sum, I'm 95% sure the sum A + (-B) is meant, and I'm not sure if convexity of the polygons is needed for this to be true. Being able to visualize this A + (-B) will go a long way in understanding stuff
-
1Perhaps think in terms of $B$ as a point first and then two points, etc, etc? – copper.hat Sep 22 '22 at 20:07
1 Answers
The Minkowski sum can be computed for any two Jordan polygons, regardless of convexity. When both $A$ and $B$ are convex, one simple way to compute the sum $A + B$ by hand is to:
cut out a piece of paper in the shape of $B$ and mark one of its corners
for each vertex $V$ of $A$, align the marked corner of $B$ with $V$ (without rotating the cutout) and mark all of $B$ vertices on the paper below
compute the convex hull of the resulting set of points
This simple procedure is only guaranteed to work for convex $A$ and $B$. I think what may be meant by "sliding around the edges" is the alternative approach:
cut out a piece of paper in the shape of $B$ and mark one of its corners
divide the perimeter of $A$ into $m$ equal increments; for each point $P$ on $A$'s perimeter ($m$ in total), align the marked corner of $B$ with $V$ (without rotating the cutout), trace out $B$ on the paper below, and colour in the traced-out polygon
then as $m \to \infty$, the resulting total coloured-in region $\to A + B$
That is, as the number of points on the perimeter of $A$ approaches infinity, we can think of the process of selecting successive points as "sliding along" the edges of $A$. It just so happens that when $A$ and $B$ are convex, the sliding along can be replaced by the first procedure, which is much more efficient.
Also, I should note that in a computerized setting, the second procedure would never be used. For example, it's far more practical to decompose $A$ and $B$ into convex parts, compute the sums of all combinations of those parts, and then stitch them together.

- 472
-
I gotta do some more thinking, but I think that I got it. Thanks for the info! – gist076923 Sep 23 '22 at 19:16