1 Introduction

The r-offset of a polygon, for a real parameter r>0, is the set of points at distance at most r away from the polygon. Computing the offset of a polygon is a fundamental operation. The offset operation is, for instance, used to define a tolerance zone around the given polygon [11] or to dilute details for clarity of graphic exposition [4, 16, 20]. Technically, it is usually computed as the Minkowski sum of the polygon and a disk of radius r. The resulting shape is bounded by straight-line segments and circular arcs. However, a customary practice is to model the disk in the Minkowski sum with a (tight) polygon, which yields a piecewise-linear approximation of the offset. Our study is motivated by two applications, where such an approximation forms the legacy data which a program has to deal with—the original shape before offsetting is unknown. This leads to the question what is the original polygon whose approximate offset we have at hand. Of course, finding the exact original polygon, or even its topology, is impossible in general, because the offset might have blurred small features like holes or dents. However, a reasonable choice can lead to a more compact and smooth representation of the approximate offset.

The first relevant problem concerns cutting polygonal parts out of wood. A wood-cutting machine, which can smoothly cut along straight-line segments and circular arcs, is given a plan to cut out a certain shape. This shape was designed as a polygon expanded by a small offset, but with circular arcs approximated by polygonal lines comprising many tiny line segments. Thus instead of moving smoothly along circular arcs, the cutting tool has to move along a sequence of very short segments, and make a small turn between every pair of segments. The process becomes very slow, the tool heats up, and occasionally it causes the wood to burn. Moving the cutting tool smoothly and fast enough is the way to keep it cool. If this were the only issue, other smoothing techniques like arc-spline approximation [5, 12] may have been applicable. However, we may also wish to reduce the offset radius if a more accurate cutting machine is available—in this case, it seems desirable to find the original shape first and then to re-offset with a smaller radius.

A motivation to study this question from a different domain is to recover shapes sketched by a user of a digital pen and tablet. The pen has a relatively wide tip, and the input obtained is in fact an approximate offset (with the radius of the pen tip) of the intended shape. The goal is to give a good polygonal approximation of the intended shape. More broadly, as the offset operation is so commonplace, it seems natural to ask, given only an (approximated) offset shape, what could be the original shape before the offsetting. Therefore, we pose the (offset-)deconstruction problem which comes in two variants:

Problem 1

(The decision problem)

Given a polygonal shape Q, and two real parameters r,ε>0, decide if there exists a polygonal shape P such that Q is within (symmetric) Hausdorff distance ε to the r-offset (i.e., offset with radius r) of P.

Problem 2

(Finding a solution)

If the answer to Problem 1 is YES, compute a polygonal shape P with the desired property. We refer to P as a solution of the deconstruction problem. Note that P might be disconnected, even if Q is connected (Fig. 1).

Fig. 1
figure 1

For a given Q, the red P is a candidate summand whose exact r-offset is shaded. Left: For a given ε, deconstruction is ensured iff ϕ 1ε and ϕ 2ε. Note that, when r decreases, ϕ 1 decreases, but ϕ 2 increases. Middle: Example where Q can be approximated by an r-offset of a P that has much fewer vertices than Q. Right: Example where Q can be approximated by the r-offset of a disconnected shape P (Color figure online)

Problem 1 can be seen as a special case of the Minkowski decomposition problem which asks whether a set can be composed in a non-trivial way as the Minkowski sum of two sets—disallowing a summand to be a homothetic copy of the input set. A general criterion for decomposability of convex sets in arbitrary dimension has been presented in [19]. A particularly well-studied case are planar lattice polygons, because of their close relation to problems in algebra, for instance, polynomial factorization [17]. It has been shown that deciding decomposability is NP-complete for lattice polygons [8]. In [6], decomposability is investigated under the constraint that one of the summands is a line segment, a triangle, or a quadrangle. However, all these approaches discuss the exact decomposition problem; our scenario of being Hausdorff-close to a particular decomposition seems to not have been addressed in the literature. Allowing tolerance raises interesting algorithmic questions and at the same time makes the tools that we develop more readily suitable for applications, which typically have to deal with inaccuracies in measuring and modeling.

Contributions

We first present an efficient algorithm to decide Problem 1: For a shape Q with n vertices, the algorithm reports the correct answer in O(nlogn) time in the real-RAM model of computation [18]. It constructs offsets with increasing radii in three stages; the intermediate shapes arising during the computation are in general more difficult to offset than polygons, as they are bounded by straight-line segments and “indented” circular arcs (namely, the shape is locally on the concave side of the arcs). The main observation is that for certain classes of such shapes, these circular arcs can be ignored when computing the next offset (see Theorem 5 for the precise statement). This observation bounds the time required by each offset computation by O(nlogn), which is the key to the efficiency of the decision algorithm. Our proof is constructive, that is, if a solution exists it can be computed with the same running time.

The computation of the exact decision procedure requires the handling of algebraic coordinates of considerably high degree. As an alternative, we give an approximation scheme that works exclusively with rational numbers. The scheme proceeds by replacing the offset disks by polygonal shapes of similar diameter, whose precision is determined by another parameter δ<ε. We prove a bound Δ that depends on \({\hat {\varepsilon }}\), the minimal ε for which the answer to the decision problem is YES, such that the rational approximation returns the exact result for all δ≤Δ. If the input shape is found to be deconstructible, this algorithm also outputs a solution. The computation of \({\hat {\varepsilon }}\) up to any desired precision is still possible. We believe that our investigation of the relation between δ and \({\hat {\varepsilon }}\) is of independent relevance, mostly to the study of certified algorithms that approximate geometric objects with algebraic coordinates by means of rational arithmetic.

The deconstruction problem leads to natural optimization questions: if Q and r are given, how to compute \({\hat {\varepsilon }}\), the minimal tolerance for which a solution exists? Similarly, if Q and ε are given, what are the possible radii such that a solution exists? For the first question, we provide a certified and efficient solution based on binary search, using the rational-approximation algorithm. For the second question, we prove that the set of possible radii forms an interval and propose an algorithm to compute it. We also provide a heuristic to find a reasonable radius r if both r and ε are unknown.

For a convex shape Q with n vertices, we reduce the running time for solving Problem 1 to the optimal O(n) (in the real-RAM model). Moreover, we describe a greedy algorithm within the same time complexity that returns a solution P which minimizes, up to one extra vertex, the number of vertices among all solutions, if there are any. Our algorithm technically resembles an approach for the different problem of finding a vertex-minimal polygon in the annulus of two nested polygons [1]. We also remark that the r-offset of P has a tangent-continuous boundary and therefore constitutes a special case of an arc-spline approximation of Q where all circular arcs have the same radius.

Organization

We describe an exact decision algorithm for the deconstruction problem (solving Problem 1 above) in Sect. 2. In Sect. 3 we describe a rational-approximation algorithm for the deconstruction problem. Both algorithms output a solution in case the input is deconstructible (solving Problem 2). Section 4 discusses the optimization problems. For convex input, Sect. 5 exposes a specialized deconstruction algorithm and the computation of an almost vertex-minimal solution. We conclude in Sect. 6 by pointing out open problems.

2 The Decision Algorithm

For a set X⊂ℝ2 denote its boundary by ∂X and its complement by X C:=ℝ2X. A polygonal region or polygonal shape X⊂ℝ2 is a set whose boundary consists of finitely many line segments with disjoint interiors. The endpoints of these straight-line segments are the vertices of the polygonal region. We assume henceforth that the input shapes that we deal with are bounded (but not necessarily connected). Although the techniques seem to go through also for unbounded shapes, this assumption simplifies the exposition and is sufficient for the real-life applications we have in mind. For two sets X and Y, we denote their Minkowski sum by XY:={x+yxX,yY}. With d(⋅,⋅) the Euclidean distance function, and any c∈ℝ2,r∈ℝ, we write D r (c):={p∈ℝ2d(c,p)≤r} for the (closed) r-disk around c, and D r :=D r (O) for the r-disk centered at the origin. The r-offset of a set X, offset(X,r), is the Minkowski sum XD r .

