# COSC 6114 Prof. Andy Mirzaian Geometric Duality & Arrangements.

## Presentation on theme: "COSC 6114 Prof. Andy Mirzaian Geometric Duality & Arrangements."— Presentation transcript:

COSC 6114 Prof. Andy Mirzaian Geometric Duality & Arrangements

References: Applications: [Preparata-Shamos’85] chapter 1.3
[Edelsbrunner’87] chapter 1.6, 4.2, 14 [O’Rourke’98] chapter 6 [Matoušek] Lecture Notes [at ] 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, Edelsbrunner, O’Rourke, Seidel [1986] “Constructing Arrangements of Lines and Hyper-planes with Applications,” SIAM J. Comp. 15, Edelsbrunner, Guibas [1989] “Topologically sweeping an arrangement,” JCSS 38, pp: [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. DS(h) = |1/4 – 3/10 | = 0.05 FACT: DH (S) can be computed in O(n2) time, using Geometric Duality & Arrangement of lines in the plane.

2D arrangements of lines
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 Point: (a1, a2, … , ad )  origin Hyper-plane: a1x1+a2x2+… +adxd +1 = not passing through the origin 2 Point: (a,b)  (0,0) Line: ax + by + 1 = 0 y (a,b) 1/d ax + by + 1 = 0 p* = dual of p d(0,p)  d(0,p*) = 1 The origin is “above” the line. x d slope = -a/b

2. Another Point-Line Transform
Point p: (a, b)  line p*: y = ax + b (non-vertical line) Line l: y = ax + b  point l*: (-a, b) “asymmetric”: p**  p, l**  l. y=ax + b y (a,b) slope = a x

3. Another Point-Line Transform
Point p: (a, b)  line l: y = 2ax – b “symmetric”: p** = p, l** = l. y=2ax - b y y = x2 (a,a2) (a,b) x y=2ax – a2 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.)

Duality Transforms Preserve Incidence
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 Above/Below relation is also preserved (or reversed). Line l passes through points p & q  Lines p* & q* intersect at point l*. Points p, q, r are collinear  Lines p*, q*, r* are concurrent. l* p p* l p l* l p* They preserve incidence since they are affine transforms l* q p l q* p* r q l* p p* l q* r*

Problem Transformation by Duality
Problem 1: Compute the discrepancy: L q p L* q* p* DUAL PLANE PRIMAL PLANE Now compute levels in arrangement of lines in the dual plane Problem 2: [Degeneracy]: are there any 3 collinear points among n given points? Solution: 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 DUAL PLANE PRIMAL 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 : V = # vertices = E = # edges = n (each line is cut into n edges) F = # regions = Q (n2) Euler: (V+1) – E + F = vertex at   F = (n2 + n + 2) / 2

Arrangement Construction
Will take at least W(n2) time & space, due to combinatorial size of A(L ). Plane Sweep: At least W(n2 log n) time, since it will “sort” the arrangement vertices. 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 vi1 vi+1,1 lk

Refined Incremental Algorithm
How to insert lk in A({ l1 , l2 , … , lk-1 }) ? u3 “upward” movement on one side of l1 v2 u2 v1 u1 lm l1 v0 u0 “downward” movement on the other side of l1 lk

Refined Incremental Algorithm
How to insert lk in A({ l1 , l2 , … , lk-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 . 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. If v0v1 does not intersect lk , then we take the next vertex v2 CCW on v1 from v1v0 and repeat the same procedure. When we encounter a vertex that has a leftmost edge which is a ray diverging from lk, we have finished the “upward” movement. 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 lk lj lk
THEOREM: Combinatorial complexity of zone of lk in A({ l1 , l2 , … , lk-1 }) is  5k-6 on each side ( 10k–12 on both sides). vtop Proof 1: k convex polygonal regions incident to in the “upper” zone of lk (similarly in the “lower” zone). Define: ceiling, left/right wall, & floor edges for each polygon as the figure on the right. 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 ceiling right walls left walls lk floor e2 e3 lj e1 Pm Pi 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 lk lk lk
THEOREM: Combinatorial complexity of zone of lk in A({ l1 , l2 , … , lk-1 }) is  5k-6 on each side ( 10k–12 on both sides). d a c b 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 … ). Claim: This is a (k-1, 2) DS sequence. That is, …a…b…a…b… is a forbidden sub-sequence. lk d b d c a c d Cannot contribute any left w/c. a b lk ..b..b..b..a..a..b..b.. Total count: k floors 2(k-1) -1 left walls / ceilings 2(k-1) -1 right walls / ceilings 5k total b a 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 strictly above it [let’s call this level(v)], pass through it, 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. +1 +1 +1 -1 1 -1 3 1 1 2 3 2 l 2 1 2 3 3 level=1 3 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 Duality D: point p: (a,b)  line p*: y = ax – b
line l: y = a x + b  point l*: (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 ] 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 ] 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. Q Q P P 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 Slope < 0 P G P,Q L L* H Slope > 0 X < 0 X > 0 L*

