Guarding Fat Polygons and Triangulating Guarded Polygons

G. Aloupis ∗ P. Bose † V. Dujmovic ‡ C. Gray § S. Langerman ¶ B. Speckmann §

Abstract In this paper we study three related problems: (i) Given a fat polygon P , we show how to find a set G of points in P such that every point on the boundary of P sees at least one point of G. The set G is said to guard the boundary of P and its cardinality depends on the shape parameters of P . Fat polygons are often used to model more realistic inputs. (ii) Given k points that guard the boundary of P , we show how to compute O(k2) points that guard the interior of P . (iii) Given k points that guard P , we provide two simple O(kn) time algorithms to triangulate P : one that triangulates the polygon when the guards are given as input and the other slightly more complicated algorithm that triangulates the polygon when the guards are not given.

1 Introduction

Many algorithms and data structures developed in Computational often display their worst-case performance on intricate configurations that seem artificial. Indeed, in practical situ- ations, these algorithms tend to perform much better than predicted by the theoretical bounds. An attempt to understand this disparity has led to the study of geometric problems with so-called realistic input models [5]. Here one places certain restrictions on the shape and/or distribution of the input objects, so that hypothetical worst-case examples are excluded. One of the most widely studied realistic input models assumes that the input objects are fat, that is, they are not arbitrar- ily long and skinny. There are several different ways to characterize fat objects—see Section 3 for formal definitions. Combinatorial properties of sets or unions of fat objects are well-studied in the literature, while properties of a single fat object has only been addressed recently. The first problem we study in this paper is how to find a guard set for the boundary of a polygon whose cardinality depends on the fatness parameter of the polygon. Valtr showed [21] that ε-good polygons (a class of fat polygons) can be guarded with a constant number of guards where the constant depends on the fatness parameter. We show in Section 3 that the boundary of a different class of fat polygons, namely (α,β)-covered polygons, can also be guarded by a constant—again depending on the fatness— number of guards. Guarding problems have a rich history in Computational Geometry (see [9], [20], [15] for books and surveys on this topic). We continue our investigation by showing in Section 4 that a polygon whose boundary can be guarded with k guards can be completely guarded with O(k2) guards. We say that a polygon is completely guarded provided that every point in the polygon is visible to at least one guard.

∗Carleton University & Universit´eLibre de Bruxelles, [email protected]. †Carleton University, [email protected]. ‡McGill University, [email protected]. §TU Eindhoven, {cgray,speckman}@win.tue.nl. C.G. is supported by the Netherlands’ Organisation for Scientific Research (NWO) under project no. 639.023.301. ¶Chercheur Qualifi´edu FNRS, Universit´eLibre de Bruxelles, Belgique, [email protected].

1 We complete our investigation in Section 5 by showing a relationship between the number of guards required to guard the boundary of a polygon and the time required to triangulate that polygon. Such relationships between shape complexity and time to triangulate polygons have been investigated before. For example, it has been shown that monotone polygons [19], star-shaped polygons [16], edge-visible polygons [18] and palm-shaped polygons [8] can all be triangulated in linear time by fairly simple algorithms. Other measures of shape complexity studied include the number of reflex vertices [11] or the sinuosity [4] of the polygon. In 1991, Chazelle [3] presented a linear time algorithm to triangulate a simple polygon. However, the algorithm is quite complex. In this paper, we give simple algorithms to triangulate a polygon for which a set of guards collectively sees its boundary. Given a simple n vertex polygon P and k guards that guard the boundary of P , we present a simple O(kn) time algorithm to triangulate P . By simple, we mean that the algorithm uses the following: computing the convex hull of a polygonal chain [14], computing the visibility polygon from a point [7], and triangulating an edge-visible polygon [18]. These problems have linear-time algorithms that are generally considered to be simple. If we are simply told that the boundary of P can be guarded with k guards but are not given k guards as input, then we provide another O(kn) time triangulation algorithm that is slightly more complicated. The additional operation we need is a linear-time algorithm to compute the visibility polygon from an edge. There exist classes of polygons that can be guarded by a constant number of guards, such as ε-good polygons and (α,β)-covered polygons. Therefore, our algorithms for such classes use linear running time.

2 Tools and definitions

