Slide 8

advertisement
COSC 6114
Prof. Andy Mirzaian
References:
•
•
•
•
•
•
•
[Preparata-Shamos’85] chapter 1.3
[Edelsbrunner’87] chapter 1.6, 4.2, 14
[O’Rourke’98] chapter 6
[Matoušek] Lecture Notes [at http://kam.mff.cuni.cz/~matousek/ ]
Guibas, Stolfi [1987] “Ruler, Compass and computer: The design and analysis of
geometric algorithms,” Proc. of the NATO Advanced Science Institute, series F, vol.
40: Theoretical Foundations of Computer Graphics and CAD, 111-165.
Edelsbrunner, O’Rourke, Seidel [1986] “Constructing Arrangements of Lines
and Hyper-planes with Applications,” SIAM J. Comp. 15, 341-363.
Edelsbrunner, Guibas [1989] “Topologically sweeping an arrangement,”
JCSS 38, pp:165-194 [correction in JCSS …]
Applications:
•
•
•
•
•
•
•
range searching,
geometric optimization,
motion planning,
visualization,
molecular modeling,
wireless networks: shadow edge estimation & sensor selection
…
Super-sampling in Ray Tracing
Determining visible objects by ray tracing.
• A ray through each pixel center.
• Problems: jagged edges, false hit/miss.
• A solution: super-sampling. Shoot many rays per pixel
(usually at random)
if 100 rays shot at pixel, and 43 hit the
same object, we say object visible in
roughly 43% pixel area.
Computing the Discrepancy
Pixel U = [0 : 1]  [0 : 1]
S = a set of n sample points in U
H = set of all half-planes
For h H define:
m(h) = area(h  U)
continuous measure
mS(h) = |S  h| / |S|
discrete measure
DS(h) = | m(h) - mS(h) |
discrepancy of h
DH (S) = sup hH DS(h)
half-plane discrepancy of S
The bounding line of this worst half-plane h passes
through either only 1, or at least 2, sample points.
FACT:
DH (S) can be computed in O(n2) time, using
Geometric Duality &
Arrangement of lines in the plane.
DS(h) = |1/4 – 3/10 | = 0.05
 geometric duality
 2D arrangements of lines
 Incremental Construction
 Ham-Sandwich Cuts
 Topological Sweep
 Applications
GEOMETRIC DUALITY
Geometric Duality
Point -to- hyperplane Transformations
Some Applications:
 Intersection of half-spaces 
Convex Hull of point sets
 Whenever the problem becomes intuitively “easier” in the dual space.
1. Hough (or Reciprocal) Transform (1969)
d
2
Point: (a1, a2, … , ad )
Hyper-plane: a1x1+a2x2+… +adxd +1 = 0
 origin
Point: (a,b)  (0,0)
not passing through the origin
Line: ax + by + 1 = 0
y
(a,b)
p* = dual of p
x
d(0,p)  d(0,p*) = 1
The origin is “above” the line.
slope = -a/b
2. Another Point-Line Transform
Point p: (a, b)

Line l: y = ax + b 
line p*: y = ax + b (non-vertical line)
point l*: (-a, b)
“asymmetric”: p**  p, l**  l.
y
(a,b)
x
3. Another Point-Line Transform
Point p: (a, b)  line l: y = 2ax – b
“symmetric”: p** = p, l** = l.
y = x2
y
(a,a2)
(a,b)
Some technical difficulties:
• In (1) the origin is not mapped suitably.
• In (2) and (3) lines parallel to the y-axis are not mapped.
• How to interpret dual of oriented lines?
(Answer: Use “inversive” transforms (see [PrS85] section 1.3.)
x
Duality Transforms Preserve Incidence
1.
2.
3.
Point p is mapped to line p*.
Line l is mapped to point l*.
Point p and line l are incident  line p* and point l* are incident
l*
p
p*
l
4.
Above/Below relation is also preserved (or reversed).
p
l*
l
5.
Line l passes through points p & q  Lines p* & q* intersect at point l*.
l
6.
p*
p
l*
q
q*
p*
Points p, q, r are collinear  Lines p*, q*, r* are concurrent.
l
p
q
r
l*
q*
r*
p*
Problem Transformation by Duality
Problem 1:
Compute the discrepancy:
L
q
p
L*
q*
PRIMAL PLANE
p*
DUAL PLANE
Now compute levels in arrangement
of lines in the dual plane
Problem 2:
Solution:
[Degeneracy]: are there any 3 collinear points among n given points?
Duality: are there 3 concurrent lines among n given lines?
(Use arrangement of lines)
Problem Transformation by Duality
Problem 3: Find upper (respectively, lower) envelope of n given lines
Solution:
Compute upper (respectively, lower) convex hull of the n dual points
l3*
l2*
l4
l1
l4*
l1*
l2
l3
PRIMAL PLANE
DUAL PLANE
Problem 4: Compute intersection of n half-spaces
Solution:
Compute Convex Hull of n dual points
Caution:
What happens if the origin is not in the intersection?
Arrangements
Arrangements of lines and hyper-planes
L = { l1 , l2 , … , ln } n lines in 2 (in general: n hyper-planes in d )
A(L ) = arrangement of L , i.e., subdivision of 2 (resp., d ) induced by L .
Assume: L is in general position, i.e., no 2 lines in L are parallel,
& no 3 are concurrent.
Combinatorial complexity of A(L ) in 2 :
n 
V = # vertices =  
2
E = # edges
= n2
(each line is cut into n edges)
F = # regions = Q (n2)
Euler: (V+1) – E + F = 2
 F = (n2 + n + 2) / 2
vertex at 
n n n
n
     
 0 1  2
d 
Arrangement Construction
Will take at least W(n2) time & space, due to combinatorial size of A(L ).
1.
Plane Sweep:
At least W(n2 log n) time, since it will “sort” the arrangement vertices.
2.
Naïve Incremental Algorithm
A ({ l1 , l2 , … , lk-1 })  A ({ l1 , l2 , … , lk }), for k=2..n


Binary Search to find vi1 , vi+1,1 .
O(log k) for each of l1 , l2 , … , lk-1.

O(k log k) to insert lk.

Total O(
Sk k log k)
= O(n2 log n) time, and O(n2) space.
l1
vi+1,1
vi1
lk
Refined Incremental Algorithm
How to insert lk in
A({ l1 , l2 , … , lk-1 }) ?
u3
v2
v1
u2
u1
“upward”
movement
on one
side of
l1
lm
l1
v0
lk
u0
“downward”
movement
on the
other side
of l1
Refined Incremental Algorithm
How to insert lk in A({ l1 , l2 , … , lk-1 }) :
1.
Find u0 = l1  lk and rightmost vertex v0 on l1 to the left of u0, in O(k) time.
Let v0v1 be CCW from v0u0 on vertex v0 .
2.
If segment v0v1 intersects lk , then we have closed a polygonal line that starts
from a previous intersection point, namely u0, and ends in another intersection
point, namely u1. Therefore, we can insert u1 properly in the adjacency list.
We now go to u1 and repeat steps 1,2,3 with u1 as the new u0 and lm as the new l1.
3.
If v0v1 does not intersect lk , then we take the next vertex v2 CCW on v1 from v1v0
and repeat the same procedure.
4.
When we encounter a vertex that has a leftmost edge which is a ray diverging from
lk, we have finished the “upward” movement.
5.
We do a similar “downward” movement, starting from v0, on the other side of l1.
ZONE of a line in the arrangement
Zone of lk
= collection of the polygonal regions of the arrangement
that have an edge on lk.
Combinatorial complexity of a zone
= total number of vertices of the polygonal regions in the zone
(counting multiplicities).
upper zone
lk
lower zone
ZONE Complexity
in A({ l1 , l2 , … , lk-1 }) is
 5k-6 on each side ( 10k–12 on both sides).
THEOREM: Combinatorial complexity of zone of
lk
vtop
Proof 1: k convex polygonal regions incident to in the
“upper” zone of lk (similarly in the “lower” zone).
ceiling
right
walls
left
walls
Define: ceiling, left/right wall, & floor edges for each
polygon as the figure on the right.
floor
Claim:   1 left wall &  1 right wall on each line lj , j =1..k-1.
Proof: e1  ceiling  e3’s extension cuts Pm  a contradiction.
Corollary:   2(k-1) -2 = 2k-4 wall edges.
(First poly has no left wall, last poly has no right wall.)
Total count:
k
floors
2k-4 walls
2k-2 ceilings (1s & last have only one ceiling edge)
5k-6 total
lk
lj
e2
e3
e1
Pi
Pm
lk
Davenport–Schinzel Sequences
DSs(n) :
•
•
•
a1 a2 a3 …
n different characters
ai  ai+1
… a … b … a … b … a … b … (length s+2 alternating subsequence
is forbidden)
ls(n) = max length DS sequence (n,s)
Fact:
l1(n) = n
l2(n) = 2n-1
l3(n) = Q(n a(n))
(a(n) = inverse Ackermann’s function,
very slow growing.)
Example:
max length of upper envelope of n (possibly crossing) line-segments in the plane
= Q(l3(n)).
ZONE Complexity
in A({ l1 , l2 , … , lk-1 }) is
 5k-6 on each side ( 10k–12 on both sides).
THEOREM: Combinatorial complexity of zone of
Proof 2: By Davenport-Schinzel sequences.
Consider the sequence of only left wall/ceiling edges in
the traversal of upper-zone of lk (similarly for right … ).
lk
a
k
dbdcacd
a
b
..b..b..b..a..a..b..b..
floors
2(k-1) -1 left walls / ceilings
2(k-1) -1 right walls / ceilings
5k-6
total
d
lk
Claim: This is a (k-1, 2) DS sequence.
That is, …a…b…a…b…
is a forbidden sub-sequence.
Total count:
c
b
a
lk
b
lk
..a..a..a..b..b..b..
Arrangement Complexity
THEOREM: The arrangement A(L) of n lines L = { l1 , l2 ,
… , ln } in 2
can be constructed in optimal time & space O(n2).
THEOREM: Let H = { h1 , h2 ,
… , hn } be a set of n hyper-planes in d.
(a) The combinatorial size of the zone of any hyper-plane in the
arrangement A(H) is O(nd-1).
(b) A(H) can be constructed in optimal time & space O(nd).
Levels and Discrepancy
U = [0 : 1]  [0 : 1], S = a set of n points in U.
Dualize:
S  S*  A(S*).
For each vertex v in A(S*) we need to compute how many lines of S* are
a) strictly above it [let’s call this level(v)],
b) pass through it,
c) strictly below it.
We essentially need to compute the levels of all vertices of the arrangement A(S*).
Take a walk along each line, and compute the level of each vertex on it.
0
+1
-1
1
1
2 3
3
2
2
l
3
3
0
-1
2
1
1
+1
+1
3
level=1
4
Compute level of leftmost vertex of l in O(n) time, then compute each of its
subsequent vertices in order of degree of the vertex.
Total time, over all lines in S*, is O( sum of vertex degrees + n2) = O(n2).
Ham-Sandwich Cuts
Ham-Sandwich Cuts
 line p*: y = ax – b
