1
Point Location Strategies
Idit Haran13.4.2005
2
Outline Problem Description Other strategies Our strategy - Landmarks Benchmark Working with conic arrangements
and some number theory Future work Summary
3
Point Location – Problem Description
INPUT OUTPUT
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
Other Strategies Strategies implemented in CGAL:
Naïve Walk along line Random Incremental Algorithm
(Trapezoidal) Triangulation
Other strategies: Persistent search trees
5
Naïve Approach (CGAL) Idea No need for any preprocess, just go over all
elements and find the closestPreprocess& memory
No preprocess.Storage space = 0.
Query Go over all vertices, and check if q equals a vertexGo over all halfedges and check if q is on edgeGo over all halfedges and find the closest edge upwards.O(n) query time
6
Walk Along a Line Idea start from a known place in the arrangement and
walk from there towards the query point through a straight line
Preprocess& memory
No preprocess.Storage space = 0.
Query The implementation in CGAL: Start from the unbounded face Walk down to the point in through a vertical lineAsymptotically O(n) time In practice: quite good, easy to maintain
q
7
Random Incremental Algorithm (Trapezoidal)
Idea Use hierarchy data structure that allows a logarithmic query time
Preprocess& memory
Add the segments one by one randomly. For each segment:
Update the trapezoidal map. Update the DAG.
O(n·logn) time, O(n) space
Query Search for the trapezoid in the DAG O(log n) time, if the segments were added randomly
8
Vertical Decomposition Assume a bounding box. Extend the vertical line from each
vertex upward and downward, until it touches another segment.
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
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
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
The DAG Search StructureQ1
P1 Q2
P3
S3
B
C
S1
P2
A
S3 S2
D E F G D H
Q3
S2 S3
J K
BA
C
D
E
F
H
G
J K
P1
P2
P3
Q1
Q2
Q3
S1
S3
S2
DAG = Directed Acyclic Graph
13
K
Q1
P1 Q2
P3
S3
B
C
S1
P2
A
S3 S2
D E F G D H
Q3
S2 S3
J
BA
C
D
E
F
H
G
J K
P1
P2
P3
Q1
Q2
Q3
S1
S3
S2
Using the DAG Search Structure
14
TriangulationIdea Use a working algorithm on triangulation and test
it on the arrangement (only segments !)(triangles are much simpler than faces)
Preprocess& memory
Triangulate the planar map O(n·logn) time, O(n) space Keep relations between planar map vertices and triangulation
Query 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
15
Persistent Search Trees (Sarnak-Tarjan)
Idea Divide the arrangement into slabs, like in sweep, and use logarithmic search
Preprocess& memory
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
Query Find the slab Find the two segment above and below q O(log n) time.
AABB
16
Other Strategies - SummaryNaïve Walk RIC Triangle Persiste
ntPreprocess & memory
none none O(n·logn) O(n)
O(n·logn) O(n)
O(n·logn) O(n)
Query O(n) < O(n) O(logn) O(sqrt(n)) – O(n)
O(logn)
Benefits Simple Simple and reasonable query time
Good locate time
Quite good locate time
Good locate time
Drawbacks
Bad query time
Query time not good enough
Complicated data structure, bugs, long preprocess, Very large memory needs
Long preprocess
Long preprocess, large memoryMore Algorithms on Delaunay Triangulations: The Delaunay Hierarchy, Jump &
Walk
17
Point location using Landmarks
Idea 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.
Preprocess Choose the landmarks, and locate them in the arrangement. Store the landmarks in a nearest neighbor search structure.
Query Given a query point q, find the closest landmark to the query point q, using the search structure.“walk” from to q.
q
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
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
pv
v
p
AD = 0
AD = 4
20
Nearest Neighbor Search Structure
Input: Landmarks Query point q
Question: Find nearest landmark to
the query point q Answer:
Voronoi? - Again, point location problem !
21
Kd-trees
47
6
5
1
3
2
9
8
10
11
l5
l1 l9
l6
l3
l10 l7
l4
l8
l2
l1
l8
1
l2 l3
l4 l5 l7 l6
l9l10
3
2 5 4 11
9 10
8
6 7
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
Kd-trees - Construction
47
6
5
1
3
2
9
8
10
11
l5
l1 l9
l6
l3
l10 l7
l4
l8
l2
l1
l8
1
l2 l3
l4 l5 l7 l6
l9l10
3
2 5 4 11
9 10
8
6 7
23
47
6
5
1
3
2
9
8
10
11
l5
l1 l9
l6
l3
l10 l7
l4
l8
l2
l1
l8
1
l2 l3
l4 l5 l7 l6
l9l10
3
2 5 4 11
9 10
8
6 7
q
Kd-trees - Query
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
Landmarks point location – Query
Find Nearest
Landmark
Decide on Startup
Face
Cross to Next Face
Query PointLocated
Is query point
in face ?
Yes
No
Walk
26
Landmarks point location – Query
Find Nearest
Landmark
Decide on Startup
Face
Cross to Next Face
Query PointLocated
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
q
q
27
Landmarks point location – Query
Find Nearest
Landmark
Decide on Startup
Face
Cross to Next Face
Query PointLocated
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
Landmarks point location – Query
Find Nearest
Landmark
Decide on Startup
Face
Cross to Next Face
Query PointLocated
Is query point
in face ?
Yes
No
Walk
Cross to next face: Create a segment s from the
landmark 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’…
ef
q
f’
s
29
Benchmark Categories: Query & Preprocess time Algorithms: Naïve, Walk, Triangle, RIC,
2 variants of landmarks algorithm. Arrangements: random and degenerate. similar results.
Random Onebig
30
Number of
Edges
Number of
Original Segment
s
Naïve Walk Triangle
RIC Landmarks
(vertices)
Landmarks
(random)
35 10 0.28 0.31 0.2 0.05 0.20 0.13
2301 100 8.9 3.9 1.7 0.20 0.31 0.23
9548 200 30.7 8.7 3.6 0.26 0.32 0.24
56070 500 163.4 24.3 8.6 0.33 0.35 0.26
114303 700 329.6 35.1 12.07 N/A 0.35 0.26
235553 1000 685.7 50.5 18.14 N/A 0.36 0.27
Benchmark: Query Arrangements of random line segments
Time in milliseconds
31
Number of
Edges
Number of
Original Segments
Common Preprocessing: Constructing
the Arrangement
Algorithm Specific PreprocessTriangl
eRIC Landmark
s(vertices)
Landmarks
(random)
35 10 0.004 0.036 0.016 <0.001 0.03
2301 100 1.2 11 4.04 <0.001 2.3
9548 200 5.4 80 20 <0.001 10
56070 500 30 990 153 <0.001 68
114303 700 31 1463 N/A 1 166
235553 1000 65 7984 N/A 2 352
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
Number of Random
Landmarks
Total Preprocessing
Time [sec]
Net Preprocessing
Time [sec]
Query Time [msec]
% Queries with
AD = 0
10 72.8 0.1 3.95 2.9
100 72.9 0.2 1.41 14.2
1,000 73.3 0.5 0.55 30.9
10,000 76 3.5 0.33 53.0
50,000 90 17 0.26 73.9
100,000 106 34 0.22 82.0
500,000 242 169 0.21 87.7
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
Landmarks Type
Number of
Landmarks
Total Preprocessi
ng Time [sec]
Net Preprocessi
ng Time [sec]
Query Time
[msec]
% Queries
with AD = 0
Vertices (V)
28,000 72.8 0.6 0.32 92.7
Edge Midpoints (EM)
57,000 74.7 1.8 0.27 96.6
V + EM 85,000 74.5 1.9 0.27 97.6
Random 50,000 90.0 17 0.26 73.9
UniformGrid
50,000 89.3 16.7 0.24 77.5
Landmarks Algorithm Analysis Algorithm performance vs. the type of landmarks used
pv
q
34
Landmarks Algorithm Analysis
35
Conics Differences from segments Bench results Problems invoked, and their
solutions Cross to next face The chord method Number type theory
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
Benchmark: Query Arrangements of random conic arcs
Time in seconds
Number of Edges
Number of Original Conics
Naïve Walk RIC Landmarks
(vertices)
Landmarks(random)
26 10 0.2 0.3 0.04 0.25 0.10
72 20 0.4 0.7 0.07 0.36 0.14
192 40 0.9 1.6 0.11 0.45 0.17
430 60 1.5 3.5 0.15 0.51 0.16
1000 100 3.4 8.5 0.2 0.62 0.15
7554 200 9.8 28.8 0.4 0.69 0.11
26160 400 29.6 71.4 0.35 0.72 0.12
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.
q
s e
x-range
q
x-range
e
s
L
q
x-range
e
sL
q
x-range
e
s
q
x-range
e
s
(a) (b) (c)
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
2
2 2
tan2
2 1sin ,cos1 1
t
t tt t
2
2 2
1 2,1 1
t tt t
2
The Chord MethodGiven: Unit circle equation:
x2 + y2 = 1 The point (-1,0) is on the circleFind: Rational point v’ close to vSolution: Every line passing through
this point is:y = t(x+1) where t is the slope of the line.
solve x2 + (t(x+1))2 = 1
-)1,0(
y=t(x+1)
x2+y2=1
v
41
One Rational Point Apparently, not all conics with rational (or even integer)
coefficients have rational points on them
For example, the circle
x2 + y2 = 3
does not have any rational points on it.
42
Change the equation into homogenic coordinates:
A: r x2 + s y2 + t xy + u x + v y + w = 0 ⇓ (x→x/z, y→y/z)
B: r x2 + s y2 + t xy + u xz + v yz + wz2 = 0
(Rational solution to A ⇔ Integer solution to B)
Theory 1: if there is a solution for every congruence modulo pk 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
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
What to do in practice? Change the equation into homogenic coordinates Go over all small pk and check if there is a solution modulo
pk. 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
If there are no rational points on the conic?
Euclid’s algorithm to approximate real number x into rational number r:
x = a0 + 1/x1, x1>1, a0 - integerx1 = a1 + 1/x2, x2>1, a1 - interger…Finally, r = a0 + 1/(a1 + (1/ (a2 + ….) ) ) = pn/qn.
If x is irrational, and the algorithm ends after n stages, then:
| x - pn/qn | < 1/qn2
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
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
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
Top Related