Throughout this paper let P be a simple polygon with n vertices. We denote the interior of P with int(P ), the boundary of P with ∂P , and the diameter of P by diam(P ). The boundary is considered part of the polygon, that is, P = int(P ) ∪ ∂P . We say that a point p is in P if p ∈ int(P ) ∪ ∂P . The segment or edge between two points p and q is denoted by pq. The same notation implies the direction from p to q if necessary. Two points p and q in P see each other if pq ∩ P = pq. If p and q see each other, then we also say that p is visible from q and vice versa. A star-shaped polygon contains a set of points—the kernel—each of which can see the entire polygon. If there ex- ists an edge pq ⊂ ∂P such that each point in P sees some point on pq, then P is weakly edge-visible. The visibility polygon of a point p ∈ P with respect to P , denoted by v(p, P ) is the set w P Pw of points in P that are visible from p. Visibility polygons are p star-shaped and have complexity O(n). Let Q be a subpolygon of P , where all vertices of Q are on ∂P . If all vertices of Q coincide with vertices of P , then we call Q a pure subpolygon. If ∂P intersects an edge w of ∂Q only at Figure 1: The visibility polygon w’s endpoints, then w is called a window of Q. Any window v(p, P ) is shaded. Pw is the pocket w separates P into two subpolygons. The one not containing of w with respect to v(p, P ). Q is the pocket of w with respect to Q (see Fig. 1).

Lemma 1 (El Gindy and Avis [7]) v(p, P ) can be computed in O(n) time.

2 This algorithm, while not trivial, is fairly simple. It involves a single scan of the polygon and a stack. See O’Rourke’s book [15] for a good summary. The geodesic between two points in P is the shortest polygonal path connecting them that is contained in P . The vertices of a geodesic belong to ∂P .

Lemma 2 Let x be a vertex of polygon P and let y be a point on edge vw ∈ P . If y sees x, then the geodesic between x and v: (a) is convex and entirely visible from y, and (b) can be computed in O(n) time.

Proof. Property (a) holds trivially if x sees v. Consider the case v w where x does not see v. Then, the (x,y,v), denoted by T , y must contain at least one vertex of P in its interior. Let I be all the vertices of P inside T and let CH(I) be the convex hull of I. The path S = CH(I) \ xv is the geodesic from x to v. Any other path from x to v inside T can be shortened. Thus, Property (a) holds. x To prove property (b), note that since the geodesic we seek is z entirely visible from y by part (a) it is fully contained in v(y, P ). We compute v(y, P ) in linear time. Let z be the first intersection of ∂P and the ray emanating from x in the direction yx. Consider Figure 2: The geodesic from the polygonal chain from x to v along ∂v(y, P ) that avoids y. By x to v. construction of v(y, P ), the shortest path from x to v is part of the convex hull of this path. By Melkman’s algorithm [14], the convex hull of a simple polygonal chain can be computed in linear time. 

3 Guarding fat polygons

As mentioned in the introduction there are several ways to characterize fat polygons. Valtr [21] studied ε-good polygons. A polygon P is ε-good if every point p ∈ P can see at least an ε-fraction of the total area of P . Valtr showed that an ε-good polygon can be guarded by (1 + o(1)) · 23 · (1/ε) log(1/ε) guards. Kirkpatrick [12] considered polygons where every point on the boundary sees a fraction ε of the boundary. He showed how to guard the boundary of such polygons with 64(1/ε) log log(1/ε) guards. In this section we show how to guard the boundary of (α,β)-covered polygons [6]. A polygon P is (α,β)-covered if for each point p on ∂P there exists a triangle T (p), called a good triangle of p, such that: (i) p is a vertex of T (p), (ii) T (p) is completely contained in P , (iii) each angle of T is at least α, and (iv) the length of each edge of T (p) is at least β · diam(P ). It is easy to show that the classes of (α,β)-covered polygons and ε-good polygons are not equal. We prove with a simple grid-based argument that we can guard the boundary of an (α,β)- covered polygon with ⌈32π/(αβ2)⌉ guards. Let P be an (α,β)-covered polygon with diameter 1 and let p be a point on ∂P . We construct a C of radius β/2 around p and place ⌈4π/α⌉ guards evenly spaced on the boundary of C. Call this set of guards Gp. By construction, the triangle consisting of p and any two consecutive guards of Gp has an angle at p of α/2. Hence any good triangle which is placed at p must contain at least one guard from Gp. Now consider the circle C′ centered at p with radius β/4. We show in the lemma below (proved in the Appendix) that any good triangle placed at a point inside the circle C′ must contain at least one guard from Gp.

3 Lemma 3 Let T be a good triangle with a vertex inside the circle C′. Then T contains at least one guard from Gp.

This lemma almost immediately provides a guarding set for ∂P .

