You are on page 1of 3

AMS 345/CSE 355 (Spring, 2006) Joe Mitchell

COMPUTATIONAL GEOMETRY
Homework Set # 8 – Solution Notes
(1). Consider the set S of 7 line segments given by S = {s0 , s1 , . . . , s6 } = { ((-4,13.5),(4,6)), ((1,3),(6,16)),
((2,9),(7,13)), ((3,15),(8,5)), ((4,4),(10,8.5)), ((6,7),(13,17)), ((9,14),(12,10))}, where each segment s i = (ai , bi )
has upper endpoint ai and lower endpoint bi .

15

3
0 6
10 2 5

5 1 4

5 10 15

Apply the Bentley-Ottmann sweepline algorithm to S. Give the event queue Q and the sweep status L just after
each event. (Use the notation as in the text that xij denotes the point (if any) at the intersection of segment si and
segment sj .)
Show the chart, just as in the handout given in class.
I show the execution of the algorithm in the table below. I place an event point x ij in square brackets (“[xij ]”)
if it would not be present if we follow the modified Bentley-Ottmann algorithm, which deletes crossing events from
the queue whenever the corresponding segments stop being adjacent in the sweep status (they are reinserted later,
when the segments are again adjacent).
Event Event Queue, Q Sweep Status, L
- (a5 a1 a3 a6 a0 a2 b6 b2 a4 b5 b0 b3 b4 b1 ) ()
a5 (a1 a3 a6 a0 a2 b6 b2 a4 b5 b0 b3 b4 b1 ) (s5 )
a1 (a3 a6 a0 a2 b6 b2 a4 b5 b0 b3 b4 b1 ) (s1 , s5 )
a3 (a6 a0 a2 x13 b6 b2 a4 b5 b0 b3 b4 b1 ) (s3 s1 , s5 )
a6 (a0 a2 x56 x13 b6 b2 a4 b5 b0 b3 b4 b1 ) (s3 , s1 , s6 , s5 )
a0 (a2 x56 x13 b6 b2 a4 b5 b0 b3 b4 b1 ) (s0 , s3 , s1 , s6 , s5 )
a2 (x56 x13 x12 b6 b2 a4 b5 b0 b3 b4 b1 ) (s0 , s3 , s1 , s2 , s6 , s5 )
x56 (x13 x12 b6 b2 a4 b5 b0 b3 b4 b1 ) (s0 , s3 , s1 , s2 , s5 , s6 )
x13 (x23 [x12 ]b6 b2 a4 x01 b5 b0 b3 b4 b1 ) (s0 , s1 , s3 , s2 , s5 , s6 )
x23 (x12 b6 b2 a4 x35 x01 b5 b0 b3 b4 b1 ) (s0 , s1 , s2 , s3 , s5 , s6 )
x12 (b6 b2 a4 x35 [x01 ]b5 b0 b3 b4 b1 ) (s0 , s2 , s1 , s3 , s5 , s6 )
b6 (b2 a4 x35 [x01 ]b5 b0 b3 b4 b1 ) (s0 , s2 , s1 , s3 , s5 )
b2 (a4 x35 x01 b5 b0 b3 b4 b1 ) (s0 , s1 , s3 , s5 )
a4 (x35 x01 b5 b0 b3 b4 b1 ) (s0 , s1 , s3 , s5 , s4 )
x35 (x01 b5 x34 b0 b3 b4 b1 ) (s0 , s1 , s5 , s3 , s4 )
x01 (b5 x34 b0 b3 b4 b1 ) (s1 , s0 , s5 , s3 , s4 )
b5 (x34 b0 b3 b4 b1 ) (s1 , s0 , s3 , s4 )
x34 (b0 b3 b4 b1 ) (s1 , s0 , s4 , s3 )
b0 (b3 b4 b1 ) (s1 , s4 , s3 )
b3 (b4 b1 ) (s1 , s4 )
b4 (b1 ) (s1 )
b1 () ()
(2). Let P be a given simple polygon, specified by a list of its vertices in counterclockwise order around its boundary.
We know that P can be preprocessed in time O(n), to build a data structure of size O(n), that supports “point-in-
polygon” queries: Is the point q inside polygon P ? (Triangulate P , using Chazelle’s algorithm, triangulating both the
inside of P and its exterior (after placing it, e.g., in a giant triangle that surrounds it). Then preprocess using the
Kirkpatrick algorithm, which allows point location in time O(log n) to report which triangle contains a query point q.
Since we can tag each triangle as being “inside” or “outside”, we can determine if q is inside or outside P in time
O(log n) by this method.)
We want to solve the following two special cases by a simpler method, avoiding the need to triangulate P (since
Chazelle’s algorithm is a real mess!) and the need to build the Kirkpatrick hierarchy. Show how to do point-in-polygon
queries in time O(log n), using O(n) preprocessing/space, for the case that P is (a). a convex polygon; and (b). an
x-monotone polygon.
The following method applies to both parts (a) and (b), since it only assumes that P is x-monotone:
In O(n) time we find the leftmost and rightmost vertices of P . Also, since the know the order of the vertices
around the polygon, we can organize them into two x-monotone chains of vertices connecting the leftmost vertex to
the rightmost vertex, still in O(n) time. Then, in O(n) time we can merge these two lists into one list sorted in x.
This gives us the vertices of P in x-sorted order. Consider the vertical lines through each vertex of P . They cut
the plane into vertical slabs, with each slab having at most three trapezoids: one consisting of points above P , one
consisting of points inside P , one consisting of points below P . We locate query point q in O(log n) time among the
slabs, just by doing binary search on the x-coordinates. Then, an additional O(1) time is all that is needed to test
which of the (up to three) regions of the slab contains q, and this tells us whether q is in P or not. See the figure
below.

