1 / 52

COSC 6114

COSC 6114. Prof. Andy Mirzaian. Point Location. Planar Point Location: Knowing where you are on the map. References :. [M. de Berge et al] chapter 6 [O’Rourke’98] chapter 7.6 [Edelsbrunner ’87] chapter 11 [Preparata-Shamos’85] chapter 2.2 Applications :

fathi
Download Presentation

COSC 6114

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COSC 6114 Prof. Andy Mirzaian Point Location

  2. Planar Point Location:Knowing where you are on the map

  3. References: • [M. de Berge et al] chapter 6 • [O’Rourke’98] chapter 7.6 • [Edelsbrunner ’87] chapter 11 • [Preparata-Shamos’85] chapter 2.2 Applications: • GIS: Geographic Information Systems • Computer Graphics • Mobile Telecommunication • Mobile Robotics • …

  4. Point Location in a Planar Subdivision PSLG = Planar Straight-Line Graph q PSLG Locate a query point q in the PSLG: find which face of the PSLG contains q. Complexity Measures: • S - space to store the point location data structure • T - preprocessing time to construct the data structure • Q - query time to locate the PSLG face that contains the query point.

  5. Point Location in a Planar Subdivision • 1D Optimal method: sorted array, S = O(n), T = O(n log n), Q = O(log n). • 2D: Shamos [1975]: Slab Method: S = O(n2), T = O(n2), Q = O(log n). • 2D Optimal Method: S = O(n), T = O(n log n), Q = O(log n). • Mulmuly [1990], Seidel [1991]: Randomized Incremental Method. • Kirkpatrick [1983]: Triangulation Refinement Method. • Edelsbrunner-Guibas-Stolfi [1986] SIAM J. Computing, pp:317-340. • Sarnak-Tarjan [1986], “Planar point location using persistent search trees,” Communications of ACM 29, pp: 669-679. • Lipton-Tarjan [1977-79]: Planar Separator Method. • 2D Line Segments intersections: Randomized Incremental Method in O( K + n log n) expected time.

  6. The Slab Method • O(n2) space • O(n2) preprocessing time • O(log n) query time. A given PSLG with n vertices ( # edges  3n-6). We may add a large bounding box. y x

  7. The Slab Method • O(n2) space • O(n2) preprocessing time • O(log n) query time. A given PSLG with n vertices ( # edges  3n-6). We may add a large bounding box. y q x a vertical slab Query Answering: • do binary search among slabs (in x-sorted order). • do binary search vertically within the located slab. • each binary search takes Q = O(log n) time.

  8. Preprocessing for the Slab Method The Plane Sweep Method: • Event schedule: x-coordinate of PSLG vertices in increasing order. Maintain these in a priority queue Q. • Event Status: vertical sorted ordering of sub-regions within the current slab. Maintain this in a dictionary D. • Create a sorted array of slabs. Every time a slab is completed, dump a copy of the current D in the next entry of the sorted array of slabs. [This will be the final data structure.] • Analysis: • Event processing takes O(log n) time on Q, O(ev log n) time on D, and O(n) time to dump a copy of D into the permanent D.S. Here ev is the number of edges incident to the current event vertex v. • Total Preprocessing Time T = O(n log n +v ev log n + nn) = O(n log n + n log n + n2) = O(n2). • Space = O(n2).

  9. Randomized Incremental Method Construct the Trapezoidal decomposition not by the sweep method but by a randomized incremental method. This at the same time constructs the query search structures and also has optimal expected performance. y x

  10. Randomized Incremental Method Defining features of a trapezoid :  is defined by up to 4 line segments left(), right(), top(), bottom(). (These are some edges of the PSLG, possibly not all distinct.) top()  right() sides left() bottom() top() top() top() top() left()  left()    left() bottom() bottom() bottom() left() bottom() right() is defined symmetrically.

  11. Randomized Incremental Method CLAIM: If PSLG has n line segments, then # trapezoids  3n + 1. Proof: Assume 2n end-points are in general position.Each end-point defines left/right wall of at most 3 trapezoids. Except the leftmost & rightmost trapezoids, each trapezoid is defined by 2 vertical walls (incident to 2 end-points).  2(# trapezoids) – 2 = 3 (# end-points) = 6n. • # trapezoids = 3n+1. If end-points are not in general position (i.e., some have equal x-coordinates, or coincide), then the count is even less. [Could use Euler’s formula too.] 1 3 2 Trapezoidal Map T (S) O(n) space of a set S of n non-crossing line segments can be represented by the adjacency structure of its trapezoids. Adjacency: 1 and2 are adjacent iff they share (portion of) a vertical wall. A  has at most 2 left neighbors and at most 2 right neighbors. 1 3  2 4

  12. R bounding box p1 q1 insert s1 A C p1 s1 q1 s1 D q1 p1 R D A q2 B C s1 B A insert s2 p2 s2 I C C s1 q1 I H p1 F s2 R H E p2 s2 q2 G F A E G D(S): The Query Search Structure • It’s a rooted DAG, each node has out-degree at most 2. • Leaves (i.e., nodes of out-degree 0) store trapezoids with 2-way cross-pointers with their counter-parts in T (S). • Internal nodes are either endpoints with x-value as key (left/right comparison), or a line-segment of S (below/above comparison). TS = { s1 , s2 }D R

  13. Randomized Incremental Construction of T (S) &D(S) Input: a set S of n non-crossing line-segments in the plane. Output: T (S) & D(S). • Get a bounding box and initialize T () & D(). • Randomly permute S into (s1 , s2, … , sn). • for k  1..n do (* insert sk & update T (Sk) & D(Sk). Sk = {s1 , s2, … , sk} *) Let pk & qk be left & right ends of sk, respectively 0 Search (pk, D) ; j  0 whileqk is to the right of right(j) do if sk is below right(j) then j+1 lower-right-neighbor of j else j+1 upper-right-neighbor of j j  j+1 end-while 0 , 1, … , j are trapezoids intersected by sk. Update T (Sk) & D(Sk) accordingly (see next slide). end 0 1 3 2 qk pk sk sk

  14. Example of step 3 T (Sk) T (Sk-1) C  D A qk pk B sk D(Sk) D(Sk-1) D(Sk-1) pk  qk A sk D B C

  15. Example of step 3 T (Sk-1) T (Sk) 2 1 3 E 0 C F G A qk pk sk pk qk sk D B D(Sk) D(Sk-1) D(Sk-1) pk sk sk qk 0 1 2 3 sk sk G E A B C D F

  16. Complexities THEOREM: Randomized Incremental algorithm constructs trapezoidal map T (S) & search structure D(S) for a set S of n non-crossing line-segments with complexities: • O(log n) expected query time for any query point q. • O(n) expected size of the search structure. • O(n log n) expected construction time. • [All these expectations are on the random ordering of the segments in S.] Proof of (1):Height of D(S)  3n, since each iteration can increase height by  3. So, worst-case query time is O(n).“Fix” q and S. Define the random variable Xk # nodes added on the search path of q in D(S) during iteration k, 1k n.Expected query time for q = E[k Xk] = k E[Xk].E[Xk]  3 Pk where Pk = prob. that there is a node added to that path in iteration k.q(Sk)  the trapezoid in T(Sk) that contains q. Pk = Pr[q(Sk)  q(Sk-1)] = Pr[q(Sk)  T(Sk-1)]  4/k . [Backwards analysis: “Fix” Sk S, Any segment in Skhas prob. 1/k of being sk.T(Sk) is fixed and does not depend on the choice of sk, but T(Sk-1) does. Pr[q(Sk)  T(Sk-1)] = Prob. that sk defines bottom, top, left, or right of q(Sk). Each has prob.  1/k . Since 4/k doesn’t depend on the choice of sk, we can lift the “fix” condition.]Expected query time = k E[Xk]  k 3 Pk k 12/k  12 Hn = O(log n). This too doesn’t depend on q or S. Lift the “fix” condition.

  17. Complexities THEOREM: Randomized Incremental algorithm constructs trapezoidal map T (S) & search structure D(S) for a set S of n non-crossing line-segments with complexities: • O(log n) expected query time for any query point q. • O(n) expected size of the search structure. • O(n log n) expected construction time. • [All these expectations are on the random ordering of the segments in S.] Proof of (2): |T (S)| = O(n). k  # new trapezoids created in iteration k. |D(S)| = O(n) leaves + k ( # internal nodes created in iteration k). = O(n) + k O(k - 1) = O(n+ k k) = O(n2) worst-case. E[ |D(S)| ] = O( n + E [ k (k – 1) ] ) = O( n + k E[k ] ).Backwards analysis: Temporarily fix Sk S :

  18. Complexities THEOREM: Randomized Incremental algorithm constructs trapezoidal map T (S) & search structure D(S) for a set S of n non-crossing line-segments with complexities: • O(log n) expected query time for any query point q. • O(n) expected size of the search structure. • O(n log n) expected construction time. • [All these expectations are on the random ordering of the segments in S.] Proof of (3): O(1) + k [ O(log k) + O( E[k ] ) ] = O(k [ O(log k) + O(1)]) = O(n log n). to search in D(Sk-1) to replace the affected for the left end point trapezoids. of segment sk. This completes the proof of the Theorem.

  19. Complexities COROLLARY: S = Planar Straight-Line Subdivision with n edges. Planar point location data structure: • O(log n) expected query time for any query point q. • O(n) expected size of the search structure. • O(n log n) expected construction time. Proof:Represent S by a DCEL & construct T (S) and D(S) for edges of S. Have each trapezoid D T (S) point to the face in DCEL(S) just below top(D).

  20. y e 1 1 Shear Transform: 0 0 1 1 x 0 0 Dealing with Degeneracy What if more than one end-point in S has the same x-coordinate? How about vertical line-segments in S? … Conceptually assume e > 0 is sufficiently small.For a point p = (x,y) assume (x,y) is representing p = (x+ey , y). Properties: • No two end-points p & q of S have the same (transformed) x-coordinate. • Preserves left/right relationships: p left of q  p left of q. • Preserves point-line incidence (it is affine transformation): point p above segment s  pabove segment s. [Also holds with above replaced by on or below.]

  21. Some Facts on Probability • Markov Inequality (MI): Consider a random variable Z  0, and a fixed parameter >0. Then Proof: E[Z] = z 0z Pr[Z=z]  z az Pr[Z=z]  az aPr[Z=z] = a Pr[Za]. • Let Z = Z1 + Z2 + … + Zn , all random variables. Then, by linearity of expectation: E[Z] = E[Z1] + E[Z2] + … + E[Zn]. • Let Z = Z1  Z2  …  Zn , all random variables. Furthermore, assume that all Zk’s are Independent Random Variables (IRV). Then we have E[Z] = E[Z1]  E[Z2]  …  E[Zn].

  22. source  {2} {1} {3} {4} {1,2} {1,3} {1,4} {2,3} {2,4} {3,4} {1,2,3} {2,3,4} {1,2,4} {1,3,4} sink {1,2,3,4} A Permutation Graph G Let S = { s1, s2, … , sn} be a randomly permuted set of n segments in the plane. Consider DAG (Directed Acyclic Graph) G of subsets of S (see figure below). • n+1 layers 0,1,…,n. Each node at layer k has in-degree k and out-degree n-k. • Each source-to-sink path is in one-to-one correspondence with a permutation of S. • Each edge from subset S’ to S’  {sk} is labeled by the segment sk. • Consider a fixed query point q. • Mark every edge of G if its removal affects Dq (The trapezoid in T (S) that contains q). • Up to 4 incoming edges to each node in G is marked. • Fix a source-to-sink path P. • Xk, k=1..n, defined below, are Independent Random Variables.

  23. A Tail Estimate We showed expected query time is O(log n). Now we show the probability that the query time for a query point to be much more than O(log n) is very small. That is, the prob. that height of D(S) is much more than O(log n) is very small. LEMMA 1: Consider a parameter  > 0. Then

  24. Proof of Lemma 1 Fix a query point q and a (permutation) source-to-sink path P in G. Consider the 0/1 IRVs Xk, k=1..n. Length of the search-path for q in D(S)  3 Y, where Y = k=1..n Xk. Since this does not depend on selection of P or q, the Lemma follows.

  25. A Tail Estimate (continued) LEMMA 2: Proof: Slab-Partition of S is a more refined partition than T (S) for any permutation of S. Any 2 query points in the same trapezoid of the Slab-Partition are equivalent w.r.t. T (S) & D(S), since they follow the same search path. Slab-Partition has  2(n+1)2 trapezoids. Therefore, SlabPartition

  26. A Tail Estimate (continued) LEMMA 2: Example: For n > 4, take l=20  Pr[ height D(S)  3l ln (n+1) ]  1/4  Pr[ height D(S)  3l ln (n+1) ]  1 - ¼ = 3/4 . This is worst-case expected query time.Similar results for, space and construction time:  Pr[ Query Time & Const. Time & Space are good]  1- ( ¼ + ¼ + ¼ ) = 1/4. THEOREM: One can construct a point-location query data structure with • O(n log n) expected construction time, & • O(n) worst-case space, & • O(log n) worst-case query time. Proof: Run (the truncated version of) the randomized incremental algorithm until it succeeds. Expected number of runs  4.

  27. Triangulation Refinement Method MAIN IDEAS: • Starting from initial triangulation of the PSLG, iteratively find coarser triangulations, by removing fractions of independent vertices of low degree, then re-triangulate. • Maintain the history DAG of the overlaps which becomes the search structure. • For point location, start from the coarsest subdivision and walk through thehistory DAG to more refined triangulations, until down to the complete triangulation of the PSLG. APPLICATIONS: • [O’Ro’98, section 7.6]: Planar Point Location, • [O’Ro98, section 7.5] Given a 3D convex polytope: • Is a given query point inside P? • Find extreme vertex of P in a given direction. • …

  28. PSLG Triangulation Worst-case Optimal: O(n log n) time and O(n) space. y x

  29. PSLG Triangulation Worst-case Optimal: O(n log n) time and O(n) space. Step 1: Trapezoidal Decomposition [O(n log n) time, O(n) space] y x

  30. PSLG Triangulation Worst-case Optimal: O(n log n) time and O(n) space. Step 1: Trapezoidal Decomposition [O(n log n) time, O(n) space] Step 2: Add supporting diagonal of trapezoids [O(n) time & space] y x

  31. PSLG Triangulation Worst-case Optimal: O(n log n) time and O(n) space. Step 1: Trapezoidal Decomposition [O(n log n) time, O(n) space] Step 2: Add supporting diagonal of trapezoids [O(n) time & space] Step 3: Remove vertical visibility chords (now each region is x-monotone) [O(n) time&space] y x

  32. PSLG Triangulation Worst-case Optimal: O(n log n) time and O(n) space. Step 1: Trapezoidal Decomposition [O(n log n) time, O(n) space] Step 2: Add supporting diagonal of trapezoids [O(n) time & space] Step 3: Remove vertical visibility chords (now each region is x-monotone) [O(n) time&space] Step 4: Triangulate each x-monotone region (including introduction of convex-hull edges) [O(n) time & space] y x

  33. Triangulation Refinement Algorithm Input: Triangulated PSLG G=(V,E) with possibly unbounded edges. |V|=n, |E|3n-6. Complexity: O(n) time & space G

  34. Triangulation Refinement Algorithm Input: Triangulated PSLG G=(V,E) with possibly unbounded edges. |V|=n, |E|3n-6. Complexity: O(n) time & space Step 1: Inscribe vertices of G in a bounding triangle T=(W1, W2, W3) (sufficiently large). W3 T G W2 W1

  35. Triangulation Refinement Algorithm Input: Triangulated PSLG G=(V,E) with possibly unbounded edges. |V|=n, |E|3n-6. Complexity: O(n) time & space Step 1: Inscribe vertices of G in a bounding triangle T=(W1, W2, W3) (sufficiently large). Step 2: New vertices = intersection of unbounded edges of G with T. Re-triangulate. m = # vertices  |V|+|T|+|E|  n + 3 + 3n-6 = O(n). # edges = O(m) = O(n). W3 T G W2 W1

  36. Triangulation Refinement Algorithm Input: Triangulated PSLG G=(V,E) with possibly unbounded edges. |V|=n, |E|3n-6. Complexity: O(n) time & space Step 1: Inscribe vertices of G in a bounding triangle T=(W1, W2, W3) (sufficiently large). Step 2: New vertices = intersection of unbounded edges of G with T. Re-triangulate. m = # vertices  |V|+|T|+|E|  n + 3 + 3n-6 = O(n). # edges = O(m) = O(n). Step 3: Generate the triangulation refinement sequence (T1 , T2 , … , Th(n) ), where h(n) = O(log n). [see next slides] W3 T G W2 W1

  37. Step 3: Triangulation Refinement Idea W2 T1 W3 W2 T2 W3 W2 T3 W3 11 11 1 8 12 14 19 2 9 4 13 3 15 10 18 17 7 5 5 6 16 W1 W1 W1 T4 W3 W2 20 2 3 4 5 6 7 8 9 10 11 W1 1 12 13 14 15 16 Hierarchical (history) DAGO(n) nodesnode out-degrees = O(1) Depth = O(log n) 19 17 18 20

  38. Step 3: Triangulation Refinement Algorithm Step 3: Sequence (T1 , T2 , … , Th(n) ) of coarser-&-coarser triangulations, h(n) = O(log n). v(Tk) = # vertices of Tk.  constant 0 <  < 1 s.t. v(Tk+1)   v(Tk)  h(n) =O(log1/a n) = O(log n).How to get from Tk to Tk+1 : • Tk: S {degree(v) | v Tk} = 2  # edges of Tk  6 v(Tk) –12  average node degree < 6  in Tk  at least v(Tk)/2 vertices of degree  2  average < 12 • D12  vertices of degree  12 in Tk (excluding W1, W2, W3) Q  while D12   do v  a vertex in D12 add v to Q remove v and all its adjacent vertices from D12 (at most 13 including v) • |Q|  | D12 | / 13  |Q|  |v(Tk)| / 26 • Q is an independent set of vertices in Tk (i.e., no two are adjacent). • Tk+1  Tk+1 - Q (and re-triangulate it , see next slide) • v(Tk+1)   v(Tk) where a = 25/26.

  39. Step 3: Triangulation Refinement Algorithm v(Tk+1)   v(Tk) where a = 25/26 v(T1) = O(n)  v(Tk) = O(n ak) Total # vertices in T1 , T2 , … , Th(n) = O(n + n a + n a2 + n a3 + … ) = O(n) remove v& re-triangulate the induced hole v A star polygon can be re-triangulated in linear time.

  40. Triangulation Refinement Algorithm Query Answering:O(log n) time • locate the query point q in a face (triangle) of Th(n). • for i  h(n) – 1 downto 1 do using the history DAG go from face of Tk+1 to face of Tk containing q • report located face of T1 that contains q.

  41. Edelsbrunner et al. Algorithm Planar Point Location for Monotone Subdivisions • O(n) Preprocessing Time • O(n) Storage Space • O(log n) query Time R10 R11 R5 R9 R4 y R3 R2 R8 R7 x R1 R6 R0 A B

  42. Edelsbrunner et al. Algorithm R10 R11 R5 R9 R4 R3 R2 R8 R7 R1 Separator s8 R6 R0 Chain Tree: Sk’s internal nodes, Rk’s leaves

  43. Edelsbrunner et al. Algorithm Naïve implementation: • O(n2) time • O(n2) space [lot of overlap between chains] • O(log2 n) query time [O(log n) levels, O(log n) at each node on search path] Improvement (see chapter 11 of [Ede87]): • O(n) time [for monotone subdivision] • O(n) space • O(log n) query time Ideas used: • Layered DAG [Edelsbrunner, Guibas, Stolfi, SICOMP’86, pp:317-340] • Fractional Cascading [Chazelle, Guibas, Algorithmica’86 ] • Filtering Search [Chazelle, SICOMP’86, pp:703-724.]

  44. Line Segments Intersections:Randomized Incremental Method Input: A set S of n line segments in the plane. Output: Report all pairs of intersecting segments in S in expected O(K + n log n) time, where K = # of intersecting pairs in S. Solution: • Bentley-Ottman’s deterministic algorithm takes O(K log n + n log n) time. So, that’s not the right answer. • Construct the trapezoidal decomposition by a randomized incremental method.

  45. No History DAG used for point location. Instead, start the initial trapezoidal decomposition by inserting the 2n end-points of the line segments. We can obtain this initial structure by sorting in O(n log n) time. Suppose R is the random subset of r segments out of the n input segments we have inserted so far. Let s be the latest segment added to R’ = R - {s} to get R. s

  46. Insert s into R’: start from the trapezoid containing the leftmost end of s and thread s left-to-right through the current trapezoidal decomposition. - Which wall of the current trapezoid will you exit from? - What is the next trapezoid you will enter? - Easy if you enter through a vertical wall. The entering face has at most 6 edges to be checked. - What if you go through a segment intersection? You may need to check more than O(1) sub-division edges.- What can you do? Answer: Use the planar sub-division shown in the right figure.

  47. Expected cost of this insertion over the random choice of s (looking backwards) is where the 2nd sum is over all zero-width faces f of the current planar sub-division,and KR is the number of intersecting pairs of segments in R. Insertion cost of segment s into R’ to get R = R’{s} is cost(s, R) = O( total size of the red shaded zero-width faces).

  48. So, expected insertion cost for R = R’  {s} is • Let {a,b} be an intersecting pair of segments among the n input segments.The probability that {a,b} will show up in R is • So, expected value of KR is This depends only on the input and the iteration number r, but is independent of R. • So, expected cost of the rth iteration is • Total expected cost over the n iterations is R itself is a random subset of r input segments. What is the expected value of KR?

  49. Exercises

  50. Show that query point location can be done in linear time on a planar subdivision without preprocessing. That is, given DCEL of a PSLG S of size n and a query point q, the face of S containing q can be found in O(n) time. [ Note: we don’t have a point location data structure.] • Given a set P of n pointsin the plane, we define a subdivision of the plane into rectangular regions by the following rule. We assume that all the points are contained within a bounding rectangle. Imagine that the points are sorted in increasing order of y-coordinate. For each point in this order, shoot a bullet to the left, to the right and up until it hits an existing segment, and then add these three bullet-path segments to the subdivision. (See the figure below left for an example.) (a) Show that the resulting subdivision has size O(n) (including vertices, edges, and faces).(b) Describe an algorithm to add a new point to the subdivision and restore the proper subdivision structure. Note that the new point may have an arbitrary y-coordinate, but the subdivision must be updated as if the points were inserted in increasing order of y-coordinate. (See the figure above center and right.) (c) Prove that if the points are added in random order, then the expected number of structural changes to the subdivision with each insertion is O(1).

More Related