
714 Chapter 13 Computational Geometry Topics
Although it is expected that eventually the outer loop terminates, it is not clear
how many iterations will occur until then. A variation is to replace the
while loop
by a
for loop that runs at most a specified number of iterations. If a good ray is not
found for all those iterations, a call can be made to a much slower algorithm, for
example the algorithm in Paeth (1995), “Point in Polyhedron Testing Using Spherical
Polygons.” This method requires computing solid angles, operations that use inverse
trigonometric function calls, hence the slower performance.
13.5 Boolean Operations on Polygons
A common question that arises in computer graphics is how to compute the in-
tersection of two polygons A and B, a query that is one of a collection of queries
generally known as Boolean operations on polygons. Each polygon is assumed to be
non-self-intersecting in that no edge transversely crosses another edge, but edges
meeting at vertices are allowed. Usually each polygon is assumed to enclose a con-
nected, bounded region that possibly has holes. We do not require boundedness and
allow edges to be line segments, rays, or lines. We also do not require connectedness.
For example, two disjoint triangles may be considered to be part of a single polygon.
The generality of the definition for polygon allows for operations other than inter-
section to be implemented in a fairly simple way.
The plane must be partitioned by the polygon into two disjoint regions, an inside
region and an outside region. Each linear component of the (potentially unbounded)
polygon has a normal vector associated with it. The region to which the normal is
directed is labeled the “outside;” the opposite region is labeled as “inside.” Equiva-
lently, if the linear components are represented as having directions, as you traverse
the component in the specified direction the inside region is to your left and the out-
side region is to your right. Figure 13.20 illustrates with three polygons, one bounded
and convex, one bounded and not convex, and one unbounded.
Figure 13.20 Bounded and unbounded polygons that partition the plane into inside and outside
regions. The inside region is gray. The unbounded polygon on the right is a half-space
with a single line as the boundary of the region.