line l: y = a x + b  point l*: (a, -b)
Duality D: point p: (a,b)
Fact: D preserves point-line incidence & above-below relationships.
Definition: A bisector hyper-plane of n points in d is one such that each
of its induced open half-spaces contains  n/2 of the points.
Ham-Sandwich Theorem
Borsuk-Ulam Theorem [1933]:
Let f: Sd-1 | d-1 be any continuous mapping
from the sphere Sd-1 to d-1.
Then, f(x) = f(-x) for some anti-podal pair
x and –x on Sd-1. (For details see [Ede87].)
S1
x
-x
Ham-Sandwich Theorem:
Let P1 , P2 , … , Pd be d finite point sets in d.
There exists a hyper-plane h in d that simultaneously bisects P1 , P2 , … , Pd.
Proof: By Borsuk-Ulam Theorem.
Let x be an arbitrary point on the sphere Sd-1.
Consider the hyper-plane h(x) that bisects Pd and has x as unit normal vector.
Define f(x) = (n1, n2, , … , nd-1), where nk is # points of Pk on the “positive” side
of h(x), plus half the # points of Pk on h(x).
Note that, f(-x) = ( |P1| - n1, |P2| - n2 , … , |Pd-1| - nd-1 ).
Function f(x) can be “made” continuous.
By Borzuk-Ulam Theorem, there is an x on Sd-1 such that f(x) = f(-x).
For such an x, h(x) is a ham-sandwich cut, i.e., simultaneously bisects P1, P2, …, Pd.
Stone-Tukey [1942]: Proved the continuous version: volume bisection.
2D Ham-Sandwich Cut (HSC)
Ham-Sandwich Theorem in 2D:
Consider finite point sets P and Q in the plane, where |P|=m, |Q|=n.
There exists a line L in the plane that simultaneously bisects P and Q.
[WLOGA m and n are odd. We may add extra point if even.]
L
2D HSC
Consider sets of points P and Q in the plane, where |P|=m, |Q|=n, both odd.
Then HSC of P&Q can be computed in O((m+n) log (m+n)) time.
[Lo, Matoušek, Steiger [1994], Discr. Comp. Geom. 433-452]
improved it to O(m+n) time.
2D HSC
Consider sets of points P and Q in the plane, where |P|=m, |Q|=n, both odd.
Then HSC of P&Q can be computed in O((m+n) log (m+n)) time.
[Lo, Matoušek, Steiger [1994], Discr. Comp. Geom. 433-452]
improved it to O(m+n) time.
We will show:
THEOREM:
If P and Q are linearly separable, then HSC of P&Q can be computed in O(m+n) time.
P
Q
P
Q
L
COROLLARY: A set in 2D (also in 3D) can be 4-sected in linear time.
2D HSC
THEOREM:
If P and Q are linearly separable, then HSC of P&Q can be computed in O(m+n) time.
METHOD:
Apply duality. Consider the dual sets of lines G = P* and H = Q*.
Find the intersection of the mid-level of their arrangements by prune-&-search.
WLOGA P&Q are separated by the y-axis.
y
Q
P
G
P,Q
L
L*
X<0
X>0
H
L*
Prune-&-Search: TEST(line t)
(1)
Line t is vertical (Fig. (a))
i(P) above i(Q)  s is to the right of t.
t
L(G)
K(H)th level of H
i(P)
(2)
(3)
0 < slope(t) <  (Fig. (b))
i(P) above i(Q)  s is below t.
(a)
s
i(Q)
- < slope(t) < 0 (similar).
K(G)th level of G
(4)
L(H)
slope(t) = 0 (Fig. (c))
i(P) left of i(Q)  s is below t.
L(G)
t’
L(G)
i(P)
i(P)
t
i(Q)
s
L(H)
t
s
i(Q)
L(H)
(c)
(b)
Finding test lines & pruning
(1)
Lmed  median-slope line in G H.
L<  { L G H | slope(L) < slope(Lmed) }
L=  { L G H | slope(L) = slope(Lmed) }
L>  { L G H | slope(L) > slope(Lmed) }
(2)
Pair up lines in L< with those in L> as much as possible into a set of pairs called Pairs.
( | | L< | - | L>| | lines of either L< or L> remain unmatched.)
(3)
A  multiset of x-coordinates of intersection points of each pair in Pairs.
(4)
t1  the vertical line through median point in A. TEST(t1). It either terminates having found a
point in L(G)  L(H), or determines the half-plane t1+ that contains L(G)  L(H).
(5)
B  the multiset of points on t1 as follows: intersections of t1 with lines in L= and
intersections of t1 with lines of slope(Lmed ) through intersections of those pairs in Pairs
that are not in t1+.
t1+
t1
(6)
t2  line with slope (Lmed ) through median point in B. TEST(t2). It either terminates having
found a point in L(G)  L(H), or determines the half-plane t2+ that contains L(G)  L(H).
(7)
q  t1+ t2+ (quadrant that contains a point in L(G)  L(H).)
t1
q
t2
Finding test lines & pruning
LEMMA: Suppose |G H| = L and let q be the quadrant t1+  t2+ computed in the procedure.
Then, at least L/8 of the lines in G H avoid the quadrant q.
Proof:
Define N< = | L< | ,
N= = | L= | ,
N> = | L> |.
q
L = N< + N= + N> ,
|A| = min {N< , N> } ,
|B|