Alternative Method for (a) Convex Polygons: First, we trivially can triangulate the convex polygon,
making a “fan” triangulation from any one (say, v0 ) of its vertices, with diagonals connecting it to every other vertex
(except the two that are its neighbors in the boundary). (Alternatively, we can place any (“Steiner”) point inside
the polygon and join it to all n vertices.) Now, consider the (infinite) rays from v 0 to each of the other vertices
(v1 , . . . , vn−1 ). These rays partition the plane into cones. We can use binary search (adapted to take care of the
“wrap-around effect”) to find which cone contains the query point q in O(log n) time. Then, in additional O(1) time
we can determine if q is inside P or not, since we have only to decide which side of one additional segment contains
q.
(3). Given a set S of n points in the plane, give a method of constructing an efficient data structure that allows one
to answer quickly a query of the following form: Is there a point of S within distance r of point q = (q x , qy )? (The
query is specified by giving three numbers: r, qx , qy .)
We are given a set S of n points in the plane. First, we construct the Voronoi diagram for S; this takes time
O(n log n) and results in a data structure (e.g., winged-edge data structure) of size O(n). A query for a point q and
radius r can be answered by finding the point of S that is closest to q: if point p ∈ S is closest to q, and the distance
d(p, q) ≤ r, then the answer to the query is “yes, there is a point of S within distance r of q”.
Thus, we want to preprocess the Voronoi diagram, V D(S), for point location queries: This takes time O(n),
since each face of V D(S) is a simple polygon (in fact, a convex polygon), implying that each can be triangulated in
linear time, and then Kirkpatrick’s point location method can be applied with additional O(n) preprocessing time.
A query for point q is answered in time O(log n) and reports back which face of V D(S) contains q. This tells us the
closest point, p ∈ S, to q, since p is the “owner” of the face of V D(S) containing q.
In total, we spend O(n log n) preprocessing time to build a data structure of size O(n) for which queries cost
O(log n) each.
(4). Build the Kirkpatrick point location hierarchy for the triangulation shown below. At each step, when you identify
an independent set, apply Algorithm 7.4 on page 277, breaking ties when you select a node in favor of the lowest
numbered vertex. When you retriangulate a hole, use the simple ear-clipping algorithm (Triangulate, page 39),
starting at the (rightmost) bottommost vertex of the hole (as “v0” in Triangulate, the first one tested for earity),
and proceeding counterclockwise.
(a). List the independent sets corresponding to each stage of the algorithm. Also, for each stage, draw the
corresponding triangulation.
The independent sets at each stage are given by: {2, 6}; {3, 4}; {5}; {7}.
See the sequence of figures below.
(b). Draw the final hierarchy as a DAG, with each node of the hierarchy labeled by the triangle to which it
corresponds. (When you label a node, please list the triangle as a triple with the vertex indices in order; e.g., the
triangle with vertices “1”, “8” and “9” should be written as “189” (not as “819” or “918”, etc).)
See the DAG below.
(c). Highlight in the final hierarchy those nodes that are explored when point location is performed for point p, as
shown in the figure.
The nodes are circled in red1
below. 1

3 3
5 5
p p
4 4

6
8 8
7 7

9 9
1 1

5
p p

8 8
7 7

9 9
1
189

178 179

158 159 579


p

135 145 358 578


8

123 124 138 149 235 245 356 368 457 479 567 678 789
9

You might also like