Theorem 4 The boundary of any (α,β)-covered polygon can be guarded with ⌈32π/(αβ2)⌉ guards.

Proof. Assume without loss of generality that the diameter of P is 1. Thus, P has a bounding box B with area 1. We tile the bounding box with copies of the guarding set Gp used in Lemma 3. ′ 2 Since the circle C in the guarding set Gp contains a with area β /8 and each copy of Gp contains ⌈4π/α⌉ guards, we need at most ⌈32π/(αβ2)⌉ guards to guard P . 

4 Guarding the Interior of Boundary-Guarded Polygons

In this section we are given a polygon P and a set of k guards {g1,...,gk} that guard ∂P . We show how to also guard the interior of P with an additional Θ(k2) guards. To do so we bound the number of “dark areas” inside P , that is, the areas that are not guarded by the k guards. Formally, k v a dark area is a maximal connected region in P \ Si=1 (gi, P ). The boundary of any dark area is consists of subsegments of windows of the visibility polygons of the guards. Furthermore, every dark area is convex since it is the intersection of half-planes. Finally, note that every vertex on the boundary of a dark area is the intersection of two windows of visibility polygons. It was shown in [1] and [2] that the number of dark areas is Θ(k2). In this section, we tighten the constant. We define a labeling for each vertex of a dark (a)gi (b) gi area so that we can bound the number of vertices. v A vertex v of a dark area is determined by the in- v tersection of two windows from different guards; we will call these guards gi and gj. Assume that i < j. We orient the edges of the dark area adjacent to v and assign v a label that is taken from the set Figure 3: (a) giv has the orientation in. {in, out} × {in, out}, depending on the orientation (b) giv has the orientation out. of these edges. The orientation of the edge that is a subsegment of the window of the visibility polygon of gi is in if the edge is contained in giv. It is out otherwise. The orientation of the edge that is a subsegment of the window of the visibility polygon of gj is determined in the same manner.

Lemma 5 Every pair of guards (gi, gj) can produce at most one vertex with the label (in,in), one vertex with the label (in, out), and one vertex with the label (out, in). However, every pair of guards may produce multiple vertices with the label (out, out).

Proof. Let v and w be distinct vertices of dark areas. It is sufficient to show that v and w can not have the same label unless that label is (out, out). There are three cases (up to symmetry). In the first case, the segments giv, gjv, giw, and gjw form a simple polygon. At least one of v or w must be on the convex hull of the four points; assume without loss of generality that it is v. Since no part of ∂P can intersect the polygon made by the segments (the segments are lines of visibility), v must have the label (out, out).

4 In the second case, w is a point on the segment giv. In this case, the entire segment vw must be visible from gj, and therefore the dark area edge that is a subset of the window of gi must be oriented in at w and out at v. Therefore, v and w have different labels. Finally, consider the case where the segment giw intersects the segment gjv at the point p. Note that the segments pv and pw are completely visible to gi and gj respectively. This implies that gj can not give v the label in and that gi can not give w the label in. Therefore, the label of v can not be the same as that of w unless both of the labels are (out, out). 

Lemma 6 In every dark area with a vertex labeled (out, out), there is a vertex with label (in,in).

Proof. Let H be a dark area. Let e be an edge of H that is a subsegment of the window from guard gi. Direct e from the vertex closer to gi to the vertex farther from gi. It should be clear that the part of the label associated with gi for these vertices is out and in respectively. Let every edge of H be directed this way. If there is a vertex with the label (out, out), then the vertices and edges form a directed acyclic graph. In every directed acyclic graph, there is a source (a vertex with a label (out, out)) and a sink (a vertex with a label (in,in)). 

We are finally ready to bound the number of dark areas in P .

Lemma 7 Let k be the number of guards that guard the boundary of a simple polygon P . There are at most 3(k2 − k)/4 dark areas in P .

Proof. Since there are (k2−k)/2 pairs of guards, we can easily see that there are at most 3(k2−k)/2 vertices, excluding vertices with the label (out, out). Every dark area must contain at least three vertices, at least two of which must not have the label (out, out). Therefore, there are at most 3(k2 − k)/4 dark areas. 

Since every dark area is convex, this leads to a bound on the number of guards needed to cover the interior of a polygon whose boundary requires k guards.

Theorem 8 Let k be the number of guards that guard the boundary of a simple polygon P . Then at most 3(k2 − k)/4 additional guards are needed to guard the interior of P . It is simple to verify that the bound on the number of dark areas in Lemma 7 is tight up to a constant. Note, however, that this does not imply that the bound in Theorem 8 is tight. In fact, we conjecture that the interior of every simple polygon whose boundary can be guarded with k guards can be guarded with O(k) guards.