t1
N= + ½ |A| ,
t2
# lines avoiding q  ½ |B|
 ½ N= + ¼ min {N< , N> }
 1/4 N= + ¼ min {N< + N= , N> + N= }
 1/4 N= + ¼  ½ L
 1/8 L
by median property
N<
N=
L
N>
avoids q
Finding test lines & pruning
ALGORITHM: Ham-sandwich cut in the plane for 2 linearly separated point sets.
SEARCH: Find t1 and t2 and TEST
PRUNE:
Eliminate all lines of G and H that avoid region q and
update levels K(G) and K(H) accordingly.
RECURSE: Repeat the above process with the new G & H & K(G) & K(H).
RECURRENCE: T(L) = T(7L/8) + O(L)
THEOREM: Total time = O( m+n ).

T(L) = O(L)
t1
q
where
s lies
t2
Half-plane Range Queries
Half-Plane Range Query Processing: Given a fixed set P of n points in the plane,
preprocess P for such queries: given a half-plane H, report H  P.
Idea: Any intersecting pair of lines divide the plane into 4 quadrants. Any half-plane
either completely contains or completely misses at least one quadrant.
Ham-Sandwich Trees:
L1
L2
L6
L3
L1
L2
L2
L8
L5
L3
L7
L5
L3
L5
L6
L4
L6
L7
L4
L8
L4
Preprocessing Time = O(n log n)
Space = O(n)
Query Time Q(n) = Q(n/2) + Q(n/4) + O(log n) = O(na),
Query Report = O(K + na) .
a = log (1+5)/2 < 0.69
L8
Half-plane Range Queries
Ham-Sandwich Tree:
Preprocessing Time = O(n log n)
Space = O(n)
Query Report = O(K + na) , a = log (1+5)/2 < 0.69
OPEN:
Can it be improved to O(K + log n) time
without increasing the preprocessing time or space?
Partial Answer by Point Location in Arrangements:
O(n2) preprocessing time & space to form A(P*), arrangement of dual of P.
Preprocess A(P*) for point location in O(n2) time & space.
Query Time: O(K + log n).
TOPOLOGICAL SWEEP
Topological Sweep of Line Arrangements
IDEA: It requires only O(n) space, instead of O(n2) to maintain the entire arrangement
of n lines in the plane, all at once.
Definition: A cut is a simple curve that intersects each line of the arrangement once.
Cut = (c1 , c2 , … , cn ) is sequence of cut edges from top to bottom.
1
1
c1
c1
2
3
2
c2
c3
c4
4
c2
3
c4
4
cut
cut
Technical Assumption:
In the arrangement each edge is half-open;
it contains its right end-point, but not its left-end-point.
c3
Leftmost & Rightmost cuts
leftmost cut
(no vertex to its left)
rightmost cut
(no vertex to its right)
Where to advance the cut
C’
C
Li
below
above
Lj
FACT 1: Let C = (c1 , c2 , … , cn ) be any cut, except the right-most cut.
Then at least one pair of adjacent edges of the cut, say (ci , ci+1), have a common right end-point.
Proof: Let ci be the cut edge with the leftmost right end-point ri.
We claim ri is either ci ci+1 or ci ci-1 .
ci
ci
ri
ci-1
ci
ri
ci
ci+1
ci
ri
ri
ri
ri
ci
impossible
Topological Sweep
1.
Start from the leftmost cut.
2.
Using Fact 1, choose an adjacent pair of cut edges with a common
right end-point vertex v, and advance the cut past vertex v.
3.
Repeat step 2 until the rightmost cut is reached.
Auxiliary data structures to help quickly find such a vertex v in step 2.
 Stack I: of intersection points (ci , ci+1) that are vertices of the arrangement
 Upper Horizon Tree (UHT)
 Lower Horizon Tree (LHT)
 M[1..n]:
