Linear-Time Triangulation of a Simple Polygon Made Easier Via Randomization
Total Page:16
File Type:pdf, Size:1020Kb
Linear-Time Triangulation of a Simple Polygon Made Easier Via Randomization Nancy M. Amato * Michael T. Goodrich t Edgar A. Ramos ~ Abstract We describe a randomized algorithm for computing the trapezoidal decomposition of a simple polygon. Its expected running time is linear in the size of the polygon. By a well-known and simple linear time re- duction, this implies a linear time algorithm for trian- Figure 1: A triangulated simple polygon gulating a simple polygon. Our algorithm is consid- erably simpler than Chazelle's (1991) celebrated op- timal deterministic algorithm and, hence, positively answers his question of whether a simpler random- eral other problems in computational geometry deal- ized algorithm for the problem exists. The new algo- ing with polygons that have efficient solutions that rithm can be viewed as a combination of Chazelle's begin with polygon triangulation as a preprocessing algorithm and of non-optimal randomized algorithms step (e.g., see [18, 20]). Thus, there has been consid- due to Clarkson et al. (1991) and to Seidel (1991), erable interest in finding efficient algorithms for this with the essential innovation that sampling is per- problem. formed on subchains of the initial polygonal chain, rather than on its edges. It is also essential, as in Chazelle's algorithm, to include a bottom-up prepro- 1.1 Related Prior Work cessing phase previous to the top-down construction Garey et al. [15] were the first to provide a non- phase. trivial algorithm for the polygon triangulation prob- lem. Their algorithm runs in O(nlogn) time and is based on an elegant plane-sweeping paradigm. Asano 1 Introduction et al. [2] show that this bound is in fact optimal for Polygon triangulation is a classic problem in compu- polygons that may contain holes. For simple poly- tational geometry, as it was one of the first problems gons without holes, the lower bound of Asano et al. studied in the field [15]. Furthermore, there are sev- does not hold, however. This fact, and the impor- tance of the polygon triangulation problem, in turn *Texas A&M University, College Station, TX. E-mail: prompted several researchers to work on methods for amat o@cs. tamu. edu beating O(n log n) time for this problem. tThe Johns Hopkins University, Baltimore, MD. E-mail: goodrich@jhu, edu Fournier and Montuno [14] and Chazelle and In- SMax-Planck-Institut fiir Informatik, Saarbriicken, Ger- cerpi [6] showed, even prior to the Asano et al. lower many. E-mail: ramos~mpi-sb.mpg.de bound result, that to triangulate a simple polygon in linear time it is sufficient to produce a trapezoidal de- composition (trapezoidation) of a simple polygon. In Pelmission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies addition, Yap [31] showed that a similar result holds are not made or distributed for profit or commercial advantage and that in a parallel computing model. A trapezoidation is copies bear this notice and the lull citation on the first page. To copy formed by shooting a vertical ray through each vertex otherwise, to republish, to post on servers or to redistribute to lists, of the polygon, stopping each ray as soon as it hits an- requires prior specific permission and/or a fee. Computational Geometry 2000 Hong Kong China other segment on the polygon. Since this early work Copyright ACM 2000 1-58113-224-7/00/6...$5.00 201 showing the importance of trapezoidation for trian- edge conflicts for the trapezoidation of the sample is gulation, every published triangulation algorithm has doomed to spend at least linear time per round. To concentrated on improving the running time of pro- avoid this, we decompose the original polygonal chain ducing a trapezoidation of a simple polygon. For ex- into smaller subchains, sample from the resulting set ample, Tarjan and Van Wyk [30] and Kirkpatrick et of subchains and, taking advantage of the coherence al. [21] showed that the trapezoidation step can be between edges in the polygonal chain, maintain lists performed in O(n log log n) time, resulting in a similar of subchain conflicts for the resulting subproblems, running time for the polygon triangulation problem. rather than edge conflicts. Using randomization, Clarkson et al. [10], Clarkson A technical difficulty in this approach is the defini- et al. [8, 7], and Seidel [28] gave simple randomized tion of the subproblems defined by a set of subchains. algorithms that run in O(n log* n) expected time. Fi- For the approach to work, one needs a decomposi- nally, in a much celebrated and anticipated result, tion with a size that is proportional to the number Chazelle [4] showed that one could, in fact, triangu- of subchains involved, and with faces (subproblems) late a polygon in linear time. Goodrich [16] subse- of bounded complexity. The later requirement is orig- quently showed that a similar result can be proven inated in the need to be able to derive appropriate for a parallel computation model. Unfortunately, the bounds for the sizes of the conflict lists, and in the trapezoidation methods utilized by these optimal de- need to have a decomposition that can be traversed ef- terministic algorithms are quite complex. Indeed, ficiently as one walks along the polygonal chain. This this conceptual complexity has led many researchers, concept also appears in Chazelle's algorithm; follow- including Chazelle [4] himself, to ask whether there ing him, we call this bounded-complexity property is a simple randomized algorithm for triangulating a conformality. Fortunately, our problem is simpler; polygon in linear time. To our knowledge, no simple we describe a simple procedure that computes a con- linear-time randomized algorithm has been presented formal decomposition in time linear in the number of previously. edges in the set of subchalns. This is actually sub- linear in the size of the input chain because it is per- 1.2 Our Results formed for a small sample. In order to traverse the decomposition efficiently, we need a data structure We describe a randomized algorithm for computing for each subchain that answers intersection queries the trapezoidation of a simple polygon. The ex- between a vertical edge, called a portal, and the sub- pected running time of our algorithm is linear in the chain. Thus, as in Chazelle's algorithm, we need a size of the polygon. As already mentioned, from the preprocessing phase that constructs these data struc- trapezoidation, a triangulation of the polygon can tures prior to the actual construction phase. These be obtained in linear time using well-known meth- phases proceed bottom-up and top-down respectively. ods [6, 14]. Thus, our algorithm provides a random- Randomization also plays an important role in the ized algorithm for polygon triangulation that runs in preprocessing phase. Chazelle has argued that such a linear expected time. In addition, our algorithm is combination of bottom-up and top-down approaches considerably simpler than Chazelle's celebrated opti- is indispensable. mal deterministic algorithm; hence, it addresses the A final technicality is the proof of appropriate sam- open problem posed by Chazelle and others as to the pling bounds for the sizes of the chain-conflict lists of existence of a simple randomized triangulation algo- our conformal decomposition: such bounds are known rithm that runs in linear expected time. under locality or monotonicity properties that our de- The general approach of our algorithm for comput- composition does not satisfy [1, 9, 11, 22, 24]. For- ing a trapezoidation of a simple polygon P follows tunately, we can prove appropriate bounds using the that of the non-optimal randomized algorithms by fact that, although the faces in the decomposition do Clarkson et al. [8, 7] and Seidel [28]. That is, we com- not satisfy a locality property, they are chosen from pute the trapezoidation of a successively finer sample a relatively small "pool" of candidates that satisfy a from P, using an algorithm for arbitrary edges (thus locality property. with nonlinear running time), in O(log* n) rounds. This paper is organized as follows. First, for com- The fact that the edges come from a simple polygo- parison purposes, we present a detailed outline of a nal chain is used to efficiently perform the compu- non-optimal randomized algorithm (Sec. 2). We then tation of the conflict lists of the trapezoidation of describe our procedure to compute a conformal de- the sample, once in each round, by walking along the composition for a set of chains (Sec. 3) and our linear original polygonal chain in the trapezoidation. Un- time algorithm (Sec. 4). Finally, we obtain appropri- fortunately, an approach that maintains the lists of ate sampling bounds (Sec. 5) for analyzing our algo- 202 rithm (Sec. 6). We conclude with some remarks and Non-Optimal-Trapezoidation (i-th round) state some open problems (Sec. 7). Input: T(R+_I) and its conflicts w.r.t. S Output: T(R +) and its conflicts w.r.t. S 2 A Non-optimal Algorithm 1. For each A 6 T(R+_I) For the purpose of comparison with our algorithm, a. Determine R/IA and as a warm-up, we outline a non-optimal random- T(Riv, U {el, e2}) restricted to A, ized algorithm which is an adaptation from those in b. T~ ~ { where el,e2 are the edges that [8, 7] and [28]. Let go be a simple polygonal chain, bound A S be the corresponding set of polygon edges, and let 2. Merge all the TA, A 6 T(R+_I), into T(R +) n = ]S[.