gi gi gi v w w v v p

gj gj gj w

Figure 4: The three cases for the labeling of two vertices of dark areas. Gray regions must be visible to at least one guard.

5 5 Triangulating guarded polygons

We present two algorithms that triangulate a polygon that requires k guards. While the first algorithm is slightly simpler, it needs the set of guards as input. The second algorithm does not.

5.1 Triangulating with a given set of guards

Let G = {g1,...,gk} be a given set of k guards in P that jointly see ∂P . In this section we describe a x1 x2 x3 simple algorithm that triangulates P in O(kn) time. w g A vertical decomposition of P —also known as a v1 trapezoidal decomposition of P , leading to the nota- Pw v3 tion T (P )—is obtained by adding two vertical exten- sions, one travelling up and one travelling down, to v2 each vertex of P . A vertical extension of v, denoted vert(v), is the maximal vertical line segment which is contained in P and intersects v. Figure 5: The vertical projection onto w. Let g be a guard and w be a window of v(g, P ). Pw denotes the pocket of w with respect to v(g, P ). The vertical projection onto w is the intersection of w with the vertical extensions of the vertices of Pw (see Fig. 5). Our algorithm actually finds the vertical decomposition T (P ) of P in O(kn) time. In particular, we show how to compute all vertical extensions of T (P ) that are contained in or cross the visibility polygon of a guard in O(n) time. Since each vertex of P is seen by at least one guard, every vertical extension is computed by our algorithm. It is well known that finding a triangulation of a polygon P is simple given the vertical decomposition of P [4]. The most complicated procedure used in our algorithm has the difficulty level of computing the visibility polygon of a point, or of computing the convex hull of a polygonal chain. Algorithm TriangulateWithGuards (see Figure 6 for an overview):

For each guard g ∈ G: (1) Find the visibility polygon v(g, P ). (2) For each window w in v(g, P ), compute the vertical projection onto w and add the resulting Steiner points to w. After all windows of v(g, P ) have been processed, we have a simple polygon v2(g, P ) that includes all Steiner points on the windows.

(3) Compute the vertical decomposition of v2(g, P ). Add the endpoints of the vertical extensions of all vertices except the Steiner points of v(g, P ) to ∂(v2(g, P )), creating v3(g, P ). We have now computed the restriction of T (P ) to v(g, P ). That is, every vertical extension that is part of T (v3(g, P )) is contained in a vertical extension of T (P ) and every vertical extension of T (P ) that crosses v(g, P ) is represented in T (v3(g, P )).

(4) For each vertex v of v3(g, P ), determine the endpoints of vert(v) on ∂P .

By Lemma 1, step 1 takes O(n) time. We now analyze the remaining steps of the algorithm. We have moved the proofs to the Appendix in the interest of saving space.

6 (1) (2) (3) (4)

Figure 6: Sample execution of the algorithm.

Step 2: Computing a vertical projection onto a window. Without loss of generality, we assume that w is not vertical and that int(v(g, P )) is above w (see Fig. 7). Let v be a vertex of Pw such that vert(v) intersects w. Furthermore, let z be a point at infinite distance vertically above some point on w. Observe that if z can see all of w, then z can see v. This implies that if we remove all parts of Pw that are inside the “vertical slab” above w, vertices whose vertical extensions intersect w are precisely those that form the visibility polygon of z. The technique of computing a visibility polygon of a point at infinity was first used by Toussaint and El Gindy [17]. Instead of removing only the parts of Pw that enter the vertical slab above w, we will re- z move all of the parts of Pw that go above the line ℓ that contains w. We create two rays extending ℓ x1 x2 x3 w named r1, which extends w to the left, and r2 w w g which extends w to the right. We trace Pw from v1 Pw Pw the left endpoint of w, while remaining below ℓ. v3 If r1 is crossed, ignore vertices of Pw until we v2 cross back down through r1. Connect the two crossing points by an edge and continue tracing Pw. We maintain a counter to avoid problems Figure 7: Computing a vertical projection. with wrapping around w and emerging from ℓ through r1 again. This counter and the one associated with r2 will never operate synchronously. Once Pw has been traced back to w, we remove potential intersections between newly constructed line segments along ℓ by raising each of these segments vertically by a small amount proportional to their length. Since the segments are nested, we obtain a simple polygon that does not cross the vertical slab above w. Finally, we remove w and attach its endpoints to z, thus obtaining a polygon P . The vertices of v(z, P ) are precisely those vertices of P whose vertical extensions intersect cw cw w w, and appear as output in identical sorted order.

