798 Chapter 13 Computational Geometry Topics
In the size 4 or larger block of code, the function is O(nr
2
) in time since TypeA
or TypeB is called only for at least two reflex vertices or for one reflex vertex and one
polygonedge.Theworkdoneineachcallto
TypeA or TypeB is O(1) plus the number
of pairs popped from the stacks. Since at most one pair is added to two stacks, at most
O(nr
2
) elements can be popped. The memory requirements are also O(nr
2
) due to
the space required for the stacks.
At first glance, the size 3 block of code appears to be O(n
2
) in time, O(n) for the
outer loop and O(n) for each straightforward visiblity test that checks if V
i
, V
i+2
is a diagonal. This potentially offsets the O(nr
2
) time for the size 4 and larger block
when r is much smaller than n. Since the size is 3, the visibility test is really checking
if V
i
, V
i+2
is an ear. As shown at the beginning of this section, the ear test can be
implemented by testing for containment of only the reflex vertices in the triangle
V
i
, V
i+1
, V
i+2
. The size 2 block can therefore be implemented to take O(nr) time.
Miscellaneous
Partitioning of a polygon can also be accomplished by using BSP trees. The BSP
tree for a polygon is computed as shown in Section 13.1. The leaf nodes of the tree
represent a convex partitioning of the plane. The positive/negative tags allow you
to identify those leaf nodes that correspond to convex subpolygons of the original
polygon. The union of these is the original polygon. This type of decomposition
inserts points into the polygon, unlike the methods discussed in earlier sections that
just use the original vertices. If a triangulation of the polygon is needed, the convex
subpolygons can be fanned into triangles.
The problem of partitioning polyhedra into tetrahedra is the natural extension
of partitioning a planar polygon. To date, the fastest algorithm to triangulate non-
convex polyhedra is presented in Chazelle and Palios (1990). The asymptotic order
is O(n log r + r
2
log r),wheren is the number of faces and r is the number of
reflex edges. Another relevant paper is Hershberger and Snoeyink (1997), which de-
composes a nonconvex polyhedron into convex pieces effectively by using BSP trees.
Practically speaking, the BSP tree approach is easy to implement and has acceptable
performance for the decomposition.
13.10
Circumscribed and Inscribed Balls
A triangle in two dimensions has two special circles associated with it, a circumscribed
circle that contains the vertices of the triangle and an inscribed circle that is the largest-
area circle contained in the triangle. Although the inscribed circle has the largest area
of all circles contained in the triangle, the circumscribed circle is not necessarily the
smallest-area circle containing the triangle. This is clearly the case when the triangle
vertices are nearly collinear, in which case the circumscribed circle has an extremely
large radius, but the minimum-area circle containing the triangle has a diameter