Prune-&-Search: TEST(line t)
Line t is vertical (Fig. (a)) i(P) above i(Q)  s is to the right of t. 0 < slope(t) <  (Fig. (b)) i(P) above i(Q)  s is below t. - < slope(t) < 0 (similar). slope(t) = 0 (Fig. (c)) i(P) left of i(Q)  s is below t. t L(G) K(H)th level of H i(P) (a) s i(Q) K(G)th level of G L(H) L(G) L(G) t’ i(P) i(P) t i(Q) t (b) s s i(Q) L(H) L(H) (c)

Finding test lines & pruning
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) } 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.) A  multiset of x-coordinates of intersection points of each pair in Pairs. 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). 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+. 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). q  t1+ t2+ (quadrant that contains a point in L(G)  L(H).) t1+ slope(Lmed) t1 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> |. L = N< + N= + N> , |A| = min {N< , N> } , |B|  N= + ½ |A| , # lines avoiding q  ½ |B|  ½ N= ¼ min {N< , N> }  1/4 N= + ¼ min {N< + N= , N> + N= }  1/4 N= + ¼  ½ L  1/8 L q t1 t2 avoids q by median property N< N= N> L

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)  T(L) = O(L) THEOREM: Total time = O( m+n ). 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 L1 L6 L3 L2 L2 L2 L8 L5 L3 L3 L4 L4 L5 L5 L6 L6 L7 L8 L8 L7 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), a = log (1+5)/2 < Query Report = O(K + na) .

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 < 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 c2 2 c2 c3 3 3 c3 c4 c4 4 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.

Leftmost & Rightmost cuts
leftmost cut (no vertex to its left) rightmost cut (no vertex to its right)

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 . ri ci ri ci ci ci-1 ri ri ci ri ri ci ci+1 ci impossible

Topological Sweep Start from the leftmost cut.
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. 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

Vertical line at x =  not shown
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
Sort L1, L2, … , Ln in increasing order of slope O(n log n) time Initialize the data-structures for the “left-most” cut: O(n) time UHT, LHT, N[1..n], Stack I, M[1..n] (use the sorted order of step 1) 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).

Step 2 details O(n) time Li Li+1 Ln
Initialize UHT: Incrementally add Ln, Ln-1, … , Li+1, Li, …, L1. Go CCW along the Bay “up-wards” & eliminate lines until Li is added at the proper place. Implement the Bay as a stack. Li new Bay Li+1 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: c’i v w c’i+1 ? ci M[i+1] v w push vertex v Bay ci+2 ci+1 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).] Charge vertex v, 1 for each edge of the Bay we span (except the last). 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). 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. ci+2 c’i+1 ? c’i Bay w cut v 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 O(n2 log n) O(n) Plane Sweep Geometric Duality O(n2) O(n2) Arrangement Geometric Duality O(n2) O(n) 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 p*: y = ax + b Line L: y = ax + b  point L* = (-a , b) Technicality: Vertical lines can’t be represented by points in the dual space. How to avoid: 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. d(p,L) p L Notation: 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.

Geometric Duality d(p,L) p dV(p,L) L Lj Li pk pj Lk pi
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)). d(p,L) p L dV(p,L) Define: dV(pk ,L(pi , pj)) = vertical distance of pk from L(pi , pj). I(Li , Lj) = intersection point of dual lines Li & Lj. 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. pk pi pj Lk Li Lj CLAIM 2: dV(pk ,L(pi , pj)) = dV(I(Li , Lj) , Lk) Proof: Algebra exercise.

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: Sort by x-coordinate all O(n2) intersection points I(Li , Lj), 1  i < j  n. 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. 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

Let P be any set of n  3 points in the plane, not all on a line
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. 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.] 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) . 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

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. 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.] 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.] 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.] r e f P

Consider a set P of n points in the plane
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 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.) 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. Using (b), prove that any set of n points in the plane has a n/3-splitter. Describe an O(n2) time algorithm for computing a n/3-splitter of P. 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.

Let P be a given set of n points in the plane
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. 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 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 − Prove that CH(S) = CH(q0 , q1 , , qn-1 ). (f) Show that CH(S) can be computed in O(n) time.

END