Lemma 9 The vertical projection onto w can be computed in O(|Pw|) time.

Step 3: Computing a vertical decomposition of a star-shaped polygon. We can compute a point in the kernel of S in O(n) time [13]. In our particular application a given guard g is in the kernel of S = v(g, P ). We assume that the vertices of S are given in counterclockwise order. To simplify the algorithm, we describe only the computation of the upward vertical decomposition (that is, for each vertex v, we find the upper endpoint of vert(v)) of the part of S that is to the left

7 of the vertical line through g. See Figure 8. We say that a vertex v supports a vertical line ℓ if the two edges adjacent to v are both on the same side of ℓ. The algorithm for finding the upward vertical decomposi- tion of S consists of two alternating parts: a leftward walk which moves a pointer to a vertex which supports a vertical pu line outside S and a rightward walk which adds vertical decom- position edges. The algorithm begins with the leftward walk g which starts from the point directly above g. It ends when vs the rightward walk passes under g. The leftward walk is quite simple—moving a pointer forward in S until a vertex vs which pd supports a vertical line is encountered—so we concentrate on describing the rightward walk. Figure 8: Upward vertical decom- The rightward walk begins with two pointers, pu and pd, position of the part of S to the left which initially point to vs. The pointers are moved simulta- of the guard. neously so that they always have the same x-coordinate, with pd being moved forward in S while pu is moved backward in S (imagine sweeping rightward with a vertical line from vs). If pd encounters a vertex, then a vertical decomposition edge is created between pd and pu. If pu encounters a vertex v to which a vertical decomposition edge vert(v) is already attached (which implies that v supports a vertical line), then pu moves to the top of vert(v) and continues from there. When pd encounters a vertex v that supports a vertical line, the rightward walk ends and the leftward walk begins anew at v.

Lemma 10 The vertical decomposition of a star-shaped polygon P is correctly computed by the above algorithm in O(n) time.

Step 4: Computing the endpoints of vertical extensions. The final step of the algorithm is to find and connect the endpoints of the vertical extensions of every vertex of v3(g, P ). Let v be an arbitrary vertex of v3(g, P ). If both endpoints of vert(v) are on the boundary of v(g, P ), we have already found and connected them in the previous step. Thus, let us assume that at least one of the endpoints of vert(v) is not on the boundary of v(g, P ). That is, vert(v) intersects at least one window of v(g, P ). Since we have already connected the endpoints of vert(v) ∩ v(g, P ) in the previous step, it is sufficient to find the endpoints of vert(v) that are outside of v(g, P ). Thus, it suffices to examine vertices that are Steiner points on windows. Let v1,...,vj be vertices on window w, in sorted order. Again, we assume that int(v(g, P )) is above w. To find the endpoint of vert(v) that is below w for all v ∈ {v1,...,vj}, we use the visibility polygon v(z, P ) computed in step 2 of the algorithm. Note that the vertices of v(z, P ) as well cw cw {v1,...,vj} are sorted by x-coordinate. Thus we find the endpoints of {vert(v)|v ∈ {v1,...,vj}} by simultaneously scanning in v(z, P ) and {v1,...,v } (as though performing a merge operation cw j in merge-sort). Since Pw |Pw|≤ n and the number of Steiner points added to windows is at most n, we find the endpoints of the vertical extensions of all Steiner points on windows in O(n) time. Since each guard is processed in linear time, we obtain the following.

Theorem 11 The algorithm TriangulateWithGuards computes the vertical decomposition of an n-vertex polygon P whose boundary is guarded by k given guards in O(kn) time.

8 5.2 Triangulating without guards In many situations where triangulation is desired, it may be unrealistic to expect a set of guards as part of the input. In this section we describe a triangulation algorithm that does not require an input set of guards that runs in O(tn) time, where t is no greater than three times the number of guards that suffice to guard ∂P . The most complicated procedure used in our algorithm is computing the visibility polygon from an edge in linear time [10]. The edge-visibility polygon, ev(e, P ) of an edge e with respect to polygon P consists of all points in P that are visible from at least one point on e. An extended edge-visibility polygon of e with respect to P , denoted by eev(e, P ), is the smallest pure subpolygon of P that contains ev(e, P ). These concepts are illustrated in Figure 9. q (a) (b) y wi

