Algorithmadvanced
Minkowski sum of polyhedra
Also called polyhedral Minkowski sum.
Computes the Minkowski sum of two polyhedra; convex polytopes add face by face through support functions, and general polyhedra go through convex pieces, with up to O(n^3 m^3) output.
- Solves
- Minkowski sum
- Time
- O(n m (n + m)) worst
- Space
- O(n m) extra
- Where
- m = the number of vertices of Q; n = the number of vertices of P
- Model
- Word RAM
- Properties
- deterministicexactiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Efi Fogel, Dan Halperin, 2007
The Minkowski sum of two solids and is : the region that covers when its reference point moves over all of . In solid modeling it grows a part by a tool shape, as in offsetting with a ball, gives the region a translating tool sweeps along a segment, and gives the configuration space obstacles for a robot that translates. The plane version is on the Minkowski sum page, with the merge for convex polygons. In three dimensions the convex case is still easy: the support functions add, so each face of the sum is the sum of a face of and a face of with the same outer normal, and the sum of two convex polytopes has faces. The general case goes through a convex decomposition of both solids, the pairwise sums of the pieces and a union of up to quadratically many convex polytopes, and the result can have faces. This page gives the convex step exactly, with integer arithmetic.
In plain words
Take a box and a little pyramid. Put a copy of the pyramid at every point of the box. The result is a bigger convex shape.
Look at the result from any side. The part of it that sticks out furthest toward you is the part of the box that sticks out furthest that way, plus the part of the pyramid that sticks out furthest that way. Those parts can be a corner, an edge or a flat face. Two corners give a corner, a corner and a face give a copy of the face, and two edges that are not parallel give a flat four-sided face.
So the flat faces of the result come from three places: the faces of the box, the faces of the pyramid, and pairs of edges, one from each. The method lists all these candidates and keeps the ones that give a flat face.
The problem
Input. Two finite point sets and in with integer coordinates, each with a three-dimensional convex hull. We write and also for the hulls, the convex polytopes. has points, has .
Output. The facets of : for each facet, its outer normal as a primitive integer vector and the cycle of its vertices in counterclockwise order seen from outside.
Notation. For a direction , is the support function and is the face of in direction . For a finite set, is the set of points that attain the maximum. A face is a facet if it spans a plane and an edge if it spans a line. The normal cone of a face is the set of with .
The key fact is the additivity of support functions and faces:
The first equation is item 4 on the support function page. The second follows: with and holds only if both are equalities. So the faces of the sum are sums of faces of the summands with a common normal, and a facet of the sum with normal comes from one of three cases: a facet of plus a face of , a face of plus a facet of , or an edge of plus an edge of that are not parallel, with perpendicular to both, that is .
The algorithm
MINKOWSKI-SUM-CONVEX(P, Q)- 1
N ← the outer facet normals of P and of Q - 2
for each edge direction e of P and each edge direction f of Q do - 3
if e × f ≠ 0 then add e × f and −(e × f) to N, as primitive integer vectors - 4
S ← an empty map from normals to facets - 5
for each u in N do - 6
A ← F(P, u); B ← F(Q, u) ▷ two support queries - 7
if the points a + b, a ∈ A, b ∈ B, span a plane then - 8
S[u] ← the convex polygon of these points, counterclockwise seen from u - 9
return S
Line L1 needs the facets of and . A B-rep gives them; for point sets, the code finds them by brute force over triples of points. The edges of line L2 come from the facets: if and are the normals of two adjacent facets, then is their common edge. Line L3 adds both signs, since the cross product does not tell which side the facet is on; line L7 rejects the wrong sign and every pair whose Gauss arcs do not cross. The vertices of the sum are the vertices of its facets.
Fogel and Halperin do lines L2 to L7 in one pass: the Gaussian map of a convex polytope puts each facet normal as a point on the unit sphere, each edge as a great arc between the normals of its two facets, and each vertex as the spherical region of its normal cone. The Gaussian map of is the overlay of the two maps, so the edge pairs that give facets are exactly the pairs of arcs that cross, and a sweep over the sphere finds them without testing all pairs.
Example
Let be the tetrahedron with corners and the unit cube . Line L1 gives the 4 normals of and the 6 of . The three normals , and are shared, so has 7 vectors so far. has 6 edge directions and has 3, which give 15 non-parallel pairs, and line L3 brings to 13 vectors. Lines L5 to L8 then do this:
| sum spans | result | |||
|---|---|---|---|---|
| facet | vertex | plane | triangle | |
| , , | facet | facet | plane | pentagon, 5 vertices each |
| , , | vertex | facet | plane | unit square, 4 vertices each |
| , , | edge, such as | edge, such as | plane | parallelogram |
| , , | edge, such as | the parallel edge | line | rejected |
The sum has facets and 13 vertices, so it has 21 edges, and as Euler's formula requires. The pentagon on the plane has the vertices . In the three rejected rows, an edge of is parallel to an edge of , and their sum is a longer edge of , not a facet.
Two more sums that the tests check: the tetrahedron plus its reflection gives a cuboctahedron, with 8 triangles, 6 squares and 12 vertices. The cube plus the octahedron with vertices gives 6 squares, 8 triangles and 12 rectangles, 26 facets and 24 vertices.
Correctness
The face identity above says that for the sets of line L6, so a candidate that passes line L7 is the normal of a facet of the sum, and line L8 records that facet. Conversely, let be the outer normal of a facet of the sum. The facet is , whose span is the sum of the spans of and . If spans a plane, is the normal of a facet of , which is in by line L1; the same holds for . Otherwise each of and is a vertex or an edge, and their spans add up to a plane only if both are edges with directions and that are not parallel. Then is perpendicular to and , so it is a positive multiple of or of , and line L3 added both. Every edge of is the intersection of two facets, so the edge directions of line L2 cover all edges. So is exactly the set of facets of the sum. The full proof is in the proof file.
The tests check that the vertices of the output attain for all 124 integer directions with entries in on 500 random pairs, and for all 728 directions with entries in on 60 larger pairs. They check that each facet is a supporting plane that touches exactly its listed vertices, in counterclockwise order, that , and on 80 small pairs that the facets and vertices equal those of the convex hull of all vertex sums, found by brute force over triples.
Proof: The candidate normals and support faces give exactly the facets of the Minkowski sum of two convex polytopesfull
We use the pseudocode of the page. and are convex polytopes in with nonempty interior, given by finite point sets with integer coordinates. For , and . Every face of a polytope is for some , and its dimension is the dimension of its affine hull. For a finite set we write for the points of that attain the maximum; then , since a linear function attains its maximum over a polytope on the hull of the points of where it is maximal.
Lemma 1 (support functions and faces add). For nonempty compact convex sets and and every : and .
Proof. For and , , with equality when and attain their maxima, so . A point attains this value exactly when some, and then every, decomposition with has . Since each term is at most its maximum, both are equal to their maxima, so and . Conversely, the sum of two such points attains the maximum.
Lemma 2 (the dimension of a sum). For nonempty convex sets and , , where is the linear space parallel to the affine hull of .
Proof. The affine hull of is , a translate of .
Lemma 3 (edges from adjacent facets). Let and be the outer normals of two facets and of that share an edge . Then . Every edge of arises this way from some pair of facet normals.
Proof. For , , with equality exactly when . The bound is attained, since is not empty, so . Two distinct facets of a 3-polytope meet in a face of dimension at most 1, and here it contains , so it is . Every edge of a 3-polytope lies in exactly two facets.
So the edge directions of line L2, found as the faces of dimension 1 over all pairs of facet normals, are exactly the directions of the edges of , and likewise for . A pair of facets that are not adjacent gives a vertex or nothing new, since its face is a vertex or an edge in that case, and an edge found this way is still an edge of .
Lemma 4 (the normal of a facet). A facet of a polytope with nonempty interior has exactly one outer normal up to a positive factor: the with form the open ray of the outer normal of the plane of .
Proof. If , then is perpendicular to the plane of , since is constant on and spans the plane, and points away from , since lies in and has points off the plane.
Theorem. MINKOWSKI-SUM-CONVEX returns a map whose keys are exactly the primitive outer normals of the facets of , and whose value at is the vertex cycle of the facet .
Proof. (Soundness.) Let pass line L7. By Lemma 1, applied to the hulls, and the remark on finite sets, . This face spans a plane, so it is a facet, and line L8 stores the plane hull of the points, which is the facet. By Lemma 4 the facet has only the normal up to scaling, so no facet is stored twice under two keys.
(Completeness.) Let be a facet of with primitive outer normal , and let and , so by Lemma 1. By Lemma 2 the spaces of and add to a plane. If is a facet of , then by Lemma 4 is its primitive outer normal, which line L1 put in . The same holds if is a facet of . Otherwise and , and their spaces add to dimension 2 only if both are edges, with directions and that are not parallel. By Lemma 3 these directions are found in line L2. The vector is perpendicular to and to , since is constant on each face, so is a nonzero multiple of . Both primitive vectors on that line are added in line L3, so . Line L7 accepts , since spans the plane of by the soundness part.
(The cycle.) The plane hull in line L8 projects the points onto the coordinate plane that drops the coordinate where is largest. This projection is a bijection on the plane of the facet, since , and it keeps or reverses orientation by the sign of , reversed once more for the middle axis since is a left-handed pair. The monotone chain gives the vertices of the projected hull in counterclockwise order, and the code reverses the list when the orientation is reversed, so the cycle is counterclockwise seen from the side points to.
(Termination.) is finite, at most vectors, and each step of lines L5 to L8 does finitely many integer operations.
Corollary (the vertices). The vertices of are the points that occur in the facet cycles. Each vertex of the sum is for some , and a face of a 3-polytope that is a vertex lies in at least three facets, so it occurs in their cycles; conversely every point of a facet cycle is a vertex of that facet, so a vertex of the sum.
Corollary (the size). The sum has at most facets, which is for summands with and vertices, since a 3-polytope with vertices has at most edges and facets. By Euler's formula, the numbers of vertices and edges of the sum are also .
Complexity
- The set has at most vectors, where and count facets and edges. By Euler's formula a convex polytope with vertices has at most edges and facets, so .
- Each candidate needs two support queries in time and a plane hull of points, so the total time is in the worst case. The code adds the brute-force facet search on point sets, ; a B-rep input avoids it.
- The output has facets, and this is tight: for two prisms over regular -gons, one turned by a right angle, the arcs of the top and bottom edges of each prism cross arcs of the other. Fogel, Halperin and Weibel found the exact maximum number of facets of the sum of two convex polytopes; the conference version of their paper states it as for summands with and facets, and the tests check this bound on 300 random pairs.
- With the Gaussian map overlay, the time is the time of a map overlay on the sphere, for crossings by a plane sweep, which is near linear in the output.
- For nonconvex polyhedra the output can have faces, so no method is better than that in the worst case.
Properties
- Exact. Every quantity is an integer: the normals are cross products of integer vectors, and the faces are found by comparing integer dot products. No tolerance is needed, and degenerate inputs, such as parallel edges or coplanar faces, are handled by line L7 and not by special cases.
- Output sensitive with the overlay. The plain version tests pairs even when few of them cross; the Gaussian map overlay pays only for the crossings.
- Symmetric. The output does not depend on the order of and .
- The sum of a polytope and a segment. If is a segment, the sum is the region a translating sweeps, the extrusion case of the sweep representation for a convex profile.
Variants and improvements
- Convex hull of vertex sums. The sum of two convex polytopes is the convex hull of the sums of vertices, which a 3D convex hull algorithm computes in time. It is short to code but does work even when the sum has few faces.
- Gaussian map overlay. Fogel and Halperin's method, with exact arithmetic in CGAL. They also used the sum for collision detection and penetration depth.
- Nonconvex polyhedra by decomposition. Decompose both polyhedra into convex pieces, add each pair of pieces with the convex method, and take the union of all pairwise sums. Hachenberger made this exact, with a decomposition into pieces for reflex edges and the union computed with Nef polyhedra; this is the method of CGAL's 3D Minkowski sum. The union is the expensive step.
- Convolution. As in the plane, a candidate surface is formed from facet and vertex pairs and from edge and edge pairs whose normals match, and the sum is the part of space where this surface has a positive winding number. It avoids the decomposition, but the arrangement of the candidate surface is hard to compute robustly in three dimensions.
- Approximation. Voxel grids and distance fields give approximate sums with a bounded error, used when the inputs are meshes with many faces.
- Minkowski difference. For convex and , the set is the polytope cut out by the facet planes of , each moved inward by of its normal: exactly when for every facet normal of .
When to use it
Use the convex method whenever both solids are convex, or when one is convex and the other is a union of a few convex pieces: tool shapes in machining, convex hulls of robot links, bounding shapes in collision tests. For questions that need only one direction at a time, such as distance and intersection tests between convex shapes, do not build the sum at all; GJK uses the support function of directly. For offsets of a solid by a ball, the sum has spherical and cylindrical faces, and the dedicated offsetting methods are simpler. Use the decomposition method for general polyhedra only when an exact result matters, as in assembly planning, since its output and time can be very large.
Pitfalls
- Only one sign of . The cross product of two edge directions gives the line of the normal, not its side. Test both signs, as line L3 does.
- Parallel edges. If , the edges add to a longer edge, not a facet. Skip the pair, or the code divides by zero when it normalizes the vector.
- Floating-point normals. With floating-point coordinates, two nearly parallel facets of the sum can come out as two facets with a sliver between them, or a face can appear that does not exist. Use integer or rational coordinates and exact dot products, or merge normals with a tolerance and accept that the result is approximate.
- Points that are not vertices. A face found by support queries can contain points of the input that are not vertices, for example the middle of an edge. Take the plane hull of the face, as line L8 does, instead of all points.
- Nonconvex inputs. The face rule holds only for convex sets. For a nonconvex solid, the support face in a direction says nothing about the dents, so the convex method gives the convex hull of the sum, not the sum.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/minkowski-sum-of-polyhedra/. The authors are listed in prov/EBNP81.jsonl.
"""The Minkowski sum of two convex polytopes in R^3, by support faces.
The facets of P + Q have the outer normals of the facets of P, the outer
normals of the facets of Q, and the normals e x f of pairs of non-parallel
edges e of P and f of Q whose Gauss arcs cross. For each candidate normal u
the face of the sum in direction u is F(P, u) + F(Q, u), so a candidate is
a facet exactly when that sum spans a plane. This is the step that the
Gaussian map overlay of Fogel and Halperin does in one sweep; here every
candidate is tested with the support function.
All arithmetic is on Python integers, so every sign is exact. The polytopes
are given as finite point sets with integer coordinates whose convex hull is
three-dimensional; points that are not vertices are allowed.
Cost: O(F_P + F_Q + E_P E_Q) candidates, each tested in O(n + m) time, where
n and m are the input sizes. Finding the facets and edges of the inputs from
point sets takes O(n^4) and O(m^4) time by brute force; a B-rep would give
them directly.
"""
from __future__ import annotations
from math import gcd
from typing import Iterable, Sequence
Vec = tuple[int, int, int]
def sub(a: Vec, b: Vec) -> Vec:
return (a[0] - b[0], a[1] - b[1], a[2] - b[2])
def add(a: Vec, b: Vec) -> Vec:
return (a[0] + b[0], a[1] + b[1], a[2] + b[2])
def dot(a: Vec, b: Vec) -> int:
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
def cross(a: Vec, b: Vec) -> Vec:
return (a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0])
def primitive(u: Vec) -> Vec:
g = gcd(gcd(abs(u[0]), abs(u[1])), abs(u[2]))
return (u[0] // g, u[1] // g, u[2] // g)
def support(points: Sequence[Vec], u: Vec) -> int:
"""h(u) = max of u . x over the points."""
return max(dot(u, p) for p in points)
def face(points: Sequence[Vec], u: Vec) -> list[Vec]:
"""F(P, u): the points of P that attain h_P(u)."""
h = support(points, u)
return [p for p in points if dot(u, p) == h]
def affine_dim(points: Sequence[Vec]) -> int:
"""The dimension of the affine hull of a nonempty point set."""
o = points[0]
vs = [sub(p, o) for p in points[1:] if p != o]
if not vs:
return 0
a = vs[0]
b = next((v for v in vs if cross(a, v) != (0, 0, 0)), None)
if b is None:
return 1
n = cross(a, b)
return 3 if any(dot(n, v) != 0 for v in vs) else 2
def facet_normals(points: Sequence[Vec]) -> set[Vec]:
"""The primitive outer normals of the facets of conv(points). O(n^4)."""
pts = list(dict.fromkeys(points))
out: set[Vec] = set()
k = len(pts)
for i in range(k):
for j in range(i + 1, k):
for l in range(j + 1, k):
n = cross(sub(pts[j], pts[i]), sub(pts[l], pts[i]))
if n == (0, 0, 0):
continue
n = primitive(n)
c = dot(n, pts[i])
s = [dot(n, p) - c for p in pts]
if all(v <= 0 for v in s):
out.add(n)
elif all(v >= 0 for v in s):
out.add((-n[0], -n[1], -n[2]))
return out
def edge_directions(points: Sequence[Vec], normals: Iterable[Vec]) -> list[Vec]:
"""The directions of the edges of conv(points): for two facet normals
u1, u2 the face F(P, u1 + u2) is the common edge when the facets are
adjacent. O(F^2 n)."""
ns = list(normals)
out: set[Vec] = set()
for i in range(len(ns)):
for j in range(i + 1, len(ns)):
w = add(ns[i], ns[j])
if w == (0, 0, 0):
continue
f = face(points, w)
if affine_dim(f) == 1:
a = min(f)
b = max(f)
out.add(primitive(sub(b, a)))
return sorted(out)
def hull_2d_in_plane(points: Sequence[Vec], u: Vec) -> list[Vec]:
"""The vertices of the convex polygon conv(points), which lie in a plane
with normal u, in counterclockwise order seen from the side u points to."""
pts = sorted(set(points))
# drop the coordinate where u is largest, project, take the hull
k = max(range(3), key=lambda i: abs(u[i]))
ax = [i for i in range(3) if i != k]
def pr(p: Vec) -> tuple[int, int]:
return (p[ax[0]], p[ax[1]])
def turn(o: Vec, a: Vec, b: Vec) -> int:
oo, aa, bb = pr(o), pr(a), pr(b)
return (aa[0] - oo[0]) * (bb[1] - oo[1]) - (aa[1] - oo[1]) * (bb[0] - oo[0])
pts.sort(key=pr)
if len(pts) <= 2:
return pts
lower: list[Vec] = []
for p in pts:
while len(lower) >= 2 and turn(lower[-2], lower[-1], p) <= 0:
lower.pop()
lower.append(p)
upper: list[Vec] = []
for p in reversed(pts):
while len(upper) >= 2 and turn(upper[-2], upper[-1], p) <= 0:
upper.pop()
upper.append(p)
hull = lower[:-1] + upper[:-1]
# the projection keeps orientation when u[k] > 0 for the cyclic axes
sign = u[k] if k != 1 else -u[k]
if sign < 0:
hull.reverse()
return hull
def minkowski_sum_convex(P: Sequence[Vec], Q: Sequence[Vec]) -> dict[Vec, list[Vec]]:
"""The facets of conv(P) + conv(Q): a map from each primitive outer
normal to the vertex cycle of the facet. Precondition: both hulls are
three-dimensional and all coordinates are integers."""
fp, fq = facet_normals(P), facet_normals(Q)
cand: set[Vec] = set(fp) | set(fq) # @line L1
for e in edge_directions(P, fp): # @line L2
for f in edge_directions(Q, fq):
c = cross(e, f)
if c != (0, 0, 0):
c = primitive(c) # @line L3
cand.add(c)
cand.add((-c[0], -c[1], -c[2]))
facets: dict[Vec, list[Vec]] = {} # @line L4
for u in sorted(cand): # @line L5
a, b = face(P, u), face(Q, u) # @line L6
s = [add(x, y) for x in a for y in b]
if affine_dim(s) == 2: # @line L7
facets[u] = hull_2d_in_plane(s, u) # @line L8
return facets # @line L9
def vertices_of(facets: dict[Vec, list[Vec]]) -> set[Vec]:
return {v for cyc in facets.values() for v in cyc}
def euler_characteristic(facets: dict[Vec, list[Vec]]) -> int:
"""V - E + F of the boundary given by the facet cycles."""
edges = set()
for cyc in facets.values():
for i in range(len(cyc)):
a, b = cyc[i], cyc[(i + 1) % len(cyc)]
edges.add((min(a, b), max(a, b)))
return len(vertices_of(facets)) - len(edges) + len(facets)
test_minkowski_sum_of_polyhedra.py 118 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/minkowski-sum-of-polyhedra/. The authors are listed in prov/EBNP81.jsonl.
import itertools
import random
import unittest
from minkowski_sum_of_polyhedra import (affine_dim, cross, dot, euler_characteristic, facet_normals,
minkowski_sum_convex, sub, support, vertices_of)
DIRS2 = [w for w in itertools.product(range(-2, 3), repeat=3) if w != (0, 0, 0)]
DIRS4 = [w for w in itertools.product(range(-4, 5), repeat=3) if w != (0, 0, 0)]
def random_body(rng, k_lo=4, k_hi=8, r=3):
while True:
k = rng.randrange(k_lo, k_hi + 1)
pts = list({tuple(rng.randrange(-r, r + 1) for _ in range(3)) for _ in range(k)})
if len(pts) >= 4 and affine_dim(pts) == 3:
return pts
def rank(vs):
vs = [v for v in vs if v != (0, 0, 0)]
if not vs:
return 0
a = vs[0]
b = next((v for v in vs if cross(a, v) != (0, 0, 0)), None)
if b is None:
return 1
n = cross(a, b)
return 3 if any(dot(n, v) != 0 for v in vs) else 2
class TestHandCases(unittest.TestCase):
def test_tetrahedron_plus_its_reflection(self):
t = [(0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1)]
s = minkowski_sum_convex(t, [(-a, -b, -c) for a, b, c in t])
self.assertEqual(len(s), 14) # cuboctahedron
self.assertEqual(sorted(len(c) for c in s.values()), [3] * 8 + [4] * 6)
self.assertEqual(len(vertices_of(s)), 12)
def test_cube_plus_octahedron(self):
c = [(x, y, z) for x in (0, 1) for y in (0, 1) for z in (0, 1)]
o = [(1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0), (0, 0, 1), (0, 0, -1)]
s = minkowski_sum_convex(c, o)
self.assertEqual(len(s), 26)
self.assertEqual(len(vertices_of(s)), 24)
self.assertEqual(euler_characteristic(s), 2)
def test_cube_plus_cube(self):
c = [(x, y, z) for x in (0, 1) for y in (0, 1) for z in (0, 1)]
s = minkowski_sum_convex(c, c)
self.assertEqual(len(s), 6)
self.assertEqual(vertices_of(s), {(x, y, z) for x in (0, 2) for y in (0, 2) for z in (0, 2)})
class TestRandom(unittest.TestCase):
def check_facets(self, P, Q, s):
verts = vertices_of(s)
for u, cyc in s.items():
h = support(P, u) + support(Q, u)
on = {v for v in verts if dot(u, v) == h}
self.assertTrue(all(dot(u, v) <= h for v in verts))
self.assertEqual(on, set(cyc))
self.assertGreaterEqual(len(cyc), 3)
for i in range(len(cyc)):
a, b, c = cyc[i], cyc[(i + 1) % len(cyc)], cyc[(i + 2) % len(cyc)]
n = cross(sub(b, a), sub(c, b))
# a strict left turn seen from outside: n is a positive multiple of u
self.assertEqual(cross(n, u), (0, 0, 0))
self.assertGreater(dot(n, u), 0)
def test_support_function_adds(self):
rng = random.Random(1)
for _ in range(500):
P, Q = random_body(rng), random_body(rng)
s = minkowski_sum_convex(P, Q)
verts = vertices_of(s)
for w in DIRS2:
self.assertEqual(max(dot(w, v) for v in verts), support(P, w) + support(Q, w))
self.check_facets(P, Q, s)
self.assertEqual(euler_characteristic(s), 2)
def test_support_function_many_directions(self):
rng = random.Random(2)
for _ in range(60):
P, Q = random_body(rng, 6, 10, 5), random_body(rng, 6, 10, 5)
s = minkowski_sum_convex(P, Q)
verts = vertices_of(s)
for w in DIRS4:
self.assertEqual(max(dot(w, v) for v in verts), support(P, w) + support(Q, w))
def test_against_hull_of_vertex_sums(self):
"""Brute force: the facets of the hull of all n m sums, by triples."""
rng = random.Random(3)
for _ in range(80):
P, Q = random_body(rng, 4, 5), random_body(rng, 4, 5)
s = minkowski_sum_convex(P, Q)
sums = list({(p[0] + q[0], p[1] + q[1], p[2] + q[2]) for p in P for q in Q})
normals = facet_normals(sums)
self.assertEqual(set(s), normals)
hs = {u: support(sums, u) for u in normals}
want = {x for x in sums if rank([u for u in normals if dot(u, x) == hs[u]]) == 3}
self.assertEqual(vertices_of(s), want)
def test_facet_count_bound(self):
"""The facet bound 4 m n - 9 m - 9 n + 26 of Fogel, Halperin and
Weibel for summands with m and n facets."""
rng = random.Random(4)
for _ in range(300):
P, Q = random_body(rng), random_body(rng)
m, n = len(facet_normals(P)), len(facet_normals(Q))
self.assertLessEqual(len(minkowski_sum_convex(P, Q)), 4 * m * n - 9 * m - 9 * n + 26)
if __name__ == "__main__":
unittest.main()
History
Minkowski defined the sum of convex bodies around 1900 in his work on convex bodies and mixed volumes, and the additivity of support functions was part of that theory. In robotics, Lozano-Pérez used sums of convex polygons and polyhedra for configuration space obstacles in the late 1970s and early 1980s, and in solid modeling, Rossignac and Requicha used sums with a ball to define offsets in 1986. Fogel and Halperin gave an exact and fast construction of the sum of convex polyhedra through Gaussian maps in 2007. Fogel, Halperin and Weibel settled the exact maximum number of facets of the sum of two convex polytopes in 2007 and 2009, and Hachenberger gave the first exact implementation for nonconvex polyhedra by decomposition and Nef polyhedra in 2007, published in 2009.
References
- Efi Fogel and Dan Halperin, Exact and efficient construction of Minkowski sums of convex polyhedra with applications, Computer-Aided Design 39(11), 929 to 940, 2007, the Gaussian map of a convex polyhedron, the overlay of two Gaussian maps as the Gaussian map of the sum, and the exact implementation
- Efi Fogel, Dan Halperin and Christophe Weibel, On the exact maximum complexity of Minkowski sums of polytopes, Discrete and Computational Geometry 42(4), 654 to 669, 2009, the tight bound on the number of facets of the sum of two convex polytopes in three dimensions (the conference version, SoCG 2007, states it as 4mn - 9m - 9n + 26 for summands with m and n facets)
- Peter Hachenberger, Exact Minkowksi sums of polyhedra and exact and efficient decomposition of polyhedra into convex pieces, Algorithmica 55(2), 329 to 345, 2009, the decomposition of nonconvex polyhedra into O(r^2) convex pieces, the pairwise sums and their union with Nef polyhedra (the word Minkowksi is spelled this way in the printed title)
- Rolf Schneider, Convex Bodies, The Brunn-Minkowski Theory, second edition, Cambridge University Press, 2014, Section 1.7 on support functions and their additivity, and Chapter 2 on faces and normal cones of convex bodies
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag EBNP81 Edit this page History Report an error Markdown