Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Point Location Strategies Idit Haran 13.4.2005.

Similar presentations


Presentation on theme: "1 Point Location Strategies Idit Haran 13.4.2005."— Presentation transcript:

1 1 Point Location Strategies Idit Haran 13.4.2005

2 2 Outline Problem Description Other strategies Our strategy - Landmarks Benchmark Working with conic arrangements and some number theory Future work Summary

3 3 Point Location – Problem Description INPUTOUTPUT Given A map (which divides space of interest into regions) A query point q (specified by coordinates) Find the region of the map containing q Requirement: (segments/conics)  Fast query  Reasonable preprocess time  Good data structure (small space)

4 4 Other Strategies Strategies implemented in CGAL: Na ï ve Walk along line Random Incremental Algorithm (Trapezoidal) Triangulation Other strategies: Persistent search trees

5 5 Na ï ve Approach (CGAL) No need for any preprocess, just go over all elements and find the closest Idea No preprocess. Storage space = 0. Preprocess & memory Go over all vertices, and check if q equals a vertex Go over all halfedges and check if q is on edge Go over all halfedges and find the closest edge upwards. O(n) query time Query

6 6 Walk Along a Line start from a known place in the arrangement and walk from there towards the query point through a straight line Idea No preprocess. Storage space = 0. Preprocess & memory The implementation in CGAL: Start from the unbounded face Walk down to the point in through a vertical line Asymptotically O(n) time In practice: quite good, easy to maintain Query q

7 7 Random Incremental Algorithm (Trapezoidal) Use hierarchy data structure that allows a logarithmic query time Idea Add the segments one by one randomly. For each segment: Update the trapezoidal map. Update the DAG. O(n·logn) time, O(n) space Preprocess & memory Search for the trapezoid in the DAG O(log n) time, if the segments were added randomly Query

8 8 Vertical Decomposition Assume a bounding box. Extend the vertical line from each vertex upward and downward, until it touches another segment.

9 9 Trapezoidal Maps Contains triangles and trapezoids. Each trapezoid or triangle is determined by two vertices and two segments. A refinement of the original subdivision.

10 10 Trapezoidal Maps Theorem: In a trapezoidal map of n segments, there are at most 6n+4 vertices, and at most 3n+1 faces. Proof: Vertices: 2n – original vertices 4n – 2 extensions for each original vertex. 4 – Vertices of the bounding box. Total: 6n+4 Faces: Similar

11 11 Trapezoidal Map Data Structure For each Trapezoid store: The vertices that define its right and left sides. The (up to two) neighboring trapezoids on right and left. (Optional) The neighboring trapezoids from above and below. This number might be linear, so we store only the leftmost of these.

12 12 The DAG Search Structure Q1Q1 P1P1 Q2Q2 P3P3 S3S3 B C S1S1 P2P2 A S3S3 S2S2 DEFGD H Q3Q3 S2S2 S3S3 JK B A C D E F H G J K P1P1 P2P2 P3P3 Q1Q1 Q2Q2 Q3Q3 S1S1 S3S3 S2S2 DAG = Directed Acyclic Graph

13 13 K Q1Q1 P1P1 Q2Q2 P3P3 S3S3 B C S1S1 P2P2 A S3S3 S2S2 DEFGDH Q3Q3 S2S2 S3S3 J B A C D E F H G J K P1P1 P2P2 P3P3 Q1Q1 Q2Q2 Q3Q3 S1S1 S3S3 S2S2 Using the DAG Search Structure

14 14 Triangulation Use a working algorithm on triangulation and test it on the arrangement (only segments !) (triangles are much simpler than faces) Idea Triangulate the planar map O(n·logn) time, O(n) space Keep relations between planar map vertices and triangulation Preprocess & memory Find the triangle q is located in The locate is done by walk from an arbitrary vertex. They claim that it takes time O(n) in the worst case, but only O(sqrt(n)) on average if the vertices are distributed uniformly at random. Find the face in the arrangement that contains this triangle Query

15 15 Persistent Search Trees (Sarnak-Tarjan) Divide the arrangement into slabs, like in sweep, and use logarithmic search Idea Draw a vertical line through each vertex, splitting the plane into vertical slabs. Observations: sets of line segments intersecting - contiguous slabs are similar. Reduces the problem to storing a “ persistent ” sorted set. O(n · log n) time, O(n · log n) space Preprocess & memory Find the slab Find the two segment above and below q O(log n) time. Query AB

16 16 Other Strategies - Summary PersistentTriangleRICWalkNa ï ve O(n·logn) O(n) O(n·logn) O(n) none Preprocess & memory O(logn)O(sqrt(n)) – O(n) O(logn) < O(n) O(n) Query Good locate time Quite good locate time Good locate timeSimple and reasonable query time Simple Benefits Long preprocess, large memory Long preprocess Complicated data structure, bugs, long preprocess, Very large memory needs Query time not good enough Bad query time Drawbacks More Algorithms on Delaunay Triangulations: The Delaunay Hierarchy, Jump & Walk

