Presentation is loading. Please wait.

Presentation is loading. Please wait.

Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.

Similar presentations


Presentation on theme: "Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für."— Presentation transcript:

1 Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für Angewandte Wissenschaften Albert-Ludwigs-Universität Freiburg

2 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann2 Overview Trapezoidal decomposition A search structure Randomized, incremental algorithm for the construction of the trapezoidal decomposition Analysis Planar point location with persistent structures

3 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann3 Point Location in a Map

4 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann4 Partitioning of the Plane into Slabs Query time : O(log n) binary search in x and then binary search in y direction. Storage space O(n 2 ) n/2

5 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann5 Paritioning into Trapezoids Assumption : Segments are in “general position“ Observation : Every vertical edge has one point in common with a segment end. R

6 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann6 Observations R f f is convex f is bounded Every non - vertical side of f is part of a segment of S or an edge of R

7 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann7 Trapezoidal Decomposition Lemma : Each face in a trapezoidal map of a set S of line segments in general position has 1 or 2 vertical sides and exactly two non-vertical sides

8 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann8 Left Edge of a Trapezoid R For every trapezoid Δ  T(S), except the left most one, the left vertical edge of Δ is defined by a segment endpoint p, denoted by leftp(Δ).

9 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann9 The 5 Cases: Left Edges of a Trapezoid a) top(  ) bottom(  ) leftp(  ) b) leftp(  ) top(  ) d) leftp(  ) top(  ) c) leftp(  ) top(  ) bottom(  ) e) It is left edge of R. This case occurs for a single trapezoid of T(S) only, namely the unique leftmost trapezoid of T(S)

10 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann10 Size of the Trapezoidal Map Theorem: The trapezoidal map T(S) of a set of n line segments in general position contains at most 6n + 4 vertices and at most 3n + 1 trapezoids. Proof (1):A vertex of T(S) is either - a vertex of R or 4 - an endpoint of a segment in S or 2n - a point where the vertical extension starting in an endpoint abuts on another segment or on the boundary R. 2 * (2n) 6n + 4

11 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann11 Size of the Trapezoidal Map Theorem: The trapezoidal map T(S) of a set of n line segments in general position contains at most 6n + 4 vertices and at most 3n + 1 trapezoids. Proof (2): Each trapezoid has a unique point leftp(  ), which is - the lower left corner of R - the left endpoint of a segment (can be leftp(  ) of at most two different trapezoids) - the right endpoint of a segment (can be leftp(  ) of atmost one trapezoid) 1 2n n 3n + 1

12 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann12 Adjacent Trapezoids Two trapezoids  and  ´ are adjacent if they meet along a vertical edge.  11 22 33 44 55  11 22 33 44 55 66 1)Segments in general position : A trapezoid has atmost four adjacent trapezoids 2) Segments not in general position : A trapezoid can have an arbitrary number of adjacent trapezoids.

13 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann13 Vertical Neighbours: Upper, Lower Left Trapezoid  ' is (vertical) neighbor of  top(  ) = top(  ’) or bottom(  ) = bottom(  ’) In the first case  ´ is upper left neighbor of , in the second case  ´ is lower left neighbor of .

14 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann14 Representing Trapezoidal Maps There are records for all line segments and endpoints of S, the structure contains records for trapezoids of T(S), but not for vertices or edges of T(S). The record for trapezoid  stores pointers to top(  ), and bottom(  ), pointers to leftp(  ) and rightp(  ) and finally pointers to its atmost 4 neighbors.  is uniquely defined by top(  ), bottom(  ), leftp(  ) and rightp(  ).

15 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann15 A Search Structure A B C D F E G 1l 1r 2l 2r A B C D E F G 1l 1r 2r 2l 1 2 2 End points decide between left, right Segments decide between below, above

16 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann16 Example: Search Structure A B C D F E G 1l 1r 2l 2r

17 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann17 A Randomized Incremental Algorithm Input : A set S of n non-crossing line segments Output : The trapezoidal map T(S) and a search structure D(S) for T(S) in a bounding box. Determine a bounding box R, initialize T and D Compute a random permutation s 1,s 2,..., s n of the elements of S for i = 1 to n do add s i and change T(S i - 1 ) into T(S i ) and D(S i -1 ) into D(S i ) Invariant : In the step i T(S i ) is correct trapezoidal map of S i and D(S i ) is an associated search structure.

18 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann18 A Randomized Incremental Algorithm Input : A set of n non-crossing line segments Output : The trapezoidal map T(S) and a search structure D for T(S) in a bounding box. Determine a bounding box R, initialize T and D Compute a random permutation s 1,s 2,..., s n of the elements of S for i = 1 to n do Find the set  0,  1,...,  k of trapezoids in T properly intersected by s i. Remove  0,  1,...,  k from T and replace them by new trapezoids that appear because of the intersection of s i. Remove the leaves for  0,  1,...,  k from D and create leaves for the new Trapezoids. Link the new leaves to the existing inner nodes by adding some new inner nodes.

19 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann19 Questions How can we find the intersecting trapezoids? How can T and D be updated a) if new segment intersects no previous trapezoid b) if new segment intersects previous trapezoids