permutation of lines L1, L2 , … , Ln that contain edges of the cut C.
 N[1..n]:
N[i] contains left & right ends of ci and tells
which 2 lines delimit these end-points.
Total space O(n).
Upper Horizon Tree
UHT: For a given cut C = (c1 , c2 , … , cn ) , add a vertical line at x= .
Start from each edge of the cut and move right. When reached a
vertex of the arrangement, take the higher edge out of it to the right
and continue the same way until hitting the vertical line at x = . The
edges of the arrangement traversed this way form the UHT.
LHT: defined similarly.
See next slides for an example.
A Cut
Cut
UHT
Vertical line at x =  not shown
Cut
LHT
x=
Cut
More Facts
FACT 2: UHT & LHT are indeed trees.
Proof: Recall the technical assumption (left end-points of cut edges are not part of the edge.
So, no cycle that way). As we go up the tree from each edge to the parent edge, the
slope changes monotonically. So, no cycle can occur. The line at x =  is the root.
FACT 3: Two cut-edges share a right end-point  they do so in both UHT & LHT.
[This is the reason for using UHT & LHT.]
Topological-sweep overview
1.
Sort L1, L2, … , Ln in increasing order of slope
2.
Initialize the data-structures for the “left-most” cut:
UHT, LHT, N[1..n], Stack I, M[1..n] (use the sorted order of step 1)
3.
General Step:
O(n2) iterations, each takes O(1) amortized time
while stack I   do
(3a) pop a vertex v = ci ci+1 from stack I
(3b) push the cut past vertex v and update the data-structures.
end
Total time = O(n2), space = O(n).
O(n log n) time
O(n) time
Step 2 details
O(n) time
Ln-1, … , Li+1, Li, …, L1.
Go CCW along the Bay “up-wards” & eliminate lines until Li is added at the proper place.
Initialize UHT:
Incrementally add Ln,
Implement the Bay as a stack.
Li+1
Li
new
Bay
Bay
Ln
Initialize LHT: Similar.
Initialize N[1..n]:
The leftmost segment of each line (which is the appropriate edge for the
leftmost cut) is the shorter of the segments of the line in the UHT & LHT.
Initialize Stack I: Once N[1..n] is known, stack I can be trivially obtained using FACT 3.
Initialize M[1..n]: Use sorted order of step 1.
Step 3 details
 Pop vertex v=cici+1 from stack I & update the structures after advancing the cut past v.
 How to update the UHT:
 Line M[i+1], with greater slope, needs no change
 Line M[i] should be updated:
