Notes 05
Notes 05
Roberto Tamassia
Computational Geometry Sem. II, 1992–1993
1 Introduction
The chain method of point location was introduced in Lecture 6. This lecture describes the
preprocessing required to implement the chain method. It also describes how to transform
an arbitrary subdivision of the plane into a subdivision in which all regions are monotone.
This allows the chain method to be applied to arbitrary point location problems.
Recall that the planar point location problem is stated as: Given a division of the plane
into regions, R0 , R1 , ... Rn , and given a test point, p, find which region, Ri , contains p.
The chain method uses monotone chains to divide the plane into regions. Point location is
performed by discriminating p against the chains.
Vertices: Let each vertex be represented by its x and y coordinates in the plane ie vi = (xi ,
yi ). If there are n vertices in the Planar Straight Line Graph, PSLG, that defines the
regions, all vertices can be stored in O(n) space.
Edges: Edge information is stored in the adjacency lists of the vertices. Since each edge will be
listed twice (eg the edge from vertex vi to vertex vj will be listed in the adjacency lists
of both vi and vj ), the space requirement to capture all edge information of the PSLG
is also O(n) If the edges have names, we associate the edge names with the vertices in
the adjacency lists.
Regions: For each region, we store the list of vertices that delimit it from neighboring regions.
For simplicity, we follow the vertices in a defined order, such as clockwise around the
boundary of the region. Therefore, the region stored as v1 , v2 , v3 ... vk corresponds
to the region with edges (v1 v2 ), (v2 v3 ) ... (vk v1 ) The space requirement here is also
O(n).
1
We will assume that the input data for the point location problem is in this format. If
the vertices on the region boundaries are not already sorted, they should be sorted at this
input stage of the process. This could take O(n2 logn).
• Using the order of the regions defined by the topological sort, assign a region to each
leaf of the tree.
• Assign a chain to each node of the tree, such that regions to the left of each chain are
to the left of the node associated with that chain, and regions to the right of the chain
are to the right of the node.
Then we insert edges in the tree, such that the edges of each chain are at the node
associated with that chain or at ancestors of that node.
The steps of this process are described in the following sections.
1. Scan the vertex list of all regions to select the two regions which contain e on their
boundary.
2. For the selected regions, find the vertices with the largest and smallest y-coordinate,
phi and plo .
2
3. Determine whether e is on the left or right chain joining phi and plo . If the edges of
each region have been stored in clockwise order, this is achieved by simply comparing
the x-coordinate of the endpoints of e with the x-coordinate of an edge on the opposite
path from phi to plo .
If e is on the left chain that joins these vertices, then R is to the right of e. Conversely,
if e is on the right chain, R is to the left of e. Figure 1 illustrates this process.
e R2 e R2
R1 R1
R3 R3
(a) (b)
Figure 1: Finding the regions to the left and right of an edge (a) R1 is to the left of edge e.
(b) R2 is to the right of e
Each of the steps above can be done in O(n) time, so the process of finding regions to
the left and right of all edges will require O(n2 ) time. Therefore, the time required to create
the inverse graph is O(n2 ).
3
C4
C2 C6
C1 C3 C5 C7
R1 R2 R3 R4 R5 R6 R7 R8
Figure 2: Assignment of regions and chains to the leaves and nodes of a chain tree
The time requirement can reduced by considering each edge in turn (rather than each
chain in turn). Using the information about the regions to the left and right of the edge
(computed in step 3.1), we identify the leaves of the chain tree associated with these regions.
We place the edge at the node of the lowest common ancestor of these leaves. An efficient
(constant time) method for finding the lowest common ancestor of leaves of a binary search
tree is described in Appendix A.
Finally, we sort the edge list at each node. We do this by putting a ficticious vertex at
the center of every edge of the PSLG. We do a topological sort on these vertices (assume
edges are pointing upward). This will require time O(n).
We have now produced the chain tree required for the chain method of point location in
O(n2 ) time. The chain method can be applied for any input point p, as described in Lecture
6.
4
: Downward cusp
: Upward cusp
2. Initilize the edge list to contain a dummy edge e0 from the uppermost vertex, v1 to -
infinity. Add the leftmost edge from v1 , e1 with associated vertex v1 . Add the rightmost
edge from v1 with associated vertex v1 .
3. Set i = 2.
6. If vi is a downward cusp, set vi to be the vertex associated with ej−1 and with ej+2 .
Then delete ej and ej+1 (and their associsted edges) from the edge list.
7. If vi is an upward cusp, insert the edges emanating from vi , between ej and ej+1 , in
the edge list. Add the edge ej to a new list, called the auxiliary list. Associate vi with
each of these edges.
8. If vi is not a cusp, asociate vi with edge ej and ej−1 . Set ej to be the outgoing edge of
vi .
10. Halt
At this point the auxiliary list contains edges which, when added to the PSLG, will
eliminate all upward cusps.
The ascending algorithm is similar, but with the sweep moving in the opposite direction.
5
sweep
line
sweep
line
Figure 4 shows the edges added during the descending and ascending line sweeps on the
polygon of figure 3.
We label all regions that have been created during this edge addition process with the
label of the original (non-monotone) polygon P. Then when the point location algorthm is
implemented, if the point p lies in any of these regions, the correct region is reported.
Analysing this algorithm, we see that the initial sorting pass of the vertices requires
O(nlogn) operations. Step 4 involves tracing a path in the edge list. If the edge list is
implemented as a balanced tree, this requires at most O(logn) operations. Thus the total
amount of work involved in step 4 is O(nlogn). Each update, deletion or insertion (steps 5,6
and 7) requires time at most O(logn). So the total number of operations for these steps is
O(nlogn). In total, the algorithm requires O(nlogn) time.
6
- 1, where ⊕ is the binary EXOR function, gives the number of the node which is the lowest
common ancestor of a and b.
For example, if we look at leaves numbered 1 (001) and 5 (101) of the binary tree of
figure 5(b), we find that:
2blog2 a⊕bc - 1 = 2blog2 001⊕101c - 1 = 2blog2 100c - 1 = 22 - 1 = 3
We have correctly identified that node C3 is the lowest common ancestor of leaves 1 and
5.
C3
0 1 C1 0 1 C5
0 1 0 1 0 0
C0 C2 C4 C6
0 1 0 1 0 1 0 1 1 1
000 001 010 011 100 101 110 111 000 001 010 011 100 101 110 111
(a) (b)
Figure 5: Finding the lowest common ancestor of nodes in a binary tree. (a) The labeling
of edges and leaves (b) Illustration of lowest common ancestor of leaves 1(001) and 5 (101).
If we precompute and tabulate the values of 2blog2 a⊕bc - 1 for all possible values of a and
b, we can find the lowest common ancestor of any two leaves in constant time with a simple
table lookup.
References
[1] F.P. Preparata and M.I. Shamos, Computational Geometry, An Introduction ,48-56, 1985.
[2] D.T. Lee and F.P. Preparata, “Location of a point in a planar subdivision and its appli-
cations”, Siam Journal on Computing 6(3), 594-606, Sept. 1977
[3] T.H. Cormen, C.E. Leiserson and R.L. Rivest, Introduction to Algorithms, MIT Press,
McGraw-Hill 1990