20 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann20 Finding the Intersecting Trapezoids 00 sisi 11 22 33  j+1 is lower right neighbour of  j In T(S i ) exactly those trapezoids are changed, which are intersected by s i if rightp(  j ) lies above s i then Let  j+1 be the lower right neighbor of  j. else Let  j+1 be the upper right neighbor of  j Clue :  0 can be found by a query in the search structure D(S i -1 ) constructed in iteration stage i -1.

21 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann21 New Segment Completely Contained in Trapezoid Decomposition t p q s T(S i-1 ) A C B D T(S i ) Search structure D(S i-1 ) t A B CD p q s 4 new trapezoids, -1 old trapezoid, search depth + 3

22 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann22 New Segment Intersects Previous Ones Decomposition p q t0 t1 t2 t3 s T(S i - 1 ) t0t1t2t3 D(S i - 1 ) Search structure F A B C E D T(S i ) D(S i ) A B C D E F sssq s 6 new trapezoids, – 4 old, depth + 2

23 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann23 Estimation of the Depth of the Search Structure Let S be a set of n segments in general position, q be an arbitrary fixed query point. Depth of D(S): worst case : 3n, average case : O(log n) Consider the path traversed by the query for q in D Let X i = # of nodes on the search path for q created in iteration step i. X i <= 3 P i = probability that there exists node on the search path for q that is created in iteration step i. E[X i ] <= 3 P i

24 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann24 Observation Iteration step i contributes a node to the search path for q exactly if  q (S i - 1 ), the trapezoid containing q in T(S i - 1 ), is not the same as  q (S i ), the trapezoid containing q in T(S i ) P i = Pr[  q (S i )   q (S i - 1 )]. If  q (S i ) is not same as  q (S i - 1 ), then  q (S i ) must be one of the trapezoids created in iteration i.  q (S i ) does not depend on the order in which the segments in S i have been inserted. Backwards analysis : We consider T(S i ) and look at the probability that  q (S i ) disappears from the trapezoidal map when we remove the segment s i.  q (S i ) disappears if and only if one of top(  q (S i )), bottom(  q (S i )), leftp(  q (S i )), or right(  q (S i )) disappears with removal of s i.

25 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann25 Observation Prob[top(  q (S i ))] = Prob[bottom(  q (S i ))] = 1/i. Prob[leftp(  q (S i ))] disappears is at most 1/i. Prob[rightp(  q (S i ))] disappears is at most 1/i. P i = Pr[  q (S i )   q (S i - 1 )] = Pr[  q (S i )  T(S i - 1 )] <= 4/i

26 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann26 Analysis: Size of Search Structure Leaves in D are in one – to – one correspondence with the trapezoids in , of which there are O(n). The total number of nodes is bounded by : (# of inner nodes created in iteration step i) The worst case upper bound on the size of the structure

27 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann27 Analysis: Size of Search Structure Theorem: The expected number of nodes of D is O(n). Proof: The # of leaves is in O(n). Consider the internal nodes: X i = # of internal nodes created in iteration step i if  disappears from T(S i ) when s is removed from S i otherwise There are at most four segments that cause a given trapezoid to disappear

28 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann28 Analysis: Size of Search Structure The expected number of newly created trapezoids is O(1) in every iteration of the algorithm, from which the O(n) bound on the expected amount of storage follows.

29 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann29 Summary Let S be a planar subdivision with n edges. In O(n log n) expected time one can construct a data structure that uses O(n) expected storage, such that for any query point q, the expected time for a point location query is O(log n).

30 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann30 Planar Point Location and Persistence A structure is ephemeral, if there are no mechanisms to revert to previous states. A structure is called persistent, if it supports access to multiple versions. Partially Persistent: All versions can be accessed, but only the newest version can be modified. Fully Persistent: All versions can be accessed and modified. Oblivious: The data structure yields no knowledge about the sequence of operations that have been applied to it, other than the final result of the operation.

31 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann31 Planar point location - example

32 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann32 Planar Point Location: Sarnak-Tarjan Solution Idea: (partial) persistence –Query time: O(log n), Space: O(n) –Relies on Dobkin-Lipton construction and Cole’s observation. Dobkin-Lipton: –Partition the plane into vertical slabs by drawing a vertical line through each endpoint. –Within each slab, the lines are totally ordered. –Allocate a search tree per slab containing the lines, and with each line associate the polygon above it. –Allocate another search tree on the x-coordinates of the vertical lines.

33 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann33 Dobkin-Lipton Construction Partition the plane into vertical slabs.

34 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann34 Dobkin-Lipton Construction Locate a point with two binary searches. Query time: O(log n). Nice but space inefficient! Can cause O(n 2 ).

35 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann35 Worst-Case Example Θ(n) segments in each slabs, and Θ(n) slabs.

36 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann36 Cole’s Observation A B Sets of line segments intersecting contiguous slabs are similar. Reduces the problem to storing a “persistent” sorted set.

37 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann37 Improving the Space Bound Create the search tree for the first slab. Then obtain the next one by deleting the lines that end at the corresponding vertex and adding the lines that start at that vertex. Total number of insertions / deletions: –2n –One insertion and one deletion per segment.

38 Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann38 Planar Point Location and Persistence Updates should be persistent (since we need all search trees at the end). Partial persistence is enough (Sarnak and Tarjan). Method 1: Path-copying method; simple and powerful (Driscoll et al., Overmars). –O(n log n) space + O(n log n) preprocessing time. Method 2: Node-copying method –We can improve the space bound to O(n).


Download ppt "Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für."

Similar presentations


Ads by Google