For p∈ℝ2 and X a closed set, we write d(p,X):=min{d(p,x)∣xX}. The (symmetric) Hausdorff distance of two closed point sets X and Y is

$$H(X,Y):=\max\bigl\{\max\bigl\{d(x,Y)\mid x\in X\bigr\}, \max\bigl\{d(y,X)\mid y \in Y\bigr\}\bigr\}. $$

We say that X is ε-close to Y (and Y to X) if H(X,Y)≤ε, which can also be expressed alternatively:

Proposition 1

For X,Y closed, X is ε-close to Y if and only if Y⊆offset(X,ε) and X⊆offset(Y,ε).

Decision Algorithm

We fix r>0, ε>0, and a polygonal region Q, and consider the following question: Is there a polygonal region P such that Q and the r-offset of P have Hausdorff distance at most ε? First of all, we can assume that r>ε; otherwise, we can choose P:=Q, because offset(Q,r) and Q have Hausdorff distance at most ε. We define another operation, r-inset (a.k.a. “erosion”), which is computationally similar to an offset:

Definition 2

For r>0, and X⊂ℝ2, the r-inset of X is the set inset(X,r):=offset(X C,r)C={x∈ℝ2D r (x)⊆X}.

We are now ready to present the decision algorithm:

See Fig. 2 for an example with a positive answer. We next prove that Decide (Algorithm 1) correctly decides whether Q is ε-close to some r-offset of a polygonal region. A first observation is that for any polygonal region P, offset(P,r)⊆Q ε if and only if PΠ. This is an immediate consequence of the definition of the inset operation. This shows that for any offset(P,r) that is ε-close to Q, P must be inside Π. Moreover, it shows that any choice of PΠ already satisfies one of Proposition 1’s inclusions. It is only left to check whether Q⊆offset(offset(P,r),ε)=offset(P,r+ε). We summarize:

Fig. 2
figure 2

The decision algorithm illustrated on an M-shaped polygon. The set on the right-hand side of the expression is colored in light gray, the set on the left-hand side in dark gray

Algorithm 1
figure 3

Decide(Q,r,ε)

Proposition 3

Q is ε-close to offset(P,r) if and only if PΠ and Q⊆offset(P,r+ε).

To prove correctness of Decide, we have to show that Q⊆offset(Π,r+ε) already implies that there also exists a polygonal region PΠ with Q⊆offset(P,r+ε); see Fig. 3. The main difficulty in proving this is that Π is not polygonal in general; we have to study its shape closer to prove that we can approximate it by a polygonal region, maintaining the property that the offset remains ε-close to Q.

Fig. 3
figure 4

The polygon in light gray and Π (in medium gray) have the same offset (dark gray)

The Shape of Offsets and Insets

For a polygonal region Q, it is not hard to figure out the shape of Q ε =offset(Q,ε): It is a closed set bounded by straight-line segments and by circular arcs, belonging to a circle of radius ε. It is important to remark that all circular arcs are bulges.

Definition 4

Let X⊂ℝ2 be a closed set with some circular arc γ on its boundary. Then, γ is called a dent with respect to X, if each line segment connecting two distinct points on γ is not fully contained in X. Otherwise, the arc is called a bulge.

We call X a bulged (resp. an indented) region with radius r, if ∂X consists of finitely many straight-line segments and bulges (resp. dents) that are all of radius r, interlinked at the vertices of the region.

Note that a bulged region (left) is not necessarily convex. The r-offset of a polygonal region P is a bulged region with radius r. The heart of this section is Theorem 5 showing that the same also holds if P is an indented region (right) with radius smaller than r.

Theorem 5

Let P be an indented region with radius r 1, and let r 2>r 1. Then, there is a polygonal region P L P such that offset(P,r 2)=offset(P L ,r 2). In particular, offset(P,r 2) is a bulged region with radius r 2.

Proof

After possibly splitting circular arcs into at most four parts, we can assume that each circular arc spans at most a quarter of the circle. For such a circular arc, we define its endpoints by x 1 and x 2, and denote the linear cap of the circular arc as the (closed) indented region enclosed by the circular arc, and the two lines tangent to the circle through x 1 and x 2 (the shaded area in Fig. 4(a)). The extended linear cap is the (polygonal) region spanned by the two tangents just mentioned, and the two corresponding normals at x 1 and x 2. Clearly, the normals meet in the center of the circle that defines the arc.

Fig. 4
figure 5

(a) The (extended) linear cap split by the polyline , (bc) the two cases in the proof of Theorem 5

We iteratively replace an indented arc of an indented region P′ with radius r 1 (initially set to P) by a polyline ending in the endpoints of the circular arc, such that does neither leave P′ nor the linear cap of the circular arc, and such that other boundary parts of P′ are not intersected. This yields another indented region P″ with radius r 1, where one indented arc is replaced by a polyline, as depicted in Fig. 4(a). Iterating this construction, starting with P, until all indented arcs are replaced, we obtain a polygonal region P L .

We show that in each iteration, the r 2-offsets of P′ and P″ are the same. For that we consider any point x′∈P′∖P″, in the region that is cut off by P″, and consider y=x′+v′ for an arbitrary \(v'\in D_{r_{2}}\). We show that in all cases, y can also be written by y=x″+v″, with x″∈P″, and \(v''\in D_{r_{2}}\).

Since the circular arc spans at most a quarter of the circle, it is easily seen that \(D_{r_{1}}(x_{1})\cup D_{r_{1}}(x_{2})\) covers the whole extended linear cap. Therefore, for any y that lies within the extended linear cap, selecting x″=x 1 or x″=x 2, we get y=x″+v″ with \(v''\in D_{r_{1}}\).

We distinguish two other cases: for y that lies outside of the extended linear cap \(v'=\overline{x'y}\) crosses either or the circular arc. In the former case, we can simply pick the crossing point as x″, and set \(v''\in D_{r_{2}}\) accordingly (Fig. 4(b)). In the latter case, let us denote the crossing point as x (Fig. 4(c)). We consider the set of points that is closer to x than to x 1 and x 2. Clearly, that region is bounded by the two corresponding bisectors, which meet in the center of the circle that defines the circular arc and is therefore completely contained within the extended linear cap. It follows that y is closer to one of the endpoints of the arc, say x 1, than to x . Selecting x″=x 1 we ensure y is closer to x″ than to x′, which proves that y=x″+v″ with some \(v''\in D_{r_{2}}\) in this case as well. □

The proof of Theorem 5 implies that offset(P,r 2) for such a region P is completely determined by the offset of its linear segments, and the offset of the endpoints of circular arcs: the interior of the indented circular arcs can be ignored.

Corollary 6

Algorithm  1 (Decide) returns YES if and only if there exists a polygonal region P such that offset(P,r) is ε-close to Q.

Proof

Q ε is a bulged region with radius ε. Therefore, \(Q_{\varepsilon }^{C}\) is an indented region with the same radius. Since r>ε, Theorem 5 implies that \(\mathrm {offset}(Q_{\varepsilon }^{C},r)\) is a bulged region with radius r, and so, \(\mathrm {offset}(Q_{\varepsilon }^{C},r)^{C}=\mathrm {inset}(Q_{\varepsilon },r)=\varPi \) is an indented region with the same radius. Using r+ε>r and applying Theorem 5 once more, there exists a polygonal region PΠ such that offset(Π,r+ε)=offset(P,r+ε). It follows that, if the algorithm returns YES, there is indeed a polygonal region P whose r-offset is ε-close to Q. If the algorithm returns NO, it is clear that no such polygonal region can exist. □