17 17 Point location using Landmarks Special points, “ landmarks ” are stored in a nearest neighbor search structure (e.g., kd-trees). During query time, “ walk ” from the landmarks towards the query point. Idea Choose the landmarks, and locate them in the arrangement. Store the landmarks in a nearest neighbor search structure. Preprocess Given a query point q, find the closest landmark l to the query point q, using the search structure. “ walk ” from l to q. Query q l

18 18 Choosing the Landmarks Number of landmarks Distribution of the landmarks in the arrangement: Geometric entities of the arrangement: Vertices Edge Midpoints Points inside the faces: Preprocess the arrangement into trapezoids and triangles Independent of the arrangement geometry: Random Grid q l q l

19 19 Quality of the landmarks – Arrangement Distance (AD) The Arrangement Distance (AD) between two points is the number pf faces in which the straight line segment that connect these points passes. Arrangement Distance ≠ Euclidean Distance p v v p AD = 0AD = 4

20 20 Nearest Neighbor Search Structure Input: Landmarks Query point q Question: Find nearest landmark l to the query point q Answer: Voronoi? - Again, point location problem !

21 21 Kd-trees 4 7 6 5 1 3 2 9 8 10 11 l5l5 l1l1 l9l9 l6l6 l3l3 l 10 l7l7 l4l4 l8l8 l2l2 l1l1 l8l8 1 l2l2 l3l3 l4l4 l5l5 l7l7 l6l6 l9l9 3 25411 910 8 67 The kd-tree is a powerful data structure that is based on recursively subdividing a set of points with alternating axis-aligned hyper-planes.

22 22 Kd-trees - Construction 4 7 6 5 1 3 2 9 8 10 11 l5l5 l1l1 l9l9 l6l6 l3l3 l 10 l7l7 l4l4 l8l8 l2l2 l1l1 l8l8 1 l2l2 l3l3 l4l4 l5l5 l7l7 l6l6 l9l9 3 25411 910 8 67

23 23 4 7 6 5 1 3 2 9 8 10 11 l5l5 l1l1 l9l9 l6l6 l3l3 l 10 l7l7 l4l4 l8l8 l2l2 l1l1 l8l8 1 l2l2 l3l3 l4l4 l5l5 l7l7 l6l6 l9l9 3 25411 910 8 67 q Kd-trees - Query

24 24 Using Kd-trees with the landmarks Quick: Approximate nearest neighbor Operations on points only Round all points to double – Inexact computation. Final result is always exact !

25 25 Landmarks point location – Query Find Nearest Landmark Decide on Startup Face Cross to Next Face Query Point Located Is query point in face ? Yes No Walk

26 26 Landmarks point location – Query Find Nearest Landmark Decide on Startup Face Cross to Next Face Query Point Located Is query point in face ? Yes No Walk Decide on startup face: From vertex: Check all incident face to the vertex, and find the face in q ’ s direction. From Edge: Choose between the two incident face to the edge. From Face: This is the startup face. q l q l q l

27 27 Landmarks point location – Query Find Nearest Landmark Decide on Startup Face Cross to Next Face Query Point Located Is query point in face ? Yes No Walk Is query point in face? Count the number of edges on f ’ s boundary that are above q. Odd – q is inside f – found ! Even – need to cross to the next face. q

28 28 Landmarks point location – Query Find Nearest Landmark Decide on Startup Face Cross to Next Face Query Point Located Is query point in face ? Yes No Walk Cross to next face: Create a segment s from the landmark l to the query point q find the edge e in f that intersects s flip e to get a new face f ’. check if q is in f ’… e f q l f’ s

29 29 Benchmark Categories: Query & Preprocess time Algorithms: Na ï ve, Walk, Triangle, RIC, 2 variants of landmarks algorithm. Arrangements: random and degenerate. similar results. RandomOnebig

30 30 Landmarks (random) Landmarks (vertices) RICTriangleWalkNaïveNumber of Original Segments Number of Edges 0.130.200.050.20.310.281035 0.230.310.201.73.98.91002301 0.240.320.263.68.730.72009548 0.260.350.338.624.3163.450056070 0.260.35N/A12.0735.1329.6700114303 0.270.36N/A18.1450.5685.71000235553 Benchmark: Query Arrangements of random line segments Time in milliseconds

31 31 Algorithm Specific PreprocessCommon Preprocessing: Constructing the Arrangement Number of Original Segments Number of Edges Landmarks (random) Landmarks (vertices) RICTriangle 0.03<0.0010.0160.0360.0041035 2.3<0.0014.04111.21002301 10<0.00120805.42009548 68<0.0011539903050056070 1661N/A146331700114303 3522N/A7984651000235553 Benchmark: Preprocess Arrangements of random line segments Time in seconds Na ï ve and Walk algorithms do not require any specific preprocessing besides constructing the arrangement