P (wi) x

p

Figure 9: (a) The shaded area is the edge-visible polygon of the dotted edge; (b) associated extended edge visible polygon.

Lemma 12 eev(e, P ) can be computed and triangulated in O(n) time. Proof. We begin by computing ev(e, P ) in O(n) time by the result of Heffernan and Mitchell [10]. This yields a set of windows W and their associated pockets. For each window wi ∈ W that is not a diagonal of P , we do the following. Let x be the endpoint of wi closer to e, and let y be the endpoint farther from e. Then x is a vertex of P , and y is an interior point on some edge pq of P . Without loss of generality let p be the endpoint of pq that is inside the pocket of wi, as illustrated in Figure 9 (b). Since x sees y, we can use Lemma 2(b) to compute the geodesic from x to p. Let P (wi) denote the polygon enclosed by the geodesic from x to p, py and wi. It is simple to verify that the extended edge-visibility polygon eev ev is (e, P )= (e, P ) ∪ Swi∈W P (wi). By Lemma 2 (b), each pocket P (wi) can be computed in time linear in the size of the pocket eev of wi. Since pockets are disjoint and can be processed in order, Swi∈W P (wi), and thus (e, P ), can be computed in O(n) time. We now proceed to triangulate eev(g, P ). Consider P (wi). Let ▽ be the triangle determined by the points x, y and q. If e sees q, then q sees each vertex in P (wi) ∪ ▽ by Lemma 2 (a). Therefore, P (wi) ∪ ▽ is a weakly edge-visible pure subpolygon of P and can be triangulated easily in O(|P (wi)|) time. This is because weakly edge-visible polygons can be triangulated in linear time using the extremely simple Sklansky scan [18].

9 If e does not see q then q ∈ P (wj). Let Q be the quadrilateral determined by the endpoints of wi and wj. The polygon Y = P (wi) ∪ P (wj) ∪ Q is a pure subpolygon of P and each of its vertices is visible from p or q, which means that Y is weakly edge-visible. This implies that Y can be triangulated using a simple method as before. It is straightforward to verify that all of the pure subpolygons of eev(e, P ) triangulated thus far are pairwise non-overlapping. If T is the union of these subpolygons then the closure of eev(e, P )\T is a weakly edge-visible pure subpolygon of eev(e, P ) and thus can also be triangulated in linear time. This results in a triangulation of eev(e, P ), as required. 

When eev(e, Pi) is triangulated, diagonals of P that are on the boundary of eev(e, Pi) become windows of new pockets. Each such window serves as the edge from which a new visibility polygon will be computed and triangulated, within its respective pocket. In this recursive manner we break pockets into smaller components until all of P is triangulated. The procedure, although straightforward, is outlined below in more detail. This is followed by the analysis of the time complexity, where we show that the recursion depth is of the order of the number of guards that suffice to guard ∂P . We will maintain S as a queue of non-overlapping polygons (pockets) such that each Pi ∈ S has one edge wi labelled as a window. Thus elements of S are pairs (Pi,wi). We start with S := (P,w), where w is an arbitrary boundary edge of P . We process the elements of S in the order in which they were inserted. The main loop of our algorithm is as follows: TriangulateWithoutGuards(P ) Input: A polygon P . Output: A triangulated version of P . (1) S := (P,w) where w is an arbitrary edge of P (2) while S= 6 ∅ (3) foreach (Pi,wi) ∈ S (4) Compute and triangulate eev(wi, Pi). (5) Add the edges of the triangulation to P . (6) foreach boundary edge wj of eev(wi, Pi) that is a diagonal of P (7) Identify Qj as the untriangulated portion of P whose boundary is enclosed by wj and ∂P . (8) S := S ∪ {Sj(Qj,wj)} (9) return P

Theorem 13 The algorithm TriangulateWithoutGuards triangulates any given n-vertex polygon P , for which k guards suffice to guard ∂P , in O(kn) time.

Proof. By Lemma 12, each extended edge-visibility polygon computed by the algorithm is a pure subpolygon of a polygon in S and is correctly triangulated. The pockets that are created do not overlap, and thus S remains a set of non-overlapping polygons in subsequent iterations of the while-loop. Triangulated components in one iteration of the while-loop are connected in an ancestral manner to components of the previous iteration. Thus the overall connectivity of the triangulation is ensured. We now discuss the running time. By Lemma 12, the first step of the main for-loop runs in O(|Pi|)-time. The remainder of the loop takes the same time in a straightforward manner, as the main requirement is a scan of the boundary of eev(wi, Pi). Thus one iteration of the while-loop runs in O(|S|) time. As the polygons