Theorem 7

Let P be an indented region with radius r 1 having n vertices, and assume r 2>r 1. Then, offset(P,r 2) has O(n) vertices and it can be computed in O(nlogn) time.

Proof

By Theorem 5, it suffices to consider a polygonally bounded P L instead of P. We use trapezoidal decomposition of P to construct such a P L with only O(n) vertices. The Voronoi diagram of P L ’s vertices and (open) edges can be computed in O(nlogn) time and has size O(n) [22]. From it, the offset polygon with the same asymptotic complexity can be obtained in O(nlogn) [13]. □

Corollary 8

Algorithm  1 (Decide) decides ε-closeness with O(nlogn) operations.

Proof

Apply Theorem 7 in each step of Algorithm 1. The fourth step runs in O(nlogn) time as well using a simple sweep-line algorithm. □

Note that Π L , if constructed for Π as in the proof of Theorem 5 during step (3) of Algorithm 1, is a solution to the deconstruction problem if Decide returns YES.

3 Rational Approximation

A direct realization of Algorithm 1 runs into difficulties since vertices of the resulting offsets are algebraic numbers whose degrees become high in cascaded offset computations. We next describe two approximation variants of Algorithm 1, each producing a certified one-sided decision by approximating all disks in the algorithm with k-gons. In order to make guaranteed statements about the exact ε-approximability by r-offsets, we have to approximate the disks by a “working precision” δ which is even smaller than ε. Recall that D r is the disk of radius r centered at the origin. For a,b∈ℝ, a<b define \(\bar {D}_{{a},{b}}\) to be a polygon with rational vertices whose boundary lies in the annulus D b D a . In the approximation algorithms, every disk is replaced with such a polygon lying inside a δ-width annulus.

Interior Approximation