w
ci
w
v
c’i
c’i+1
?
v
push vertex v
ci+1
Bay
ci+2
cut
cut
Before
After
 c’i proceeds as before along M[i+1] in UHT.
 c’i+1 : CCW scan the Bay starting from leaf ci+2 of UHT and move up along its ancestral path
to find which edge is hit by c’i+1.
As we topologically sweep over vertices, we compute the desired info on vertices/edges of
the arrangement (see next application).
CLAIM: Step 3 takes O(1) amortized time per iteration.
Proof:
[Note: actual time of each vertex-push could be as high as O(n).]
(1)
Charge vertex v, 1 for each edge of the Bay we span (except the last).
(2)
Transfer charges received by w to v due to edges of the Bay after the one intersected by c’i+1
(they are still visible to v but not to w).
(3)
Charge Invariant: Currently a pair (v,e) is charged iff vertex v and edge e can “see” each other
at the current situation of the cut, i.e., portion of the arrangement swept over + edges in the UHT.

 charges 

1 
(v,e)
v & e can "see"
each other
2
(
10
n

12
)

O
(
n
).

Zone
Theorem L

e v
 
1 
# vertices
of polygons
touching
line L
L
belongs to
a region
with e as
an edge
v
w
1
c’i
c’i+1
?
Bay
ci+2
cut
Corollary: Topological-sweep of an arrangement of n lines in the plane requires
O(n2) time but only O(n) space.
Application: Smallest Area Triangle
Problem:
Given n points in the plane, find 3 of the points with minimum
possible triangle area.
Application: [Degeneracy Test] Are any of the 3 points collinear?
Solution tools used:
 geometric duality
 arrangement of lines
 plane sweep
 trapezoidal decomposition
 topological sweep
