Volume 7, number 4 INFGI??
$A’; r;j,> i- XXESSING LEIYI”“T:W5 June 1978
TRIANGULATING A SIMPLE POLYGON *
Michael R. CAREY, David S. JOHNSCM
Bell Laboratories, M-y Hill, N,’ 07974, USA
Frarlco P. PREPARATA **
Univertityof Iho& at Urbana-C%ampa&n,Wrbana,IL 61801, USA
Robert E. TARJAN ***
Stan&oti University,Stanford, CA 94305, USA
Received 8 November 1977
Closest-point problems, computational geometry, polygon, triangulation
1 htroduction a simple polygon appears to be more difficult. Indeed.
no previously known method im,proves on the o(n13
Let P be a simple n-sided polygon in the :plane, not brute force algorithm. (The method of [4,51 is no*
necessarily convex. A diQgona2 of P is a line segment sufficient, since it cannot ensure that the boundary
joining two non-adjacent vertices of P. We c,onsider edge:sof P will belong to the constructed triangulation.)
here the problem of triangulating P, that is, of finding We shall give an algorithm which triangulates an arbl-
n - 3 diagonals which intersect neither each other nor trary n-vertex simple polygon in time O(n log tip).
the boundary of P and which divide the interior of P Our algorithm depends heavily upon results in f I] .
intox - :2triarrgles We use the “regularization” procedure of that paper
Applications of triangulation arise in closest point to preprocess the given polygon, subdividing it into
problems [ii ,2] and in evaluating functions by interpo- polygons having a very simple structure. This special
lation [3,6]. An elegant algorithm for triangulating a structure permits us to complete the triangulation usin
set S of n points in the plane has been given by Shamos a straightforward algorithm for triangulating each of the
[4.5], using the Voronoi diagram of S, and it requires simpler polygons. Section ?, of this paper presents the
on& O(n log n) steps on a random access machine with algorithm for triangulating such a specially-structured
real-number arit’ .metic. The problem of triangulating polygon, and Section 3 discusses the property of ‘keg
ularization” which allows us to use this algorithm for
* The results in this paper were obtained independently by triangulating an arbitrary simple polygon.
the third author and by the first, second, and fourth auth-
ors.
** Departments of Electrical Engineering and cf Computer
Science. and the Coordinated Science LaboraPorl. Research 2. Triangulating :nmonotone polygon
of this 6.uthor supported in part by Nation& Science
Foundatkn grant MCS76-17321 and the Joint Servicm Let P be Qsimple polygon in the plate
Electronics program Contract DAAB-07-72-C-0259. axy vertices ply p2, .... ptz.
*** Computer Science Department. Research of this auth x
supported in part by National Scimce Foundation grant
preferred direction and as
MCS75-2287Q Office of Naval Research Contract N00014- that no two vertices of pbhave the same y-
76-C-0330, zuld Bell Laboratories. (this assumption is not crucial to the resu
Volume7, nur&r 4 INFORMATION
PROCWSINGEETTERS June 1978
merely to simplify the presentat:ionj. Suppose without
loss of generality th%atp1 is the vertex with the largest
y-coordinate. The polygon P is said to be nzoProtorre
if there is a vertex pe such that the vertices pl, pss .*.,
pk are in decreasing order by y-coordinate and the
vertices pb p&+1,..-, pm p1 are in increasing order by
y-coordinate. ln this section we describe an algorithm Fig. 1. Caw (a) of the monotone polygon triaq@ation alga-
for triangulating a nonotone polygon. rithm. Dashedlines are odded diagonals.The remainingpoly-
To triangulate such a polygon P, we first sort its gon is formedfrom the old polygon by replacingthe polygonal
vertices in order of decreasing y-coordinate, Because chainJ:,xl, x2, xg x4 by the line segmentx, x4.
P is a monotone, this can be done in time O(n) by
merging the two sequences of vertices given by the
definition. Suppose ql, 42, .... qn is the resulting at J:i is at least 180” : add diagonal (x1-1, x), delete
sequence, withqi ‘~1. It is easy to prove that the xi from the stack, and replace i by i - 1 aWhen this
following property (*) is equivalent to the monotone step is no longer ap,plicable, add x to the top of the
propps”ry: stack.
(*) For 2 G i Q n, there is some j ,< i such that qi and I$) Otherwise, if x is adjacent to both xl and xi,
41 are adjacent on the boundary of P. add diagonals (x, x2), (x, x3), .... (x, x1-1) and stop.
We process the boundary vertices in the order ql, Vertex x is the last one to be processed.
q2, l**9qn. When we process a vertex, we may add cer- Repeat the general step until case (c) applies.
tain diagonals to the polygon. Each added diagonal Fig!;. 1 through 3 illustrate cases (a), (b) and (c). The
cuts 2 triangle off of the polygon and leaves a polygon correctness of the algorithm depends upotl the fact
of one less side still to be triangulated. We shall call that the added diagonals lie completely inside ‘be poly-
the part of the original polygon still to be triangulated gon. Consider for example the diagonal (x, x2) con-
the “remaining polygon”. structed in case (a). None of the vertices xg x4, .... X‘K~
During the processing, we maintain a stack that con- can Be inside or on the boundary of the triangle formed
tains all vertices which have been processed so far and by xl, x2, and x because the internal angles of at least
which lie on the boundary of the remaining polygon. 180” at xa x3 , .. .. xi_ 1 force x and x;), x4, .... xi to lie
The contents xl, x2, ..., Xi of the stack satisfy the fol- on opposite sides of the line through xl, x2 (Fig. 4).
lowing properties drrrng the processing: No other vertex of the polygon lies inside or on the
(i) x1, x2, . ..) Xi are in decreasing order byy-coor- boundary of this t&ngle because all such vertices have
dinate; smaller y-coordinates than x. No point inside the tri-
60x1, x2, l**9xi form a chain on the boundary of angle can be exterior to the polygon, because the poly-
the remaining polygon; gon would then have to pass through the interior of
(iii) the inter‘;laJangles of the remaining polygon at the triangle, and at least one of its vertices would be
x21x39 l**Yxi-1 are at least 180” ; and
(iv) the next vertex to be processed is adjacent to
either x1 or xi (or both).
Here is the triangulation algorithm.
Initialstep: Place the first two vertices ql and q2
in the stack.
Generalstep: Let x1, x2, ..... xi denote the stack
contents and x the next vertex to be processed.
(a) Jl’x is adjacent to xl but not xi, add &ago-
nals cc x2), 6, x3), *a*, (x, Xi). Replace the stack
contents by xi, X.
Fig;.2. Case (b) ci’ the monotone polygon triangulationalgo-
(b) Otherwise, if x is adjacek;t to xI but not xl, knm. The remainingpolygon is formed from the old polygon
repeat the follotig until i = I or the internal angle k y replacingthe polygonal chainx3, x* x5 x by x3 x.
176
Volume 7, number 4 June 197
stant factors, neither the time complexity nor the
space requirements can be improved,
3. b@&uizatioh and inonotone polygons
Tocomplete the triangulation algorithm we need
Fig. 3. Case (c) of the monotone polygon triangulation algo- a met’hod for sub:dividing an arbitrary simple polygon
rithm. into one or more monotone polygons. For this purpose
we use the regularization algorithm of [ 11. This dgo-
rithm adds diagonals to the given polygon P, none of
which intersects either a boug.dary edge or another
diagonal, so that the following properties hold:
(i) Each vertex (except the one with largest y-coor-
dinate) is joined directly to at least one vertex with a
larger y-coordinate; and
(ii) Each vkrtex (except the one with smallest y-coor-
dinate) i8 joined directly to at least one vertex with a
smaller y-coordinate.
The regularization algorithm may add some &as_
Fii 4. Verticesx and xg x,+, xg lie on opposite sides of the
line through xl and x2. 04s which are-exterior to P{see Fig. 6(a)), but for
our purposes these can be ignored. As shown in Fig.
6(b), the diagonals added to the interior of P sirbdivid
P into a number of smaller polygons, each of which
contains no portion of any other diagonal in its inte-
rior. We claim that each of these polygons must be
x2
monotone.
LRt us say that a vertex 4 of a simple polygon Q is
an inter&r cusp of Q if the internal angle at 4 exceeds
180” and the two vertices adjacent to (I on the bound-
ary of Q either both have larger y-coordinates than 4
or both have smaller y-coordinates than 4. We then
Fig. 5. Pointy is on the outside of the polygon. Some point observe that, if Q is any one of the polygons obtained
z on line segment (xl, y) must lie on the polygon boundary. as described above from regularizing P, then no vertex
At least one end of the boundary edge containing z must lie of Q can be an interior cusp. Thjisis an immediate
inside the triangle xl, x2, x.
consequence of the two regularization properties and
the fact that Q was chosen so th#t none of the dia,g
in the interior of the triangle (Fig. 5). Thus, the diag onals introduced in the regularization of P intersects
onal (x, x2) lies completely within the polygon. A proof its interior. The following theorem then implies that
by induction verifies that the other diagonals constructed each of the.;.polygons obtained by regularizing P is a
in case (a) lie inside the polygon. The proofs for cases monotone: polygon.
(b) and (c) are similar.
It is routine to verify that properties (i) through llteorem 1. If Q is a simple polygon landno vertex of
(iii) are preserved by the general step. The validity of Q is an interior cusp, then Q is monotone.
(iv) follows from (*)*
The algorithm requires Q(n) time for the initial oof. Let Q be a polygon satisfying the hppot
merge-sort and O(n) time to process all the vertices. of the theorem, and let ql, q2, ..+$qan denote the ver-
Ihe space required is also O(n). Thus, except for con- tices of Q, listed in clockwise order almoundthe bound-
INFORMATlON PROCESSIF$GLETTERS June 1978
i0)
(b)
Fig. 6. A simple polygon P: (a) regularized; (b) decomposed into monotone polygons; (c) triangulated.
arg. Suppose without less of generality that Ql has the Among all the vertices of Q’, let s be the one having
largest y-coordinate among these and that qk, 1 < k G largest y-coordinate. Then s is also a vertex of Q, and
m , has the smallest y-coordinate. If Q is not monotone, furthermore s must be an interior cusp; it therefore
?nen one of the two chtilns from 41 to Q&formed by follows that Q must be monotone.
the boundary edges of Q is not strictly decreasing by The following algorithm triangulates an arbitrary
y-coordinate. Consider the case in which the chain simple polygon.
passing through q2 faik to be strictly decreasing (the Step 1. Apply the regularization algorithm to the
other case is symmetric). Choose 41, 1 <i <k, to be polygon. Delete all added diagonals which are exterior
the first vertex on thi!; path such that the y-coordinate to the pofygon (in fact the regularization algorithm
of qi+l exceeds that of QI. can be mcdified to add only the interior diagona!s).
We first obseme that the edge from qi to qi+l must Step 2. Apply the algorithm of Section 2 to t&n-
lie to the Ileft of the edge from qi_l to 41, for other- gulate each monotone polygon in the subdivision of
wise qi would be an interior cusp of Q (see Fig. 7(a)). the given polygon constructed by Step 1.
Now consider the line through qi and qk (see Fig. 7(b)), Fig. 6(c) shows the results of applying this algorithm
and let r +r qi be the first point on the boundaq ol Q to a simple polygon.
encounterlzd when traveling from gi to 4s along this The regularization algoiithm given in [ 1] requires
line (r might be qk). Then the line segment joining pi O(n log n) time for zn n-vertex polygon, and the algo-
to I divide:3the exterior of Q into two parts, one of tithkmof Section 2 requires a total of o(n) time to
which is a finite polygon Q’, as shown in Fig. 7(c). triangulate all the polygons in the resulting subdivision.
Except for r, the vertices of Q’ are all vertices of Q. Thus the total time required for triangulating an n-ver-
(a) (b) (cl
I-&. 7. Steps in f!w proof of Theorem 1: (a) qi is the first ver- a.ry for the first time at point r; (c) polygon &’ exterior to Q
tex on the path q1,42 , .... qk such that qi+l has largery-coor- formed by the line segment (qh r); s is the vertex of Q’ having
dinate than qi; (b) !ine from qi to qk intersects polygon hound- largest y-coqtdinate and must be an interior cusp of Q.
178
,I I
D.T. Lee and F.P. Reparata, Location of apointina W-162.
planar subdivision and its applications, SIAM 3. Cornput. [6] G. Strang and G. Fix, An Analysis of the Finite Element
6 (1977) 594-606. Method, (Prentice-Hall, Englewood Cliffs, NJ, 1973).
R.J. Lipton and R.E. Tarjan, Applications of a planar
separator theorem, to appear.