1.2 Survey of the Algorithm
In the sequel, a p olygon is denoted by
P
, and
n
stands for the number of its vertices.
As a convention, we include the interior of a polygon when referring to
P
. Unless stated
otherwise, we will assume that
P
is a simply-connected area, i.e., b ounded by one single
lo op of straight-line segments. The vertices are numbered in counter-clo ckwise orientation
and denoted by
v
0
; : : : ; v
n
?
1
. As usual, all vertex indices are taken mo dulo
n
.
We present an algorithm that triangulates a p olygon by searching for \ears" and \clip-
ping" them. As usual, three consecutive vertices
v
i
?
1
; v
i
; v
i
+1
of
P
are said to form an
ear
of
P
if
v
i
?
1
; v
i
+1
is a diagonal of
P
. According to Meisters [33], every simple p olygon that
is not a triangle has at least two non-overlapping ears.
A straightforward implementation of a triangulation algorithm based on rep eatedly
clipping ears runs in
O
(
n
3
) time, with
O
(
n
) time sp ent on checking whether three subse-
quent vertices form an ear. A simple re-organization of the ear-nding pro cess allows to
check only
O
(
n
) ears, thus nding all ears in
O
(
n
2
) time, see [31, 36]. However, this com-
plexity still is to o high for practical applications. Whereas faces of a p olyhedron typically
have rather few vertices, applications in GIS may involve p olygons with several tens of
thousands of vertices.
We try to reduce the practical complexity of nding one ear by p erforming only lo cal
searches. Bounding-volume trees, as successfully used in our work on collision detection [30,
26], or, alternatively, regular grids are used for registering the p olygon under triangulation
and for pruning the search while testing for earity
1
. While any form of geometric hashing
do es not reduce the worst-case complexity, it helps a lot to reduce the practical running
time of the triangulation algorithm, as witnessed by our exp eriments.
The algorithm rst determines the orientation of the p olygon. Then it rep eatedly
clips ears of the p olygon until the polygon has b een transformed to a triangle and the
entire triangulation is known. The actual core of the algorithm is based on one predicate:
we only need to check the sidedness of three p oints. (In addition, a lexicographical sort
of the vertices of the p olygon is used.) We make sure that this primitive is always used
consistently. Furthermore, care has b een taken to ensure that degenerate cases are handled
correctly.
If the algorithm cannot nd any valid ear to clip | e.g., due to deciencies of the input
p olygon, or due to numerical errors | then it tries to restart the triangulation pro cess
by applying several heuristics. For instance, it checks whether subsequent edges of the
p olygon intersect, and applies a sp ecial rule in order to by-pass this deciency. Then, the
standard ear-clipping process is resumed again. Similarly, it tries to nd a diagonal that
splits the p olygon into two sub-p olygons, which are then again sub jected to the standard
ear-clipping process.
If everything fails, and no heuristic helps to reduce the number of vertices of the
p olygon, then the algorithm (temp orarily) go es into \desp erate mo de". It randomly picks
a convex vertex, and clips the corresponding \ear". If no convex vertex exists then a reex
vertex is chosen randomly. Thus, the more desp erate the co de gets the more aggressive
means are used for \nding" an ear or a diagonal, thereby always reducing the numb er of
vertices of
P
by at least one. This strategy allows the co de to produce triangulations that
degrade gracefully as the deciencies of the input p olygon get more serious. Of course, at
1
\Earity test" is the common nickname for the pro cess that tests whether a triple of consecutive vertices
forms an ear.
2