Application: Smallest Area Triangle
SOLUTIONS
TIME
SPACE
Brute force
O(n3)
O(n)
Geometric Duality
O(n2 log n)
O(n2)
Geometric Duality
+
Plane Sweep
O(n2 log n)
O(n)
Geometric Duality
+
Arrangement
O(n2)
O(n2)
O(n2)
O(n)
Geometric Duality
+
Topological Sweep
of Arrangement
See next pages for details
OPEN PROBLEM:
Known lower and upper bounds on time complexity: W(n log n) and O(n2).
Resolve the gap between the lower and upper bound.
Geometric Duality
Primal space
Dual space
Point p = (a,b)

Line L: y = ax + b 
Technicality:
How to avoid:
line p*: y = ax + b
point L* = (-a , b)
Vertical lines can’t be represented by points in the dual space.
Sort the points (in primal space), then check to see if any two have
the same x-coordinate. If so, the line through them will be vertical.
Rotate the coordinate axes slightly, if necessary, to avoid this. This
can be achieved in O(n log n) time.
Notation:
p
 Li = p*i line dual to point pi.
 d(p,q) = Euclidean distance between the two points p and q.
 d(p,L) = orthogonal distance of point p from line L
 L(pi , pj) = line (not line-segment) through points pi & pj.
L
Geometric Duality
Primal Space: Take 2 points pi , pj. Find 3rd point pk that minimizes d(pk, L(pi,pj)).
Then, triangle Dpipjpk is the smallest area triangle with (pi,pj) as one of its sides.
Triangle Area = ½ d(pi,pj)d(pk ,L(pi , pj)).
p
Define:
dV(pk ,L(pi , pj)) = vertical distance of pk from L(pi , pj).
I(Li , Lj) = intersection point of dual lines Li & Lj.
L
CLAIM 1: The ratio d(pk ,L(pi , pj))  dV(pk ,L(pi , pj))
is fixed as pk varies among the remaining n-2 points.
CLAIM 2: dV(pk ,L(pi , pj)) = dV(I(Li , Lj) , Lk)
Proof: Algebra exercise.
Li
Lj
pk
pi
pj
Lk
Solution 1: Geometric Duality
CONSEQUENCE:
In the dual space consider the arrangement of lines L1 , L2 , … , Ln and observe
that vertical distance between I(Li , Lj) and Lk is attained only when Lk is the line
that is immediately above or below point I(Li , Lj) .
Therefore, it belong to the same face of the Arrangement.
ALGORITHM 1:
1.
Sort by x-coordinate all O(n2) intersection points I(Li , Lj), 1  i < j  n.
2.
Order all L1 , L2 , … , Ln vertically just to the left of the leftmost intersection
point, and in O(n) time rank this intersection point & find the pair of lines
just above & below it.
3.
At intersection point I(Li , Lj), swap Li & Lj in the vertical ordering
(they are adjacent in that ordering), and get the 2 lines just
above & below the intersection in O(1) time.
Repeat this process in sorted order of intersection points.
CLAIM:
Step 1 takes O(n2 log n) time.
The rest takes O(n2) time by spending O(1) time per intersection point.
Space is O(n2).
Solution 2: Plane Sweep in dual space
ALGORITHM 2:
Use plane-sweep method to compute the intersection points “on the fly” and maintain
the vertical ordering of the dual lines in a dictionary as the sweep progresses.
CLAIM:
Algorithm 2 requires O(n2 log n) time and O(n) space.
[O(log n) time per intersection point processed.]
Solution 3: Trapezoidal Decomposition in dual space
ALGORITHM 3:

Construct the arrangement of dual lines L1 , L2 , … , Ln.
(Convex regions, hence x-monotone.)

Obtain the trapezoidal decomposition of the arrangement.

Obtain the 2 lines immediately above & below each intersection point.
CLAIM: Algorithm 3 requires O(n2) time and O(n2) space.
Solution 4: Topological sweep in dual space
ALGORITHM 4:

Use topological sweep on the arrangement of dual lines.

Whenever the cut advances past a vertex v=cici+1, compute the necessary
info about v,
i.e., its vertical distance from the line above it and the line below it.
Details: Exercise.
CLAIM: Algorithm 4 requires O(n2) time and O(n) space.
Exercises
1.
Let P be any set of n  3 points in the plane, not all on a line.
(a) Prove that there is a line that contains exactly two points of P.
(b) Prove that there are at least n lines each passing through at least two points of P.
2.
We are given a set L of n lines and a set P of n points in the plane. We want to
determine whether some point in P is on some line in L .
(a) What is the geometric dual of this problem?
(b) Design an efficient algorithm to solve the problem.
[Hint: shoot for a sub-quadratic running time. Begin by dividing L into roughly n/m
groups of size m each. Then optimize the total running time over the parameter m.]
3.
Given a set L of n lines in the plane, design an O(n log n) time algorithm to compute the
convex hull of the O(n2) vertices of the arrangement A(L) .
4.
Define a strip to be the region bounded by two (non-vertical) parallel lines. The width of
a strip is the vertical distance between the two lines. The problem is, given a set of n
points in the plane find the non-vertical strip of minimum width that encloses all of these
points.
(a) What is the problem in the dual setting?
(b) Give an O(n) time algorithm to solve the problem. [Hint: use prune-&-search.]
width
5.
Let A(L ) denote the arrangement of a set L of n lines generally positioned in the plane,
i.e., no two lines of L are parallel, and no three of them pass through the same point. A
triangle in A(L ) is a region of A(L ) that is bounded and has three sides. Prove that
A(L ) must have at least n2 triangles.
6.
Let Q denote the intersection of n given half-planes {H1 , H2 , …, Hn } in the plane.
Design and analyze a linear time deterministic algorithm to determine whether Q is
empty, and if not, find a point q  Q.
[Hint: One method is to use geometric duality and prune-&-search.]
7.
Given a set P of n points in the plane, design an efficient data structure that can answer
line-dragging queries. Such a query is specified by giving a non-vertical line l and asking
for the first point of P that would be hit by dragging l vertically upward without changing its
slope. [Hint: Shoot for a query time of O(log n) with a data structure using O(n2) space.]
8.
Given an n-vertex simple polygon P and an edge e of P, show how to construct a data
structure to answer the following queries in O(log n) time and O(n) space. Given a ray r
whose origin lies on e and which is directed into the interior of P, find the first edge of P
that this ray hits. For example, in the figure below the query for ray r should report edge f.
You may assume that e is rotated into a convenient position, if it helps to simplify things.
[Hint: Use duality to reduce this to a point location query.]
P
r
e
f
9.
Consider a set P of n points in the plane. For k < n/2, a point q (not necessarily in P) is called
a k-splitter if for every line l passing through q at least k points of P lie on or above l, and
at least k points of P lie on or below l. (For example, point q shown in the figure below is
a 3-splitter, since every line passing through q has at least 3 points of P lying on either side.
But it is not a 4-splitter, since the horizontal line through q has only 3 points below it.)
q
(a)
Prove that there exists a k-splitter if and only if in the dual line arrangement of P, levels
L(k) and L(n-k+1) can be separated by a line. (L(k) is the set of arrangement edges
that each have k-1 arrangement lines strictly above them. For example, L(1) is the
upper-envelope, and L(n) is the lower envelope of the arrangement lines.)
(b)
Let u and v be two arbitrary points of level L(k) of the dual line arrangement. Let w be
an arbitrary point on the line segment uv. What is the maximum number of lines of the
arrangement that can be at or below (respectively, at or above) w? Express your
answers in terms of n and k and prove your claim.
(c)
Using (b), prove that any set of n points in the plane has a n/3-splitter.
(d)
Describe an O(n2) time algorithm for computing a n/3-splitter of P.
(e)
Prove or disprove: for all n and all k > n/3, there exists a set of n points in the plane
that has no k-splitter.
10. Let P be a given set of n points in the plane. 3 concurrent lines define a 6-partition of P if the
removal of these 3 lines partitions the plane into 6 open sectors such that each sector
contains at most n/6 points of P. (Note: The points of P that lie on the 3 lines do not count.)
(a) Prove that any set P admits a 6-partition.
(b) Design and analyze an efficient algorithm to find a 6-partition of P.
11. Let L = { l0 , l1 , . . . , ln-1} be a set of n non-vertical lines in general position in the plane (i.e.,
no two parallel, no three concurrent). Furthermore, assume the lines in L are given sorted in
increasing order of slope. That is, if the equation of line li is y = ai x + bi , then
a0 < a1 < . . . < an-1 . Consider the arrangement A (L) of L in the plane. Let F denote the
set of all polygonal regions in the arrangement. Let F denote the subset of F consisting of
only unbounded regions. For each polygonal region R F, let size(R) denote the number of
boundary edges of R.
(a) Show that S{size(R)2 | R  F } = O(n2). [Hint: use aggregate of zones of lines in A (L) .]
(b) Show that S{size(R) | R  F } = O(n).
(c) Let S be the set of n(n − 1)/2 vertices of the arrangement. Let P be the union of the
bounded faces of the arrangement A (L). We consider all vertices in S on the boundary
of P as vertices of P. So, P may have many collinear vertices. Prove that P is a simple
polygon and it has O(n) vertices.
(d) Show that we can construct polygon P in O(n) time, assuming the lines in L are given in
sorted order of slope. [Hint: Use topological sweep (implicitly). Maintain the upper horizon
tree for the leftmost cut while continuously rotating the coordinate axes CCW.]
(e) Recall the lines in L are given in sorted order of slope, and S is the set of all vertices of
the arrangement. Let vertex qi be the intersection of lines li and l(i+1)modn, for i = 0 .. n − 1.
Prove that CH(S) = CH(q0 , q1 , . . . , qn-1 ).
(f) Show that CH(S) can be computed in O(n) time.
END
Download