32 32 % Queries with AD = 0 Query Time [msec] Net Preprocessing Time [sec] Total Preprocessing Time [sec] Number of Random Landmarks 2.93.950.172.810 14.21.410.272.9100 30.90.550.573.31,000 53.00.333.57610,000 73.90.26179050,000 82.00.2234106100,000 87.70.21169242500,000 Landmarks Algorithm Analysis Results on an arrangement of 500 original segments, include ~56,000 edges and ~28,000 vertices Algorithm performance for varying number of random landmarks

33 33 % Queries with AD = 0 Query Time [msec] Net Preprocessing Time [sec] Total Preprocessing Time [sec] Number of Landmarks Landmarks Type 92.70.320.672.828,000Vertices (V) 96.60.271.874.757,000Edge Midpoints (EM) 97.60.271.974.585,000V + EM 73.90.261790.050,000Random 77.50.2416.789.350,000Uniform Grid Landmarks Algorithm Analysis Algorithm performance vs. the type of landmarks used p v q l

34 34 Landmarks Algorithm Analysis

35 35 Conics Differences from segments Bench results Problems invoked, and their solutions Cross to next face The chord method Number type theory

36 36 Conics – differences from segments More complex curves (every operator on the curves takes longer) Working with irrational number types Basically the same methods work (except triangle)

37 37 Benchmark: Query Arrangements of random conic arcs Time in seconds Landmarks (random) Landmarks (vertices) RICWalkNaïveNumber of Original Conics Number of Edges 0.100.250.040.30.21026 0.140.360.070.70.42072 0.170.450.111.60.940192 0.160.510.153.51.560430 0.150.620.28.53.41001000 0.110.690.428.89.82007554 0.120.720.3571.429.640026160

38 38 Conics - Cross to Next Face Find exact intersection point – a complex operation on conics ! Instead – use a simple method to decide what edge to flip. The idea: check vertical order on the left and right boundaries of the common x-range. l q s e x-range l q e s L q e s L q e s l q e s (a) (b) (c)

39 39 What ’ s the problem with the vertices in an arrangement of conic arcs ? v Problem 1: vertex may be complex irrational number (algebraic with degree 4) Problem 2: finding the intersection between vp and other curves p v’ v’ Properties:  Rational  On the conic  Close to the v The chord method: given a rationl point r on the conic, we can use the chord method to find v’ r

40 40 The Chord Method Given: Unit circle equation: x 2 + y 2 = 1 The point (-1,0) is on the circle Find: Rational point v’ close to v Solution: Every line passing through this point is: y = t(x+1) where t is the slope of the line. solve x 2 + (t(x+1)) 2 = 1 (-1,0) y=t(x+1) x 2 +y 2 =1 v

41 41 One Rational Point Apparently, not all conics with rational (or even integer) coefficients have rational points on them For example, the circle x 2 + y 2 = 3 does not have any rational points on it.

42 42 Change the equation into homogenic coordinates: A: r x 2 + s y 2 + t xy + u x + v y + w = 0 ⇓ (x→x/z, y→y/z) B: r x 2 + s y 2 + t xy + u xz + v yz + wz 2 = 0 (Rational solution to A ⇔ Integer solution to B) Theory 1: if there is a solution for every congruence modulo p k for every prime p and every k, then there is a solution. Theory 2: Check only p=2 and p ’ s that divide the determinant of the equation coefficients. It is also sufficient to check only for k <= 3 + the largest exponent in the determinant factorization. Does a conic have rational solution? 3 Variables

43 43 How to find a rational solution (if there is one) Theorem : if a conic equation has an integer solution, then the size of the solution  (3F), where F is the sum of the absolute value of the coefficients.

44 44 What to do in practice? Change the equation into homogenic coordinates Go over all small p k and check if there is a solution modulo p k. One NO – no solution. All Yes – search for pairs (x,y) so that |x|<3F, |y|<3F check whether z is also an integer. YES – we found a solution. All NO – there is no solution. Complexity: (3F) 2

45 45 If there are no rational points on the conic? Euclid ’ s algorithm to approximate real number x into rational number r : x = a 0 + 1/x 1, x 1 >1, a 0 - integer x 1 = a 1 + 1/x 2, x 2 >1, a 1 - interger … Finally, r = a 0 + 1/(a 1 + (1/ (a 2 + ….) ) ) = p n /q n. If x is irrational, and the algorithm ends after n stages, then: | x - p n /q n | < 1/q n 2

46 46 How to find  ?  = the approximation value. should stay “ close ” to the vertex. 1.Find the minimum distance between v and other vertices. or 2.Find the minimum distance to all edges/vertices in the adjacent faces to the vertex.

47 47 Landmarks – future work Rationalization of the vertices More types of landmarks: Combination of different landmarks types Memory usage of the algorithms Halton sequence Hammersley Points

48 48 Summary Point location using landmarks – Fast query Efficient preprocess, using inexact computation Low memory Simple to understand and implement Many ways to improvements: different search structure, other choice of points


Download ppt "1 Point Location Strategies Idit Haran 13.4.2005."

Similar presentations


Ads by Google