preliminaries a first attempt · a first attempt (cont.) ¥sort the edges of each slab by...
TRANSCRIPT
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 1
SMD156Lecture 8
Point Location
SymbolicPerturbation
Randomized Algorithm
Trapezoidal Maps
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 2
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 3
Preliminaries
• A map is a planar subdivision !a DCEL".
• A point location query is to ask in which region!face" of a map a given !query" point lie.
• We strive to pre-process the map to enablehigh-speed point location queries.# Building a data structure suitable to search.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 4
A first attempt
• Let P be a planar subdivision with n edges.
• Partition the plane into slabs by cutting alongvertical lines through vertices of P.
• Slabs# are partitioned by parts of edges, and
# contain no vertices.
• !You have met slabs before in this course, butwhere..?"# Exercise 2.1!
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 5
A first attempt (cont.)
• Sort the slabs by x-coordinate.# Then we can locate the slab that contains a query
point in O!log n" time.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 6
A first attempt (cont.)
• Sort the edges of each slab by y-coordinate.# Then we can locate the face within a slab that contains a
query point in O!log n" time.• Two neighboring edges bound the same face.
• Bad news: Storage needed is O!n2".• Good news: A query takes just O!log n" time!
n/4
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 7
Trapezoidal maps• Non-crossing line segments are disjoint or share a
common end point.• A set of non-crossing line segments are in general
position if two distinct end points never lie on thesame vertical line.# Unrealistical
• Let S be a set of n non-crossing line segmentsenclosed in a rectangular box R.
• The trapezoidal map !or vertical/trapezoidaldecomposition" T!S" is obtained by drawing two verticalextensions from every end point in S - one upwardsand one downwards - until they hit another segmentor R.# The upper vertical extension and the lower vertical extension.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 8
Example
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 9
Lemma 6.1
• $Each face in a trapezoidal map of a set S ingeneral position has one or two vertical sidesand exactly two non-vertical sides.$
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 10
Lemma 6.2
• $The trapezoidal map T!S" of a set S of n linesegments in general position contains at most6n+4 vertices and at most 3n+1 trapezoids.$# Trapezoidal maps are planar graphs.
# Euler%s formula.
# A trapezoidal map has linear size.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 11
Trapezoids
• The top and bottom edgeof a trapezoid.
• Its point leftp !rightp analogously defined":
• top, bottom, leftp and rightp defines thetrapezoid.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 12
Trapezoids (cont)
• Two trapezoids are adjacent if they meet alonga vertical edge.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 13
A Randomized Incremental Algorithm
• Algorithm TrapezoidalMap!S"1. Determine a bounding box R that contains all of
the segments of S.
2. Initialize T, the trapezoidal map structure and D,the search structure:
• !T is the whole box R and D has only onenode corresponding to T."
3. Compute a random permutation s1, s2, ..., sn ofthe segments of S.
4. For each segment si !in this order", … .. .
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 14
The algorithm
. .. …• Find the set of trapezoids in T properly
intersected by si
• Remove them from T and replace them bythe new trapezoids that appear because of theinsertion of si
• Remove the leaves of D for the oldtrapezoids and create leaves for the new ones.Link them to the existing inner nodes byadding some new inner nodes.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 15
About the algorithm
• This algorithm computes a trapezoidal mapand a search structure !a DAG" that leads tothe trapezoid containing a query point.
• Expected ... !Theorem 6.3"# …time to construct: O!n log n"
# …space to store: O!n"
# …time to query: O!log n"
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 16
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 17 tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 18
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 19 tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 20
Degenerate cases
• Two assumptions:1. General position !no distinct end points of line
segments share x-coordinate"
2. No query point on a vertical line through an endpoint of a line segment.
• One solution: Rotate &around origo, forinstance'.# Small rotations lead to numerical problems.
• Better: Symbolic $rotations$.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 21
Symbolic perturbation
• A shear transformation:
• ! should be small and not change the x-orderof the input points.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 22
Symbolic perturbation (cont)
• We store points as !x,y", not !x + !y, y".
• We need two operations to compute atrapezoidal map:# Determine on which side of the vertical line
through one given point p another given point qlies.
# Given a line segment with end points p1 and p2
determine if a given point q, on a vertical line thatintersects the line segment, lies above or below oron the line segment.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 23
Symbolic perturbation (cont)
• Consider the first operation on the points !xp + !yp, yp"
and !xq + !yq, yq".# If xp(xq then the order between xp and xq gives the answer!
• This was how ! was chosen.
# If, on the other hand, xp=xq then the order between yp and yq
gives the answer.
• There is no need to know the value of !!
• Also the second operation can be performed withoutknowing the value of !!# NB! Slightly more involved; read pages 139- 140!
• So, we now got rid of the first assumption.
tisdag 6 april 2004 SMD156 Computational Geometry - Håkan Jonsson 24
Symbolic perturbation (cont)
• In fact, also the second assumption !that noquery point may lie on a vertical line throughan end point of a line segment" can beremoved.
Theorem 6.5$All previous results are valid also without thetwo assumptions on the input we made.$