Minkowski Sums and Offset Polygons Ron Wein
Computing Minkowski Sums
Given two sets A and B in the plane, their Minkowski sum, denoted A B, is: A B = {a + b | a A, b B} Planar Minkowski Sums =
We are given two polygons P and Q with m and n vertices respectively. If both polygons are convex, the complexity of their sum is m + n, and we can compute it in (m + n) time using a very simple procedure. The Sum Complexity (I)
If only one of the polygons is convex, the complexity of their sum is (mn). If both polygons are non-convex, the complexity of their sum is (m 2 n 2 ). The Sum Complexity (II)
The prevailing method for computing the sum of two non- convex polygons: Decompose P and Q into convex sub- polygons, compute the pair-wise sums of the sub-polygons and obtain the union of these sums. The Decomposition Method P Q P1P1 P2P2 Q1Q1 Q2Q2 P QP Q
Convex Decomposition Schemes (I) Naïve triangulation.Optimal max-degree triangulation: minimizing the maximum degree. Optimal sum-degrees triangulation: minimizing the sum of squared vertex degrees.
Convex Decomposition Schemes (II) Greedy convex decomposition: add diagonals until eliminating all reflex vertices. Optimal polygon decomposition: minimizing the number of convex sub-polygons. Takes O(r 2 n log n) time. Optimal sum-degrees decomposition: minimizing the sum of squared vertex degrees.
Convex Decomposition Schemes (III) (with Steiner Points) Slab decomposition: add vertical segments from each reflex vertex. Angle bisection: add an angle bisector for each reflex vertex. KD-decomposition: adding vertical and horizontal segments.
Given a set of polygons S 1, …, S M with counterclockwise (positive) orientation, construct the arrangement of their edges. Set N(f u ) = 0 for the unbounded face f u. Then compute N(f ) for each other face using a simple BFS traversal. All faces with N(f ) > 0 contribute to the union. Computing the Union (0) (1) (2) (0)
A planar tracing T comprises a continuous set of points. Each point t T is associated with a direction dir(t). The convolution of two planar tracings S and T, denoted S T, comprises the pair-wise sum of all points s S and t T such that dir(s) = dir(t). Convolution of Planar Tracings (Guibas, Ramshaw and Stolfi, 1983) S T s t
A polygonal tracing P consists of moves (going along an edge in a fixed direction), and turns (rotating at a vertex). For a vertex p of P, dir(p) is a continuous range of directions. The convolution P Q therefore contains the sum of each edge of the polygonal tracing Q, whose direction is in dir(p), with p. Convolution of Polygons (I) p dir(p) P Q
At the worst case, the convolution of two polygons P Q consists of (mn) line segments. Guibas and Seidel (1987) gave an output-sensitive algorithm for computing the convolution segments in O(m + n + K) time. The convolution segments form closed cycles. The Minkowski sum P Q contains all points whose winding number with respect to any of the convolution cycles is positive. Convolution of Polygons (II) (0) (1)(2)
The Case of a Single Cycle P Q P QP Q
We compute the first cycle, starting from the two bottommost vertices in P and Q. If P or Q are convex, we are done. Otherwise, while it is possible to locate two vertices p P and q Q that should be in the convolution, construct an additional convolution cycle. The Case of Multiple Cycles
The Minkowski-Sum Package of CGAL
Supports the construction of maintenance of 2D arrangements – planar subdivisions induced by a set of planes. Handles a variety of curves. Each family of curves (line segments, poly-lines, circular arcs, conic arcs, etc.) is handled by a geometric traits-class. The CGAL Arrangement Package Common intersection points Tangency points Handles degenerate cases robustly and accurately, relying on the exact computation paradigm.
The Minkowski-sum package re-implements the robust algorithms for sum-computations using the convex polygon- decomposition method (Agarwal, Flato and Halperin, 2000). The Decomposition Method Available decomposition methods: Optimal. Hertel-Mehlhorn’s approximation scheme. Greene’s approximation scheme. The small-side angle-bisector approximation scheme. Implemented in the Partition_2 package
The first software that robustly implements the convolution algorithms for polygons. Uses the same infrastructure for multi-way polygon union, used by the decomposition method. The same algorithm also works for the case of closed convolution cycles. The Convolution Method
The Minkowski sum of two polygons may contain low- dimensional features (isolated vertices and antennas). The package can treat them as follows: discard them (output the regularized sum), or give access to them through the underlying arrangement. Low-Dimensional Features
Experimental Input Sets (I) chain stars comb fork
Experimental Input Sets (II) cavity random knife country
Experimental Results: Decomposition Running time (ms.)Arrangement sizeT dec (ms.)Slk Input set SSABGre.HMOpt.|F||F||E||E||V||V| chain stars comb fork cavity random knife country
Experimental Results: Convolution Running time (ms.)Arrangement sizeT conv (ms.)KNCNC Input set LEDADecomp.Conv.|F||F||E||E||V||V| chain stars comb fork cavity random knife country
Polygon Offsetting
Polygon Offsetting using the Convolution Method P BrBr Computing the convolution cycle … Computing the induced arrangement and the winding numbers … P BrP Br
Computing the sum of two polygons (objects of the type Polygon_2 ) is of course performed using the Arr_segment_traits_2 class and using exact rational arithmetic. Related Traits Classes In case of offsetting we should consider the following traits classes: Arr_circle_segment_traits_2 – handles line segments and circular arcs using exact rational arithmetic. Arr_conic_traits_2 – handles bounded conic arcs using exact algebraic numbers (based on CORE).
Offsetting a Polygon Edge (I) p 1 = (x 1, y 1 ) p 2 = (x 2, y 2 ) = - 90º q1q1 q2q2
If the line supporting p 1 p 2 is ax + by + c = 0, then the line supporting q 1 q 2 is ax + by + (c + ℓ r) = 0. Offsetting a Polygon Edge (II) Problem: In the general case, offset arcs are not supported by rational lines! Solution no. 1: Represent the offset edge as a segments of a (degenerate) conic curve with rational coefficients:
Our Approximation Scheme p1p1 p2p2 1. Find ’ 1 and ’ 2 such that sin( ’ j ), cos( ’ j ) are rational. ’1’1 ’2’2 3. Compute the intersection q’ of the two tangents at q’ 1 and q’ 2. Use the polyline q’ 1 q’q’ 2 as an approximation. q’q’ q’1q’1 q’2q’2 2. Compute q’ j = (x j + r cos( ’ j ), y j + r sin( ’ j ) ).
Using the half-angle formulae we have: Computing “Rational” Angles (I) Observation: If is rational, then sin( ) = 2 / (1+ 2 ) and cos( ) = (1 - 2 ) / (1 + 2 ) are also rational.
Computing “Rational” Angles (II) If x 1 > x 2 we take a rational approximation : If x 1 < x 2 we approximate the edge length from above (that is, we take a rational ). We use the good old Babylonian method for approximating square roots ( ).
The Approximation Quality Lemma: For any polygon edge connecting (x 1, y 1 ) and (x 2, y 2 ) whose length is ℓ and any > 0, if we take an approximation of the edge length that satisfies: then the approximation error is bounded by . p1p1 p2p2 q’q’ q’1q’1 q’2q’2
Running Times (Pentium IV 3 GHz, in milliseconds) Approximated offsetExact offset SizeInput polygon = r = r (14)Wheel (40)Knife (19)Random (24)Comb (37)Chain (24)Country ❶ ❺ ❹ ❸ ❷ ❶ ❷ ❸ ❹ ❺
Thank you!