10 in S are disjoint, this amounts to O(n) time. Next we show that the number of iterations, t, of the while-loop is no greater than 3k. Let Sj be the set of extended edge-visibility polygons computed in the jth iteration of the while loop. To prove that t ≤ 3k, it is enough to show that for each 1

As is apparent in the proof of Theorem 13, our algorithm runs in O(tn) time, where t is the number of iterations of the while-loop. Note that t may be much smaller than k. For example, in the well known Chv´atal comb polygon (see [15]), Ω(n) guards are required but Triangulate- WithoutGuards only uses two iterations.

Acknowledgments

This research was initiated at the Carleton-Eindhoven Workshop on Computational Geometry, July 18–22, 2005, organized by Mark de Berg and Prosenjit Bose. The authors are grateful to Mark de Berg for suggesting the problems studied in this paper and Boris Aronov for many discussions.

References

[1] B. Aronov, L. Guibas, and M. Teichman. Visibility queries and maintenance in simple polygons. Discrete and Computational Geometry, 27(4):461–483, 2002. [2] P. Bose, A. Lubiw, and J.I. Munro. Efficient visibility queries in simple polygons. Computational Geometry: Theory and Applications, 23(3):313–335, 2002. [3] Bernard Chazelle. Triangulating a simple polygon in linear time. Discrete and Computational Geometry, 6(5):485–524, 1991. [4] Bernard Chazelle and Janet Incerpi. Triangulation and shape-complexity. ACM Trans. Graph., 3(2):135–152, 1984. [5] Mark de Berg, A. Frank van der Stappen, Jules Vleugels, and Matthew J. Katz. Realistic input models for geometric algorithms. Algorithmica, 34(1):81–97, 2002. [6] Alon Efrat. The complexity of the union of (α, β)-covered objects. SIAM Journal on Computing, 34(4):775–787, 2005.

11 [7] Hossam A. El Gindy and David Avis. A linear algorithm for computing the visibility polygon from a point. Journal of Algorithms, 2:186–197, 1981. [8] H. ElGindy and G. Toussaint. On triangulating palm polygons in linear time. In N. Magnenat-Thalmann and D. Thalmann, editors, New Trends in Computer Graphics (Proceedings of CG International ’88), pages 308–317. Springer-Verlag, 1988. [9] S. Ghosh. Visibility Algorithms in the Plane. Cambridge University Press, 2007. [10] Paul J. Heffernan and Joseph S. B. Mitchell. Structured visibility profiles with applications to problems in simple polygons (extended abstract). In Symposium on Computational Geometry, pages 53–62, 1990. [11] S. Hertel and K. Mehlhorn. Fast triangulation of simple polygons. In Proc. 4th Conf. Foundations of Computation Theory, pages 207–218. Springer-Verlag, LNCS 158, 1983. [12] David Kirkpatrick. Guarding galleries with no nooks. In Proceedings of the 12th Canadian Conference on Computational Geometry (CCCG’00), pages 43–46, 2000. [13] D. T. Lee and F. P. Preparata. An optimal algorithm for finding the kernel of a polygon. J. ACM, 26(3):415–421, 1979. [14] Avraham A. Melkman. On-line construction of the convex hull of a simple polyline. Information Processing Letters, 25(1):11–12, April 1987. [15] J. O’Rourke. Art Gallery Theorems and Algorithms. Oxford University Press, New York, NY, 1987. [16] A.A. Schoone and J. van Leeuwen. Triangulating a starshaped polygon. Technical Report RUU-CS-80- 03, Institute of Information and Computing Sciences, Utrecht University, 1980. [17] G. T. Toussaint and H. El Gindy. A counterexample to an algorithm for computing monotone hulls of simple polygons. Pattern Recognition Letters, 1:219–222, 1983. [18] Godfried Toussaint and David Avis. On a convex hull algorithm for polygons and its application to triangulation problems. Pattern Recognition, 15(1):23–29, 1982. [19] Godfried T. Toussaint. A new linear algorithm for triangulating monotone polygons. Pattern Recognition Letters, 2:155–158, 1984. [20] Jorge Urrutia. Art gallery and illumination problems. In J.-R. Sack and J. Urrutia, editors, Handbook of Computational Geometry. Elsevier, 2000. [21] Pavel Valtr. Guarding galleries where no point sees a small area. Israel Journal of Mathematics, 104:1–16, 1998.