In the first part of our algorithm, we ensure that the final approximation of Q′ (see line (3) of Algorithm 1), called \(\widehat{Q'}\), will be a subset of the exact Q′. We achieve this by approximating D s by \(\bar {D}_{{s-\delta},{s}}\) when an offset is computed; and by approximating D s by \(\bar {D}_{{s},{s+\delta}}\) when an inset is computed; see Algorithm 2.

Algorithm 2
figure 6

ApproxDecideInterior(Q,r,ε,δ)

Lemma 9

If ApproxDecideInterior(Q,r,ε,δ) returns YES, then Decide(Q,r,ε) returns YES as well, which means that there exists a polygonal region P such that offset(P,r) is ε-close to Q. In particular, \(P:=\widehat{\varPi }\) is a solution to the deconstruction problem.

Proof

Compare the execution of Algorithm 2 with the corresponding call of its exact version, Algorithm 1. It is straightforward to check that for any δ, \(\widehat{Q_{\varepsilon }}\subset Q_{\varepsilon }\), \(\widehat{\varPi }\subset \varPi \), and \(\widehat{Q'}\subset Q'\). The last inclusion shows that if \(Q\subseteq\widehat{Q'}\), also QQ′. □

Definition 10

For fixed Q and r, define \(\hat {\varepsilon }:=\inf\{\varepsilon \mid \textsc{Decide}(Q,r,\varepsilon )\ \text{returns}\ \hbox {\small \textsf {YES}}\}\).

Note that \(\hat {\varepsilon }\in[0,r]\), and that Decide(Q,r,ε) returns YES for every \(\varepsilon \geq \hat {\varepsilon }\) and returns NO for every \(\varepsilon <\hat {\varepsilon }\). We do not have a way to compute \(\hat {\varepsilon }\) exactly. However, we show next that ApproxDecideInterior(Q,r,ε,δ) returns YES for every \(\varepsilon >\hat {\varepsilon }\) for δ small enough, and that the required precision δ is proportional to the distance of ε to \(\hat {\varepsilon }\).

Theorem 11

Let \(\varepsilon >\hat {\varepsilon }\), and \(\delta<\frac{\varepsilon -\hat {\varepsilon }}{2}\). Then, ApproxDecideInterior(Q,r,ε,δ) returns YES.

Proof

Let ε 0 be such that \(\hat {\varepsilon }<\varepsilon _{0}<\varepsilon _{0}+2\delta\leq \varepsilon \). Let \(Q_{\varepsilon _{0}}\), Π and Q′ denote the intermediate results of Decide(Q,r,ε 0) and let \(\widehat{Q_{\varepsilon }}\), \(\widehat{\varPi }\), \(\widehat{Q'}\) denote the intermediate results of ApproxDecideInterior(Q,r,ε,δ). By the choice of ε 0, YES is returned, and thus QQ′. The theorem follows from \(Q'\subseteq \widehat{Q'}\), which we prove in three substeps:

  1. (1)

    \(\mathrm {offset}(Q_{\varepsilon _{0}},\delta)\subseteq \widehat{Q_{\varepsilon }}\): Indeed,

    $$\mathrm {offset}(Q_{\varepsilon _0},\delta)=\mathrm {offset}(Q,\varepsilon _0+\delta)\subseteq \mathrm {offset}(Q,\varepsilon -\delta)\subset Q\oplus\widehat{D_\varepsilon }= \widehat{Q_\varepsilon }. $$
  2. (2)

    \(\varPi \subseteq\widehat{\varPi }\): Starting with (1), we obtain

    We use the general fact inset(offset(A,r),r)⊇A to obtain

  3. (3)

    \(Q'\subseteq\widehat{Q'}\): Using (2), we have

    $$\mathrm {offset}(\varPi ,r+\varepsilon -\delta)=\varPi \oplus D_{r+\varepsilon -\delta}\subseteq \widehat{\varPi } \oplus\widehat{D_{r+\varepsilon }}=\widehat{Q'}. $$

    Note that r+εδ>r+ε 0, and therefore, offset(Π,r+εδ)⊃offset(Π,r+ε 0)=Q′.

 □

Exterior Approximation

In Algorithm 3, we ensure that \(\widehat{Q'}\) becomes a superset of the exact Q′ by appropriately choosing approximate disks. Specifically, we approximate D s by \(\bar {D}_{{s},{s+\delta}}\) when an offset is computed, and D s by \(\bar {D}_{{s-\delta},{s}}\) when an inset is computed. Not surprisingly, we get a certified answer in the other direction, and a certified answer is guaranteed when δ is sufficiently small. The proofs of the following two statements are similar to Lemma 9 and Theorem 11 and thus omitted.

Algorithm 3
figure 7

ApproxDecideExterior(Q,r,ε,δ)

Lemma 12

If ApproxDecideExterior(Q,r,ε,δ) returns NO, then Decide(Q,r,ε) returns  NO as well, which means that there exists no polygonal region P such that offset(P,r) is ε-close to Q.

Theorem 13

Let \(\varepsilon <\hat {\varepsilon }\) and \(\delta<\frac{\hat {\varepsilon }-\varepsilon }{2}\). Then, ApproxDecideInterior(Q,r,ε,δ) returns  NO.

In combination with Theorem 11, it follows that the exact answer can always be found for \(\delta<\Delta:=\frac{|\varepsilon -\hat {\varepsilon }|}{2}\) by combining ApproxDecideExterior and ApproxDecideInterior. We display the complete rational-approximation algorithmFootnote 1 for later reference in Algorithm 4.

Algorithm 4
figure 8

ApproxDecide(Q,r,ε,δ)

Complexity Analysis

The main task is to bound the number of vertices of \(\bar {D}_{{a},{b}}\). We will create a \(\bar {D}_{{a},{b}}\) with the additional property that all vertices lie on ∂D b . As depicted below, two such points on D b are connected by a chord of the boundary circle that does not intersect D a if and only if the angle induced by the two points is at most \(\psi:=2\arccos\frac{a}{b}\), or equivalently, the length of the chord is less than \(2\sqrt{b^{2}-a^{2}}\). Note that we need at least \(\frac{2\pi}{\psi}\) points on ∂D b for a valid \(\bar {D}_{{a},{b}}\), and \(\frac{2\pi}{\psi}\in\varTheta(\sqrt{\frac{b}{b-a}})\) as easily shown by L’Hopital’s rule.

Rational points on ∂D b can be constructed for an arbitrary t∈ℚ as \(Q_{t}:=(b\frac{1-t^{2}}{1+t^{2}},b\frac{2t}{1+t^{2}})\) [3]. For some positive z∈ℤ, we define P i :=Q i/z for i=0,…,z.

Lemma 14

For every i=1,…,z−1, the chord P i−1 P i is longer than the chord P i P i+1. In particular, the length of each chord is bounded by the length of P 0 P 1 which is shorter than \(\frac{2b}{z}\).

Proof

W.l.o.g., we assume b=1 for the proof, since the chord length scales proportionally when scaling the circle by a factor of b. The point \(Q_{t}=(\frac{1-t^{2}}{1+t^{2}},\frac{2t}{1+t^{2}})\) can be constructed geometrically as the intersection point of ∂D b with the line t through S=(−1,0) and slope t (see the figure below). In particular, the line SP i has slope \(\frac{i}{z}\); we let T i denote the intersection point of that line with the line x=1. We observe that the segment T i T i+1 has length \(\frac{2}{z}\), and that ST i <ST i+1 for i=0,…,z−1.

We are showing next that the chord P i−1 P i is longer than P i P i+1. For that, we consider the triangle SD i−1 D i+1, and its bisector at S. This bisector intersects the line x=1 at some point B. By the Angle Bisector theorem, B divides the segment T i−1 T i+1 proportionally to the corresponding triangle sides, that is, \(\frac {ST_{i-1}}{ST_{i+1}} = \frac {BT_{i-1}}{BT_{i+1}}\). Because the left-hand side is smaller than 1, it follows that BT i−1 is shorter than BT i+1. Therefore, B lies below T i , and therefore, the angle α i−1=∠T i−1 ST i =∠P i−1 SP i is larger than α i =∠T i ST i+1=∠P i SP i+1. But the chord lengths P i−1 P i and P i P i+1 are defined by 2sin(α i−1) and 2sin(α i ), respectively, which proves that the chord lengths are indeed decreasing.

Finally, by Thales’ theorem, the triangle SP 0 P 1 has a right angle at P 1. Therefore, the longest chord P 0 P 1 is shorter than the segment T 0 T 1, which has length \(\frac{2}{z}\). □

Note that all P i ’s lie in the first quadrant of the plane and that P 0:=(b,0) and P z :=(0,b). Therefore, we can subdivide the other three quarters of the circle symmetrically such that the length of each chord is bounded by \(\frac{2b}{z}\), using 4z vertices altogether. To compute a valid \(\bar {D}_{{a},{b}}\), it suffices to choose z such that \(\frac{2b}{z}\leq 2\sqrt{b^{2}-a^{2}}\), that is, \(z \geq \sqrt{\frac{b^{2}}{b^{2}-a^{2}}}\). We choose \(z_{0}:= \lceil \sqrt{\frac{b}{b-a}} \rceil\), indeed, since 0<a<b, we have \(z_{0}\geq\sqrt{\frac{b}{b-a}}>\sqrt{\frac{b}{b-a}\cdot\frac{b}{b+a}}=\sqrt{\frac{b^{2}}{b^{2}-a^{2}}}\). As stated above, we need at least \(\varOmega(\sqrt{\frac{b}{b-a}})\) points, so z 0 is an asymptotically optimal choice. We summarize the result

Lemma 15

For a<b, a polygonal region \(\bar {D}_{{a},{b}}\) as above with \(O(\sqrt{\frac{b}{b-a}})\) (rational) points can be computed using \(O(\sqrt{\frac{b}{b-a}})\) arithmetic operations.

The Minkowski sum of an arbitrary polygonal region with n vertices and a convex polygonal region with k vertices has complexity O(kn) and it can be computed in O(nklog2(nk)) operations by a simple divide-and-conquer approach, using a sweep-line algorithm in the conquer step [14]. Using generalized Voronoi diagrams where the distance is based on the convex summand of the Minkowski sum operation [15], we obtain an improved algorithm, which requires only O(knlog(kn)) operations. In combination with Lemma 15, this leads to the following complexity bound for the two approximation algorithms.

Theorem 16

Algorithm ApproxDecide requires

$$O\biggl(n\frac{r}{\delta}\sqrt{\frac{\varepsilon }{\delta}}\cdot \log\biggl(n \frac{r}{\delta}\sqrt{\frac{\varepsilon }{\delta}}\biggr)\biggr) $$

arithmetic operations with rational numbers.

We remark that the O(nlogn) bound for Decide refers to operations with real numbers instead.

We have implemented the algorithms ApproxDecideInterior and ApproxDecideExterior using exact rational arithmetic using the Cgal Footnote 2 packages for polygons [9], Minkowski sums [21] and Boolean set operations [7]. We demonstrate the execution of our software on two examples in Figs. 5 and 6.

Fig. 5
figure 9

Dependency of the algorithm’s outcome on ε and δ: The input polygon (wheel) appears in bold line. It is colored according to its approximability with the given parameters: green for YES, red for NO and yellow for UNDECIDED. The inset polygon \(\widehat{\Pi}\) and its approximate (r+ε)-offset \(\widehat{Q'}\) are drawn in green and cyan, respectively. Their outer-approximation counterparts are drawn in red and magenta. Figures (a) and (b) demonstrate how when ε is tightened from \(\frac{1}{3} \cdot r\) to \(\frac{1}{9} \cdot r\), with the same r and δ, the decision result changes from YES to NO. The green polygon inside the input polygon in (a) is a possible r-offset solution. The magnification in (b) highlights the area of the input polygon that does not fit inside the outer δ-approximation (in magenta) of maximal possible (r+ε)-offset. Figures (c) and (d) show how when δ is decreased from \(\frac{1}{4} \cdot \varepsilon \) to \(\frac{1}{10} \cdot \varepsilon \), for the same r and ε, the decision result changes from UNDECIDED to NO, namely in the latter case the algorithm is able to produce a certified negative answer (Color figure online)

Fig. 6
figure 10

A map of Kazakhstan, represented as a polygon Q (in bold blue) with 1881 vertices, is approximable for \(\varepsilon = \frac{1}{2} \cdot r\) and \(\delta = \frac{1}{8} \cdot \varepsilon \). A solution polygon P (in green) has 335 vertices. Offset(P,r) (shown as lightly shaded gray r-strip around P) is inside the ε-offset of the input Q by construction. The δ-approximation of the ε-offset of Offset(P,r) (as computed in line (3) of ApproxDecideInterior(Q,r,ε,δ)) is drawn in cyan and has 261 vertices. Since the cyan polygon contains Q, the Offset(P,r) and Q have Hausdorff distance of at most ε, that is, Q is approximable and P is a solution. Approximability computation took 3.868 seconds in this case on a 3 GHz Intel Dual Core processor. The magnification on the left highlights some cavities in the input polygon that have no effect on the Hausdorff distance within this tolerance ε. The magnification on the right demonstrates a sharp end that would prevent Q’s approximability with a tighter ε (Color figure online)

4 Searching ε and r

So far, we have assumed that both r and ε are given as input parameters, and we posed the question of deconstructing a polygon with respect to these parameters. We now investigate three variants where r and/or ε are unknown. Specifically, we ask, for some input polygon Q:

  1. 1.

    Given r, what is \(\hat {\varepsilon }\), the infimum of all ε-values such that the deconstruction problem has a solution (compare Definition 10)?

  2. 2.

    Given ε, what is the set of radii for which the deconstruction problem has a solution?

  3. 3.

    Given neither r nor ε, how are we to choose them in a “reasonable” way to obtain a solution?

Whereas the first two questions are formally posed, the third one is of a rather heuristic nature. In all three cases, we also ask for computing some polygonal shape P that approximates the solution of the deconstruction problem for the given set of parameters.

We discuss the posed questions in the remainder of this section. Our main tool will be the decision algorithm for fixed r and ε as described earlier. Because we aim for a practical algorithm, we formulate our approach using the rational-approximation algorithm from Sect. 3. We have implemented the proposed algorithms; the example at the end of this section has been produced with our implementation.

Searching for \(\hat {\varepsilon }\)

If we use the exact decision procedure Decide, it is straightforward to approximate \(\hat {\varepsilon }\) to arbitrary precision Δ employing binary search: Start with the interval [0,r] and choose ε as the midpoint of the interval. If Decide(Q,r,ε) returns YES, recurse on the left subinterval, otherwise, on the right one. Obviously, the interval width is halved in every step, so \(O(\log(\frac{r}{\Delta}))\) steps are necessary. Let \(\widetilde {\varepsilon _{\Delta }}\) denote the \(\hat {\varepsilon }\) approximation, s.t. \(\widetilde {\varepsilon _{\Delta }}- \hat {\varepsilon }\leq \Delta\). We demonstrate next that we can achieve the same approximation and produce with it a solution to the deconstruction problem using the rational approximation version ApproxDecide.

Let |I| denote the width of I henceforth on and consider the pseudocode given in Algorithm 5. It computes an interval I of width at most Δ that contains \(\hat {\varepsilon }\).

Algorithm 5
figure 11

ApproxSearchEps(Q,r,Δ)

We prove the invariant that \(\hat {\varepsilon }\in I\) after each iteration of the while-loop, implying correctness of the whole algorithm. Trivially, \(\hat {\varepsilon }\in [0,r]\), and the invariant is obviously maintained if ApproxDecide(Q,r,ε mid,δ) returns YES or NO. For the case of UNDECIDED, recall that ApproxDecide is a combination of the two one-sided approximation algorithms ApproxDecideExterior and ApproxDecideInterior, and both returned UNDECIDED. Theorems 11 and 13 imply therefore that

$$\frac{|I|}{8}\geq \biggl|\frac{ \varepsilon _{\mathrm {mid}}-\hat {\varepsilon }}{2}\biggr|. $$

It follows that \(\hat {\varepsilon }\in [ \varepsilon _{\mathrm {mid}}-\frac{|I|}{4}, \varepsilon _{\mathrm {mid}}+\frac{|I|}{4}]\) which proves that the invariant is maintained also in this case.

We next compute a solution P for the deconstruction problem for Q, r and \(\widetilde {\varepsilon _{\Delta }}\). Recall that if ApproxDecide returns YES, the algorithm computes a solution for the deconstruction problem as a by-product. Let IApproxSearchEps(Q,r,Δ) be the approximation interval for \(\hat {\varepsilon }\) and let ε yes denote the right endpoint of I, that is, \(\hat {\varepsilon }\leq \varepsilon _{\mathrm {yes}}\). We call \(\textsc {ApproxDecide}(Q, r, \varepsilon _{\mathrm {yes}}, \frac{|I|}{4})\). If the result is YES, then \(\widetilde {\varepsilon _{\Delta }}= \varepsilon _{\mathrm {yes}}\) and the polygon computed by ApproxDecide is a solution. Otherwise let us choose \(\widetilde {\varepsilon _{\Delta }}= \varepsilon _{\mathrm {yes}}+ \frac{\Delta}{2}\) and produce a solution by calling \(\textsc {ApproxDecide}(Q, r, \widetilde {\varepsilon _{\Delta }}, \frac{\Delta}{8})\). Since the result of \(\textsc {ApproxDecide}(Q, r, \varepsilon _{\mathrm {yes}}, \frac{|I|}{4})\) was UNDECIDED we conclude from Theorem 11 that \(\hat {\varepsilon }\geq \varepsilon _{\mathrm {yes}}-\frac{|I|}{2}\), that is, \(\widetilde {\varepsilon _{\Delta }}= \varepsilon _{\mathrm {yes}}+ \frac{\Delta}{2}\) is indeed Δ-approximation of \(\hat {\varepsilon }\). The call to \(\textsc {ApproxDecide}(Q, r, \widetilde {\varepsilon _{\Delta }}, \frac{\Delta}{8})\) is bound to yield YES because if it returned UNDECIDED, we would have \(\hat {\varepsilon }\geq \widetilde {\varepsilon _{\Delta }}- 2\frac{\Delta}{8} = \varepsilon _{\mathrm {yes}}+\frac{\Delta}{4}\), a contradiction to \(\hat {\varepsilon }\leq \varepsilon _{\mathrm {yes}}\). So, the polygon computed in this call is a solution.

An overall complexity analysis of approximating \(\hat {\varepsilon }\) (and computing a solution) is relatively straightforward: I is obviously halved in every iteration, so it takes \(O(\log(\frac{r}{\Delta}))\) iterations to approximate \(\hat {\varepsilon }\). Every iteration is bounded by the complexity given in Theorem 16. We omit further details of the proof:

Theorem 17

Approximating \(\hat {\varepsilon }\) to a precision Δ>0 requires

$$O\biggl(n\frac{r}{\Delta}\sqrt{\frac{\hat {\varepsilon }}{\Delta}} \cdot \log\biggl(n\frac{r}{\Delta}\sqrt{\frac{\hat {\varepsilon }}{\Delta}}\,\biggr)\biggr) $$

arithmetic operations with rational numbers.

Searching Valid Radii

We assume now that Q and ε are given, and discuss the question of what is the set R of radii such that the deconstruction problem has a solution. A priori, it is not clear what is the shape of R, but we will prove that it is an interval of the form [0,r ]. Having established this, we can apply another variant of binary search to approximate the extremal value r .

In order to prove that R is an interval, we prove first that the deconstruction problem can always be solved for Q, r and \(\hat {\varepsilon }\). In other words, we can replace the infimum in Definition 10 by a minimum. The proof relies on two properties of infinite intersections of insets and offsets that we show first.

Lemma 18

Let (A i ) i∈ℕ be a sequence of closed sets in2. Then

$$\mathrm {inset}\Biggl(\bigcap_{i=0}^{\infty}A_i,r \Biggr)=\bigcap_{i=0}^{\infty} \mathrm {inset}(A_i,r). $$

Proof

The fact follows readily from the definition of insets: If \(a\in \mathrm {inset}(\bigcap_{i=0}^{\infty}A_{i},r)\), then D r (a) is contained in \(\bigcap_{i=0}^{\infty}A_{i}\). In particular, it is contained in A i for every i which proves one inclusion. The other direction is similar. □

Lemma 19

Let (A i ) i∈ℕ be a sequence of closed sets in2 with A 0A 1⊇⋯. Moreover, let (λ i ) i∈ℕ be a monotonously decreasing sequence of real numbers that converges to λ∈ℝ. Then

$$\mathrm {offset}\Biggl(\bigcap_{i=0}^{\infty}A_i, \lambda\Biggr)=\bigcap_{i=0}^{\infty} \mathrm {offset}(A_i,\lambda_i). $$

Proof

The “⊆” inclusion is straightforward, so we concentrate on the “⊇” part. Fix some b∈⋂offset(A i ,λ i ). For every i∈ℕ, there exists some a i A i such that \((b-a_{i})\in D_{\lambda_{i}}\). Now, the sequence (ba i ) i∈ℕ is a bounded sequence in ℝ2 (bounded by \(D_{\lambda_{0}}\)) and therefore has a convergent subsequence by the well-known Bolzano–Weierstrass Theorem. Let r denote the limit point of this subsequence. In particular, the corresponding subsequence of (a i ) i∈ℕ converges to a:=br. We show that a∈⋂A i and rD λ which suffices to prove the claim.

Assume that a∉⋂A i . Then, there is some n 0 such that \(a\notin A_{n_{0}}\). Since \(A_{n_{0}}\) is closed, \(d(a, A_{n_{0}})=:\varepsilon >0\), where d is the Euclidean distance function. Moreover, because each A n with nn 0 is included in \(A_{n_{0}}\), d(a,A n )≥ε. Because (a i ) i∈ℕ converges to a, we can find some Nn 0 such that d(a,a N )<ε. However, a N A N , so

$$d(a,A_N)\leq d(a,a_N)<\varepsilon =d(a,A_{n_0})\leq d(a,A_N), $$

which is a contradiction. The fact that rD λ follows by a similar argument. □

Theorem 20

For arbitrary Q and r, and \(\hat {\varepsilon }\) as from Definition 10, there exists a solution to the deconstruction problem.

Proof

Because of Corollary 6, we need to prove that

$$Q\subseteq Q'_{\hat {\varepsilon }}:=\mathrm {offset}\bigl(\mathrm {inset}\bigl(\mathrm {offset}(Q, \hat {\varepsilon }),r\bigr),r+ \hat {\varepsilon }\bigr). $$

Let (ε i ) i∈ℕ be a monotone decreasing sequence of real numbers that converges to \(\hat {\varepsilon }\). Because \(\varepsilon _{i}>\hat {\varepsilon }\) for each i, Decide return YES for each ε i , which is equivalent to

$$Q\subseteq Q'_{i}:=\mathrm {offset}\bigl(\mathrm {inset}\bigl(\mathrm {offset}(Q,\varepsilon _i),r\bigr),r+\varepsilon _i\bigr). $$

It is therefore sufficient to prove that

$$Q'_{\hat {\varepsilon }}=\bigcap_{i=0}^{\infty}Q'_i. $$

For that, we apply Lemma 19 on the constant sequence (Q) i∈ℕ and on (ε i ) i∈ℕ to obtain

$$\mathrm {offset}(Q, \hat {\varepsilon })=\bigcap_{i=0}^{\infty} \mathrm {offset}(Q,\varepsilon _i). $$

Applying Lemma 18 yields

$$\mathrm {inset}\bigl(\mathrm {offset}(Q, \hat {\varepsilon }),r\bigr)=\bigcap_{i=0}^{\infty}\bigl( \mathrm {inset}\bigl(\mathrm {offset}(Q,\varepsilon _i),r\bigr)\bigr), $$

and applying Lemma 19 for the sequences (inset(offset(Q,ε i ),r)) i∈ℕ and (r+ε i ) i∈ℕ yields

$$\underbrace{\mathrm {offset}\bigl(\mathrm {inset}\bigl(\mathrm {offset}(Q,\hat {\varepsilon }),r\bigr),r+\hat {\varepsilon }\bigr)}_{=Q'_{\hat {\varepsilon }}}=\bigcap_{i=0}^{\infty} \underbrace{\mathrm {offset}\bigl(\mathrm {inset}\bigl(\mathrm {offset}(Q,\varepsilon _i),r\bigr),r+ \varepsilon _i\bigr)}_{=Q'_i}. $$

 □

Since r is no longer fixed, we now consider \(\hat {\varepsilon }\) as a function from ℝ+ to ℝ+ depending on r; abusing notation, we will let \(\hat {\varepsilon }\) by itself denote this function from now on.

Theorem 21

\(\hat {\varepsilon }\) is a monotone increasing function. Moreover, \(\hat {\varepsilon }\) is Lipschitz-continuous with Lipschitz factor 1.

Proof

We prove monotonicity first: Let a<b denote two radii and \(\varepsilon _{a}=\hat {\varepsilon }(a)\), \(\varepsilon _{b}=\hat {\varepsilon }(b)\). We will show that Decide(a,ε b ) returns YES, which proves that ε a ε b .

We compare the intermediate results of Decide(a,ε b ), denoted by S i , to those of Decide(b,ε b ), denoted by B i :

$$\begin{array}{ll@{\qquad }rl} S_1& =\mathrm {offset}(Q, \varepsilon _{b}) & B_1=&\mathrm {offset}(Q, \varepsilon _{b}) = S_1 \\ \noalign {\vspace {5pt}} S_2& =\mathrm {inset}(S_1, a) & B_2=&\mathrm {inset}(B_1, b) = \mathrm {inset}\bigl(\mathrm {inset}(S_1, a) , b-a\bigr)\\ \noalign {\vspace {5pt}} &&=& \mathrm {inset}(S_2, b-a) \\ \noalign {\vspace {5pt}} S_3& =\mathrm {offset}(S_2, a+\varepsilon _{b}) &B_3=&\mathrm {offset}(B_2, b+\varepsilon _{b}) \\ \noalign {\vspace {5pt}} &&= &\mathrm {offset}\bigl(\mathrm {offset}(B_2,b-a), a+\varepsilon _{b}\bigr) . \end{array} $$

Since

$$\mathrm {offset}(B_2,b-a) = \mathrm {offset}\bigl(\mathrm {inset}(S_2, b-a), b-a \bigr) \subseteq S_2 $$

it follows that B 3S 3. Because Decide(b,ε b ) returns YES by definition, we have QB 3, therefore QS 3 and Decide(a,ε b ) also returns YES.

For Lipschitz continuity, let a<b be such that baδ, and again \(\varepsilon _{a}=\hat {\varepsilon }(a)\), \(\varepsilon _{b}=\hat {\varepsilon }(b)\). We show that ε b ε a δ. There exists a polygonal region P that is a solution to the deconstruction problem for Q, a and ε a . In other words,

$$H\bigl(\mathrm {offset}(P,a),Q\bigr)\leq \varepsilon _{a}. $$

Because of the general fact

$$H(A,B)\leq \varepsilon \quad \Rightarrow \quad H\bigl(\mathrm {offset}(A,\delta),B\bigr)\leq \varepsilon +\delta, $$

and since ba+δ we have

$$\begin{array}{l} H\bigl(\mathrm {offset}(P,b),Q\bigr)\leq H\bigl(\mathrm {offset}(P,a+\delta),Q\bigr) \\ \noalign {\vspace {5pt}} \quad = H\bigl( \mathrm {offset}\bigl(\mathrm {offset}(P,a),\delta\bigr),Q\bigr) \leq \varepsilon _{a}+\delta. \end{array} $$

Therefore, P is a solution for the deconstruction problem for Q, b and ε a +δ, so ε b ε a +δ. □

It follows from the monotonicity and Theorem 20 that R is an interval which has 0 as its left endpoint. Thus, computing R reduces to finding the maximal r >0 such that \(\hat {\varepsilon }(r^{*})=\varepsilon \).

Using the exact decision procedure, we can perform a binary search similar to that for approximating \(\hat {\varepsilon }\): First, we compute an interval [0,r] containing r . Since Q is finite, we can take r to be the radius of the smallest enclosing circle of Q plus ε. Then, we start the iterative process, deciding on the left or right subinterval depending on the result of Decide for Q, ε and the midpoint of the interval.

What if we are using ApproxDecide instead? Unlike Algorithm 5, we can no longer guarantee that every execution of the approximation algorithm halves the search interval, because a return value UNDECIDED does not bound the distance of the current radius r to the critical value r . Instead, we propose the following scheme: For an interval I with midpoint r, ApproxDecide is called with some δ, initially set to \(\frac{\varepsilon }{2}\). If it returns UNDECIDED, δ is divided by 2 and ApproxDecide is recalled. Eventually, the algorithm returns YES or NO, and the interval I can be halved.

Let R′ be the preimage of ε under \(\hat {\varepsilon }\). Note that R′ is an interval (which may consist of only one point). The scheme from above is guaranteed to converge to some rR′. However, if R′ contains more than one point, it is not guaranteed to converge to the maximal one (because it gets stuck in an infinite loop as soon as the query value r lies in R′). One way of avoiding this infinite loops is to decrease δ only to some threshold and choosing another query value r from the interval if no decision was made. Nevertheless, we have not found an algorithm with t he formal guarantee of converging to the largest value in R′ eventually.

Searching for both r and ε

We finally consider the question of how we can find a reasonable choice of r, ε and a polygonal region P, such that P is a solution for the deconstruction problem for Q, r, and ε. The meaning of “reasonable” depends on the application context, and possible prior information (for instance, a range of possible offset radii). We offer a basic generic approach and justify our choice with an example.

Generally, we expect from a reasonable pair (r,ε) that ε is small. So, in order to judge whether a good solution exists for radius r, we consider \(\hat {\varepsilon }(r)\). However, \(\hat {\varepsilon }(r)\) being small (or equivalently, \(\frac{1}{\hat {\varepsilon }(r)}\) being large) is not a good criterion, because \(\hat {\varepsilon }\) is monotone increasing according to Theorem 21, so r=0 would always be the best solution.Footnote 3 In order to remove the bias towards small radii, we scale the objective function and consider

$$J:\mathbb {R}^+\rightarrow \mathbb {R}^+, r\mapsto \frac{r}{\hat {\varepsilon }(r)}. $$

Note that J is well-defined on the positive axis and continuous. Moreover, we can approximate the graph of J in any finite interval of r-values by choosing a sample of the interval and approximating \(\hat {\varepsilon }\) at each sample value using Algorithm 5.

We demonstrate by an example that the local maxima of J yield radii that lead to good deconstruction results. Consider the polygonal region defined in Fig. 7a, and its (approximated) J-graph in Fig. 7b. We can identify two local maxima r 1 and r 3; we have plotted the corresponding solutions in Fig. 8. Indeed, we see that for the large radius r 3, we obtain a relatively simple solution whose offset blurs away the spikes of Q. For the smaller local maximum at r 1, we obtain a solution with more details such that the spikes can be approximated almost perfectly with the given radius. In contrast, the shape at the local minimum r 2 combines the disadvantages of the two discussed cases: the solution is similarly complicated as the r 1-solution (it contains flattened versions of all the spikes), but its approximation quality is not significantly better than for the r 3 solution which achieves the same with a much larger radius.

Fig. 7
figure 12

The Flower polygon example: 10 samples per radius unit for r≤5

Fig. 8
figure 13

Flower polygon approximations for the \((r,\widetilde {\varepsilon _{\Delta }}(r))\) values at J-graph extrema. In the upper row, approximations of the solutions are shown in green, and their r-offsets (\(\widetilde {\varepsilon _{\Delta }}(r)\)-close to the input) in dark blue. In the lower row the input polygon is shown in blue. The \(\widetilde {\varepsilon _{\Delta }}\)-width cyan stripe around the r-offset demonstrates the quality of the approximation (Color figure online)

5 Deconstructing Convex Polygons

Assume that the input Q to Algorithm 1 is a convex polygon. We first improve the decision algorithm such that it runs in linear time (Algorithm 6). Then we look for a polygon P with a minimal number of vertices (OPT) such that Q is ε-close to offset(P,r). We give a simple linear-time algorithm that produces a polygon with at most OPT+1 vertices.

Algorithm 6
figure 14

ConvexDecide(Q,r,ε)

Lemma 22

If Q is a convex polygonal region, then Π, as computed by Decide (Algorithm  1), is also a convex polygon, and it can be computed in O(n) time.

Proof

Q is the intersection of the half-planes bounded by lines that support the polygon edges. Observe that Π can be directly constructed from Q by shifting each such line by rε inside the polygon, which shows that Π is convex. For the time complexity, we divide the shifted edges of Q into those bounding Q from above, and those bounding Q from below (we assume w.l.o.g. that no edge is vertical). Consider the former edges; the lines supporting those edges have slopes that are monotonously decreasing when traversing the edges from left to right. We have to compute their lower envelope; for that, we dualize by mapping y=mx+c to (m,−c), which preserves above/below relations, and compute the upper hull of the dualized points. Since we already know the order of the points in their x-coordinate, this can be done in linear time using Graham’s scan [2, 10]. The same holds for the edges bounding Q from below, taking the upper envelope/lower hull. □

Decide first computes Π and checks whether Q⊆offset(Π,r+ε). We replace the latter step for convex polygons: Let q 1,…,q n be the vertices of Q (in counterclockwise order) and define K i =D r+ε (q i ), namely the disk of radius r+ε centered at q i . We check whether all these disks intersect Π.

Lemma 23

ConvexDecide agrees with Decide on convex input polygons Q and runs in O(n) time.

Proof

For correctness, it suffices to prove that offset(Π,r) is ε-close to Q if and only if each K i intersects Π: Indeed, if any K i does not intersect Π, then q i has distance more than r+ε to Π, so Q is not ε-close to the offset. Otherwise, if each disk K i intersects Π, offset(Π,r+ε) contains each vertex of Q. Since it is a convex set (as the Minkowski sum of two convex sets), it also covers each edge of Q. Thus, Q⊆offset(Π,r+ε), which ensures that Q is ε-close to the offset by Proposition 3.

For the complexity, Lemma 22 shows that the computation of Π runs in linear time. We still have to demonstrate that the last step of the algorithm (checking for non-empty intersections) also takes a linear time. Let e 1,…,e m be the edges of Π (with m<n). To check for an intersection of K i with Π, we traverse the edges and check for an intersection, returning NO if no such edge is found. However, if such an edge, say e j was found, we start the search for an intersection of the next disk K i+1 at e j , again traversing the edges in counterclockwise order. Using this strategy, and noting that K 1,…,K n are arranged in counterclockwise order around Π, it can be easily seen that we iterate at most twice through the edges of Π. □

Reducing the Number of Vertices

We assume that offset(Π,r) is ε-close to Q. We prefer a simple-looking approximation of Q, thus we seek a polygon PΠ whose offset is ε-close to Q, but with fewer vertices than Π. Any such P intersects each of the bulged regions of radius r+ε: κ i :=K i Π,i=1,…,n. We call these bulged regions Π’s eyelets. The converse is also true: Any convex polygon PΠ that intersects all eyelets κ 1,…,κ n has an r-offset that is ε-close to Q.

The following observation is a simple consequence of Proposition 3:

Proposition 24

If offset(P,r) is ε-close to Q, and PP′⊆Π, then offset(P′,r) is ε-close to Q.

We call a polygonal region P (vertex-)minimal, if its r-offset is ε-close to Q, and there exists no other such region with fewer vertices. Necessarily, a minimal P must be convex – otherwise, its convex hull CH(P) has fewer vertices and it can be seen by Proposition 24 that offset(CH(P),r) is also ε-close to Q. By the next lemma, we can restrict our search to polygons with vertices on ∂Π.

Lemma 25

There exists a minimal polygonal region PΠ the vertices of which are all on ∂Π.

Proof

We pull each vertex \(p_{i} \not\in \partial \varPi \) in the direction of the ray emanating from p i−1 towards p i until it intersects ∂Π in the point \(p_{i}'\) (dragging p i ’s incident edges along with it); see the enclosed illustration. For \(P' = (p_{1},\ldots,p_{i-1},p_{i}',p_{i+1},\ldots,p_{m})\): PP′⊆Π, offset(P′,r) is ε-close to Q by Proposition 24. □

We call a polygonal region P good, if PΠ, all vertices of P lie on ∂Π, and P intersects each eyelet κ 1,…,κ n . Note that any good P is convex.

Definition 26

For two points u,u′∈∂Π, we denote by [u,u′]⊂∂Π all points that are met when traveling along ∂Π from u to u′ in counterclockwise order. Likewise, we define half-open and open intervals [u,u′), (u,u′], (u,u′).

Let κ i =K i Π be q i ’s eyelet as before. Consider κ i ∂Π. The portion of that intersection set that is visible from q i (considering Π as an obstacle) defines a (ccw-oriented) interval [v i ,w i ]⊂∂Π. We call v i the spot of the eyelet κ i . Finally, for u,u′∈∂Π, we say that the segment \(\overline {{u}{ u'}}\) is good, if for all spots v i ∈(u,u′), \(\overline {{u}{ u'}}\) intersects the corresponding eyelet κ i .

The figure above illustrates these definitions: The segment \(\overline {{p}{p'}}\) is good, whereas \(\overline {{p}{p''}}\) is not good, because v 2∈(p,p″), but the segment does not intersect κ 2.

Theorem 27

Let P be a convex polygonal region with all its vertices on ∂Π. Then, P is good if and only if all its bounding edges are good.

Proof

We first prove that if all the edges of P are good, then P is good. It suffices to argue that it intersects all eyelets κ 1,…,κ n . Let p 1,…,p k be the vertices of P in counterclockwise order. Any spot v i of an eyelet κ i either corresponds to some vertex p of P, or lies inside some interval (p ,p +1). Since \(\overline {{p_{\ell}}{p_{\ell+1}}}\) is good, it intersects κ i .

For the converse, assume that \(\overline {{p_{\ell}}{p_{\ell+1}}}\) is not good, which encloses with the interval (p ,p +1) a polygonal region RΠP. Hence, there is a spot v i R such that \(\overline {{p_{\ell}}{p_{\ell+1}}}\) does not intersect the eyelet κ i . It follows that the entire κ i is inside R (see the illustration above, considering \(\overline {{p}{p''}}\) and κ 2). Thus, Pκ i =∅, and so P cannot be good. □

For u∂Π, we define its horizon h u ∂Π as the maximal point in counterclockwise direction such that that segment \(\overline {{u}{h_{u}}}\) is good. Consider again the figure above: The segment \(\overline {{p}{h_{p}}}\) is tangential to κ 2, so if going any further than h p on ∂Π from p, the segment would miss κ 2 and thus become non-good.

Lemma 28

Let P be a good polygonal region, and u∂Π. Then, P has a vertex p∈(u,h u ].

Proof

Assume to the contrary that P has no such vertex, and let p 1,…,p be its vertices on ∂Π. Let p j be the vertex of P such that u∈(p j ,p j+1). Then, also h u ∈(p j ,p j+1), because otherwise, p j+1∈(u,h u ]. Since P is good, the segment \(\overline {{p_{j}}{p_{j+1}}}\) is good, too. It is not hard to see that, consequently, both \(\overline {{p_{j}}{u}}\) and \(\overline {{u}{p_{j+1}}}\) are good. However, the latter contradicts the maximality of the horizon h u . □

For an arbitrary initial vertex s∂Π, we finally specify a polygonal region P s by iteratively defining its vertices. Set p 1:=s. For any j≥1, if the segment \(\overline {{p_{j}}{s}}\), which would close P s, is good, stop. Otherwise, set \(p_{j+1}:=h_{p_{j}}\). Informally, we always jump to the next horizon until we can reach s again without missing any of the eyelets. By construction, all segments of P s are good, so P s itself is good. The (almost-)optimality of this construction mainly follows from Lemma 28.

Theorem 29

Let P be a vertex-minimal polygonal region for Q, having OPT vertices. Then, for any s∂Π, P s has at most OPT+1 vertices.

Proof

We first prove that P s has the minimal number of vertices among all good polygonal regions that have s as a vertex. Let s:=p 1,…,p m be the vertices of P s. There are m−1 segments of the form \(\overline {{p_{\ell}}{h_{p_{\ell}}}}\). By Lemma 28, any good polygonal region has a vertex inside each of the intervals \((p_{\ell},h_{p_{\ell}}]\). Together with the vertex at s, this yields at least m vertices, thus P s is indeed minimal among these polygonal regions.

Next, consider any minimal polygonal region P . We can assume that all its vertices are on ∂Π by Lemma 25. If s is not a vertex of P , we add it to the vertex set and obtain a polygonal region P′ with at most OPT+1 vertices that has s as a vertex. P s has at most as many vertices as P′, so m≤OPT+1. □

As each visit of an eyelet requires constant time, the construction of a horizon is proportional to the number of visited eyelets, and there are only linearly many eyelets. Thus, we can state:

Theorem 30

For an arbitrary initial vertex s, computing P s requires O(n) time.

Proof

We prove that computing the horizon of a point u takes a number of operations proportional to the number of eyelets that are visited by the segment \(\overline {{u}{h_{u}}}\). Let us consider an arbitrary u∂Π. By rotating appropriately, we can assume, without loss of generality, that u lies on a vertical edge of Π (or, if u is a vertex, that the next edge in counterclockwise order is vertical), and that the edge is traversed top-down. The horizon is determined by the slope of the edge at u. Note that for each eyelet κ 1,…,κ n , there is an interval of slopes \(I_{1}^{(u)},\ldots,I_{n}^{(u)}\) such that the segment from u with slope λ intersects κ i if and only if \(\lambda\in I_{i}^{(u)}\). Furthermore, each single \(I_{i}^{(u)}\) can be computed with a constant number of arithmetic operations. Assuming that the next eyelet to be traveled from the current p i is κ j , we can iteratively compute the intersections I j I j+1I j+2,… until I j ∩⋯∩I j+k is empty. In this case, we choose λ i :=max(I j ∩⋯∩I j+k−1) as the slope for the next segment, which must be \(\overline {{p_{i}}{h_{p_{i}}}}\) since it is good by construction, and any larger slope would produce a non-good segment. Based on this property, it is easy to show that computing P s needs a number of operations which is proportional to n, the number of eyelets. □

6 Open Problems

We have shown how to decide whether a given arbitrary polygonal shape Q is composable as the Minkowski sum of another polygonal region and a disk of radius r, up to some tolerance ε. Many related questions remain open. (i) Deconstruction of Minkowski sums seems more difficult when both summands are more complicated than a disk; many practical scenarios may raise this general deconstruction problem. (ii) It would be interesting to analyze the deconstruction not only under the Hausdorff distance but for other similarity measures, such as the Frêchet or the symmetric distance. (iii) Can one remove the extra vertex when seeking an optimal (vertex-minimal) polygonal summand P in the convex case. (iv) Finding an optimal or near-optimal polygonal summand in the non-convex case seems challenging. (v) As in polygonal simplification, we could also search for the polygonal region with a given number of vertices whose r-offset minimizes the (Hausdorff) distance to the given shape. (vi) The offset-deconstruction problem can be reformulated in higher dimensions. We consider especially the three-dimensional case to be of practical relevance.