C.S. 252 Prof. Roberto Tamassia Computational Geometry Sem. II, 1992 1993 Lecture 05 Date: Febuary 17, 1993 Scribe: Peter C. McCluskey Trapezoid and Chain Methods 1 Trapezoid Method (continued) Continuing the discussion of the Trapezoid Method for determining the region in which a point is located: 1. Partition the planar straight-line graph (PSLG) into as many trapezoids as possible (a) Each trapezoid with one or more spanning edges (PSLG edges which cross both the upper and lower edges of the trapezoid (to be depicted as ) ) is divided by those edges into smaller trapezoids. (Figure 1) (b) Create the horizontal lines (to be depicted as ) dividing each trapezoid into two through the vertex within the trapezoid which has the median y-coordinate. (Figure 2) [ if the horizontal lines were calculated first, the algorithm would reduce to the Slab Method ] Figure 1: Spanning Edge Figure 2: Horizontal Edge 2. Query When multiple trapezoids separated by spanning edges contain only one PSLG vertex, they can be joined into a single node, and searched via a secondary binary tree. 1
It takes O(h + log n) time. Each edge is cut into 2 log n fragments. The space needed is O(n log n). Considering only the delta nodes, there are O(log n) layers if the tree is balanced locally. The height is O(log n) at each node, so the height is O(log 2 n) if the tree balanced locally, but O(log n) height can be achieved with global balancing. 2 Global Balancing Let u = T 1 l 1 T 2 l 2... T n 1 l n 1 T n where T i is a trapezoid, and l i is a line splitting the trapezoids. Define the weight w i of T i to be the number of vertices inside T i. Define W = n i=1 w i. Then the tree can be balanced by finding, at each trapezoid, an r that splits the weights as evenly as possible: r 1 i=1 w i <W/2, and ri=1 w i W/2. The balancing step at each trapezoid puts the first r 1 fragments into the right subtree of the trapezoid, and puts the remaining fragments into the left subtree. Theorem 1 Claim: height(tree(u)) 3 log 2 w + 5 where tree(u) is the tree whose base is at node u, and height(t) is the maximum number of nodes that need to be visited in order to reach a leaf of tree t. Proof: Inductive Proof: Base Case: w = 1 Figure 3: Base case, height 5 The tree for this case consists of 2 nodes of empty trapezoids, one a child of other, a node below that child, with node children on each side, and 2 children below each. Thus, the total height of this tree is 5. 2
Induction step: Assume that the claim is true for w < k. Prove for w = k: (refer to Figure 4) By inductive assumption and the fact that balancing makes each side in the lower part have weight k/2, H(lowerpart) 3 log 2 k/2 + 5 for each k/2 child of node τ. H(tree) (3 log 2 k/2 + 5) + 3 (3( log 2 k 1)) + 5 + 3 3 log 2 k + 5 If a spanning edge is found on the first try, then height(τ) = 3 log 2 n + 5, otherwise height(τ) < 3 log 2 n + 5. H(tree) w<k/2 w>=k/2 H(lower)<=3 log(k/2) +5 2 Figure 4: A tree of weight k, with subtrees of weights < k/2 3
Origins: Segment Tree Method 1986 [2] Slab Method 1976 [3] Trapezoid Method 1981 [1] 3 Preprocessing 1. Sort the vertices by their y-coordinates (O(n log n) time). 2. Create a left to right partial order of the edges using a line sweep (moving a horizontal line upwards) (n insertions of O(log n) time each for a total of O(n log n) time). 3. Sort the edges topologically (O(n) time). 4. Recursively decompose the trapezoids: a. (a) check each trapezoid for spanning edges (b) accumulate weights (c) make s b. Each τ i with no spanning edge is cut horizontally by the median y vertex. This creates O(log n) fragments. 4 Chain Method Definition: a monotone chain is a series of connected line segments with non-decreasing y-coordinates. Definition: a separator in a planar straight-line graph: a) extends from y = to y = +, b) must be a monotone chain, and c) does not cross any other separators (but may have edges in common with other separators) In order to use separators for point location, we start by creating the leftmost separator and adding new separators, with each additional one differing from the previous by using the right edges of one region which the previous separator the left edges of, until all edges have been used. Thus, the chains distinguish all the regions and can be stored in a tree which can be searched to determine which region a point is located in. The y-coordinate of the point will be used to find the correct edge in the chain associated with each node. This requires O(log n) search time at each node to find the correct interval on the chain, at O(log n) nodes, for a query time of O(log 2 n). Each chain uses O(n) storage, so with the naive approach the space required for the entire graph is O(n 2 ), although the average case should be better than this. See Figure 6 for an example where n 2 space is needed. Stay tuned for a trick to reduce the overall storage to O(n). 4
Figure 5: Examples after the first and second separator drawn References Figure 6: An example where n 2 space is used by the naive approach [1] Preparata, Franco P., A New Approach to Planar Point Location, SIAM Journal on Computing 10(3) 473-482 (1981). [2] Edelsbrunner, E, L.J. Guibas, and J Stolfi, Optimal Point Location in a Monotone Subdivision, SIAM Journal on Computing 15(2) 317-340(1986). [3] Dobkin, David and Richard Lipton, Multidimensional Searching Problems, SIAM Journal on Computing 5(2) 181-186 (1976). 5