12 Appendix

Lemma 3 Let T be a good triangle with a vertex inside the circle C′. Then T contains at least one guard from Gp. Proof. Let v be the vertex of T that lies inside C′. Since T is a good triangle, all of its edges have length at least β. Also, all of its angles are at least α. In particular, the angle that is at v is at least α. Further note that since all angles in T are at least α, α is at most π/3. Assume that T contains no guards from Gp. It is easy to see that we lose no generality by assuming that v is on the boundary of C′. By moving T towards the boundary g1 of C′ in the direction of the bisector of v, no guards from δ Gp can enter T . We also lose no generality by assuming that the bisector of v is orthogonal to C′ at v and that it p v passes through the center point of the segment connecting g2 two consecutive guards from Gp. We now show that even in β/4 ′ this worst case, pictured in Figure 10, there must be a guard C C from Gp in T . 4 We show that there is a segment connecting two consec- β/ utive guards from Gp that is completely contained in T . Let g1 and g2 be the guards which have the property that the bi- sector of v passes through the segment g1g2. We denote the Figure 10: The guarding set Gp. length of the segment g1g2 by 2δ. Hence tan(α/4) = 2δ/β. Let the angle g1vg2 be denoted by 2θ. We have tan θ = 4δ/β. Therefore, tan θ = 2 tan(α/4). Since 0 < α/4 ≤ π/12 < π/4, we have 0 < 2 tan(α/4) < tan(α/2) (by double-angle identities for tan). This implies that tan θ < tan(α/2) and hence 2θ < α. It follows that T must contain the segment ′ g1g2. Since we chose the worst possible T , any good triangle inside C must contain at least one guard from Gp. 

Lemma 9 The vertical projection onto w can be computed in O(|Pw|) time.

Proof. The algorithm described in the text consists of a scan of Pw and a visibility polygon calculation, which has complexity O(|Pw|). Therefore, it remains to show that a point x is added to w if and only if there is a corresponding vertex vx in Pw whose vertical extension intersects w at x. Suppose there is a vertex vx whose vertical extension intersects w. Then vx is visible from z, so v is included in v(z, P ) and thus x is added to w. Contrariwise, suppose there is a point x x cw added to w. This occurs if there is a vertex vx which is visible to z through w. Since this is the case, the vertical extension of vx intersects w. 

Lemma 10 The vertical decomposition of a star-shaped polygon P is correctly computed in O(n) time.

Proof. The algorithm outlined in the text maintains the following extension invariant: the correct upward vertical extension has been found for every vertex to which pd has pointed. Initially, the invariant is trivially true. By construction, pd visits all vertices of S that are the endpoints of the edges of the upwards vertical decomposition of S in counterclockwise order. Hence the algorithm constructs a vertical

13 extension for each of these vertices. It remains to show that the upper endpoint of the vertical extension is correctly identified. Denote the current position of pd by vd. Again by construction, pu lies vertically above vd at position vu. We need to show that vdvu is not intersected by an edge of S. Consider the triangle gvdvu. Since g sees all of S, gvd and gvu can not be intersected by an edge of S. This implies that any edge e that intersects gvdvu must intersect vdvu. Furthermore, e must be an edge in the chain CL, which is the chain from vu to vd in counterclockwise order. To show that no edge from CL intersects vuvd, we establish the order invariant: CL is always to the left of pupd. The invariant is trivially true whenever pu and pd point to vs, that is, whenever we begin a rightward walk. Suppose that the invariant has been true until step k and we will show that it is ′ still true at step k + 1. Let CL be the chain from pu to pd at step k and CL be the chain from pu to pd at step k + 1. There are three cases in step k + 1: either pd is pointing to a vertex of S, pu is pointing to a vertex of S without a vertical extension, or pu is pointing to a vertex v of S with a ′ vertical extension. In the first two cases, the invariant is maintained since CL only differs from CL by two segments that by definition both lie to the left of pupd.

pu pu pu

vs vs vs pd pd pd

Figure 11: The three cases in establishing correctness of the order invariant.

Since the vertices in CL come before vd, the correct vertical extension of each vertex in CL has been computed by the assumption of the extension invariant. This implies that the order invariant is also maintained in the case where pu is pointing to a vertex v of S with a vertical extension and ′ is moved to the top of vert(v). This is because CL differs from CL by a segment which is to the left of pd and a chain which must be to the left of pupd since vert(v) is a valid vertical extension. Both pd and pu visit every vertex of S at most once, hence the running time is O(n). 

14