Presentation is loading. Please wait.

Presentation is loading. Please wait.

COSC 6114 Prof. Andy Mirzaian. References: [Preparata-Shamos85] chapter 1.3 [Edelsbrunner87] chapter 1.6, 4.2, 14 [ORourke98] chapter 6 [Matoušek] Lecture.

Similar presentations

Presentation on theme: "COSC 6114 Prof. Andy Mirzaian. References: [Preparata-Shamos85] chapter 1.3 [Edelsbrunner87] chapter 1.6, 4.2, 14 [ORourke98] chapter 6 [Matoušek] Lecture."— Presentation transcript:

1 COSC 6114 Prof. Andy Mirzaian

2 References: [Preparata-Shamos85] chapter 1.3 [Edelsbrunner87] chapter 1.6, 4.2, 14 [ORourke98] 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, ORourke, 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 …

3 Super-sampling in 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. Determining visible objects by ray tracing.

4 Computing the Discrepancy S (h) = |1/4 – 3/10 | = 0.05 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: (h) = area(h U) continuous measure S (h) = |S h| / |S| discrete measure S (h) = | (h) - S (h) | discrepancy of h H (S) = sup h H S (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: H (S) can be computed in O(n 2 ) time, using Geometric Duality & Arrangement of lines in the plane.

5 geometric duality 2D arrangements of lines Incremental Construction Ham-Sandwich Cuts Topological Sweep Applications


7 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.

8 1. Hough (or Reciprocal) Transform (1969) d Point: (a 1, a 2, …, a d ) origin Hyper-plane: a 1 x 1 +a 2 x 2 +… +a d x d +1 = 0 not passing through the origin 2 Point: (a,b) (0,0) Line: ax + by + 1 = 0 p* = dual of p d(0,p) d(0,p*) = 1 The origin is above the line. (a,b) ax + by + 1 = 0 slope = -a/b 1/d d x y

9 2. Another Point-Line Transform (a,b) y=ax + b slope = a x y 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.

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

11 Duality Transforms Preserve Incidence 1.Point p is mapped to line p*. 2.Line l is mapped to point l*. 3.Point p and line l are incident line p* and point l* are incident 4.Above/Below relation is also preserved (or reversed). 5.Line l passes through points p & q Lines p* & q* intersect at point l*. 6.Points p, q, r are collinear Lines p*, q*, r* are concurrent. l p l* p* l p l* l p p* q q* l p l* p* q q* r* r They preserve incidence since they are affine transforms

12 Problem Transformation by Duality Problem 1: Compute the discrepancy: p q p*q* L* PRIMAL PLANE DUAL PLANE L 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)

13 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 l1l1 PRIMAL PLANE DUAL PLANE l2l2 l3l3 l4l4 l1*l1* l2*l2* l3*l3* l4*l4* 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?

14 Arrangements

15 Arrangements of lines and hyper-planes L = { l 1, l 2, …, l n } 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 2 (each line is cut into n edges) F = # regions = ( n 2 ) Euler: (V+1) – E + F = 2 vertex at F = ( n 2 + n + 2 ) / 2

16 Arrangement Construction Will take at least (n 2 ) time & space, due to combinatorial size of A ( L ). 1.Plane Sweep: At least (n 2 log n) time, since it will sort the arrangement vertices. 2.Naïve Incremental Algorithm A ({ l 1, l 2, …, l k-1 }) A ({ l 1, l 2, …, l k }), for k=2..n Binary Search to find v i1, v i+1,1. O(log k) for each of l 1, l 2, …, l k-1. O(k log k) to insert l k. Total O( k k log k) = O(n 2 log n) time, and O(n 2 ) space. lklk l1l1 v i1 v i+1,1

17 Refined Incremental Algorithm How to insert l k in A ({ l 1, l 2, …, l k-1 }) ? lklk l1l1 u0u0 u1u1 u2u2 u3u3 v0v0 v1v1 v2v2 lmlm upward movement on one side of l 1 downward movement on the other side of l 1

18 Refined Incremental Algorithm How to insert l k in A ({ l 1, l 2, …, l k-1 }) : 1.Find u 0 = l 1 l k and rightmost vertex v 0 on l 1 to the left of u 0, in O(k) time. Let v 0 v 1 be CCW from v 0 u 0 on vertex v 0. 2.If segment v 0 v 1 intersects l k, then we have closed a polygonal line that starts from a previous intersection point, namely u 0, and ends in another intersection point, namely u 1. Therefore, we can insert u 1 properly in the adjacency list. We now go to u 1 and repeat steps 1,2,3 with u 1 as the new u 0 and l m as the new l 1. 3.If v 0 v 1 does not intersect l k, then we take the next vertex v 2 CCW on v 1 from v 1 v 0 and repeat the same procedure. 4.When we encounter a vertex that has a leftmost edge which is a ray diverging from l k, we have finished the upward movement. 5.We do a similar downward movement, starting from v 0, on the other side of l 1.

19 ZONE of a line in the arrangement Zone of l k = collection of the polygonal regions of the arrangement that have an edge on l k. Combinatorial complexity of a zone = total number of vertices of the polygonal regions in the zone (counting multiplicities). lklk upper zone lower zone

20 ZONE Complexity THEOREM: Combinatorial complexity of zone of l k in A ({ l 1, l 2, …, l k-1 }) is 5k-6 on each side ( 10k–12 on both sides). lklk floor v top left walls right walls ceiling lklk ljlj e1e1 e2e2 e3e3 Proof 1: k convex polygonal regions incident to in the upper zone of l k (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 l j, j =1..k-1. Proof: e 1 ceiling e 3 s extension cuts P m 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 PiPi PmPm

21 Davenport–Schinzel Sequences DS s (n) : a 1 a 2 a 3 … n different characters a i a i+1 … … … … … … … (length s+2 alternating subsequence is forbidden) s (n) = max length DS sequence (n,s) Fact: 1 (n) = n 2 (n) = 2n-1 3 (n) = (n (n)) ( (n) = inverse Ackermanns function, very slow growing.) Example: max length of upper envelope of n (possibly crossing) line-segments in the plane = ( 3 (n) ).

22 ZONE Complexity THEOREM: Combinatorial complexity of zone of l k in A ({ l 1, l 2, …, l k-1 }) is 5k-6 on each side ( 10k–12 on both sides). lklk lklk Proof 2: By Davenport-Schinzel sequences. Consider the sequence of only left wall/ceiling edges in the traversal of upper-zone of l k (similarly for right … ). Claim: This is a (k-1, 2) DS sequence. That is, …a…b…a…b… is a forbidden sub-sequence. a b c d d b d c a c d ab Cannot contribute any left w/c...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-6 total lklk a b..a..a..a..b..b..b..

23 Arrangement Complexity THEOREM: The arrangement A(L) of n lines L = { l 1, l 2, …, l n } in 2 can be constructed in optimal time & space O(n 2 ). THEOREM: Let H = { h 1, h 2, …, h n } 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(n d-1 ). (b) A(H) can be constructed in optimal time & space O(n d ).

24 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 [lets 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 l level= 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 + n 2 ) = O(n 2 ).

25 Ham-Sandwich Cuts

26 Duality D: point p: (a,b) line p*: y = ax – b line l: y = x + point l*: (, - ) 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.

27 Ham-Sandwich Theorem Borsuk-Ulam Theorem [1933]: Let f: S d-1 | d-1 be any continuous mapping from the sphere S d-1 to d-1. Then, f(x) = f(-x) for some anti-podal pair x and –x on S d-1. (For details see [Ede87].) x -x S1S1 Ham-Sandwich Theorem: Let P 1, P 2, …, P d be d finite point sets in d. There exists a hyper-plane h in d that simultaneously bisects P 1, P 2, …, P d. Proof: By Borsuk-Ulam Theorem. Let x be an arbitrary point on the sphere S d-1. Consider the hyper-plane h(x) that bisects P d and has x as unit normal vector. Define f(x) = (n 1, n 2,, …, n d-1 ), where n k is # points of P k on the positive side of h(x), plus half the # points of P k on h(x). Note that, f(-x) = ( |P 1 | - n 1, |P 2 | - n 2, …, |P d-1 | - n d-1 ). Function f(x) can be made continuous. By Borzuk-Ulam Theorem, there is an x on S d-1 such that f(x) = f(-x). For such an x, h(x) is a ham-sandwich cut, i.e., simultaneously bisects P 1, P 2, …, P d. Stone-Tukey [1942]: Proved the continuous version: volume bisection.

28 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

29 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.

30 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. L COROLLARY: A set in 2D (also in 3D) can be 4-sected in linear time. 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 We will show:

31 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. P Q y X < 0X > 0 G H L* L P,Q L* Slope > 0 Slope < 0

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

33 (1)L med median-slope line in G H. L { L G H | slope(L) > slope(L med ) } (2)Pair up lines in L as much as possible into a set of pairs called Pairs. ( | | L | | lines of either 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(L med ) through intersections of those pairs in Pairs that are not in t1 +. (6)t2 line with slope (L med ) 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).) Finding test lines & pruning slope(L med ) t1 + t1 t2 q

34 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. Finding test lines & pruning t1 t2 q avoids q Proof: Define N = | L > |. L = N, |A| = min {N }, |B| N = + ½ |A|, # lines avoiding q ½ |B| ½ N = + ¼ min {N } 1/4 N = + ¼ min {N + N = } 1/4 N = + ¼ ½ L 1/8 L by median property NN> L

35 ALGORITHM: Ham-sandwich cut in the plane for 2 linearly separated point sets. Finding test lines & pruning t1 t2 q where s lies 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 ).

36 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: L1L1 L2L2 L3L3 L4L4 L5L5 L6L6 L8L8 L7L7 L1L1 L2L2 L2L2 L3L3 L3L3 L4L4 L4L4 L5L5 L5L5 L6L6 L6L6 L8L8 L8L8 L7L7 Preprocessing Time = O(n log n) Space = O(n) Query Time Q(n) = Q(n/2) + Q(n/4) + O(log n) = O(n ), = log (1+ 5)/2 < 0.69 Query Report = O(K + n ).

37 Half-plane Range Queries Ham-Sandwich Tree: Preprocessing Time = O(n log n) Space = O(n) Query Report = O(K + n ), = 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(n 2 ) preprocessing time & space to form A (P*), arrangement of dual of P. Preprocess A (P*) for point location in O(n 2 ) time & space. Query Time: O(K + log n).


39 Topological Sweep of Line Arrangements IDEA: It requires only O(n) space, instead of O(n 2 ) 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 = (c 1, c 2, …, c n ) is sequence of cut edges from top to bottom c1c1 c2c2 c3c3 c4c c1c1 c2c2 c3c3 c4c4 Technical Assumption: In the arrangement each edge is half-open; it contains its right end-point, but not its left-end-point. cut

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

41 Where to advance the cut C C LiLi LjLj above below FACT 1: Let C = (c 1, c 2, …, c n ) be any cut, except the right-most cut. Then at least one pair of adjacent edges of the cut, say (c i, c i+1 ), have a common right end-point. Proof: Let c i be the cut edge with the leftmost right end-point r i. We claim r i is either c i c i+1 or c i c i-1. riri cici c i+1 riri riri riri cici cici cici c i-1 impossible riri riri cici cici

42 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 : of intersection points (c i, c i+1 ) that are vertices of the arrangement Upper Horizon Tree (UHT) Lower Horizon Tree (LHT) M[1..n]: permutation of lines L 1, L 2, …, L n that contain edges of the cut C. N[1..n]: N[i] contains left & right ends of c i and tells which 2 lines delimit these end-points. Total space O(n).

43 Upper Horizon Tree UHT: For a given cut C = (c 1, c 2, …, c n ), 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.

44 A Cut Cut

45 UHT Cut Vertical line at x = not shown

46 LHT Cut x =

47 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.]

48 Topological-sweep overview 1.Sort L 1, L 2, …, L n in increasing order of slope O(n log n) time 2.Initialize the data-structures for the left-most cut: O(n) time UHT, LHT, N[1..n], Stack, M[1..n] (use the sorted order of step 1) 3.General Step: (n 2 ) iterations, each takes O(1) amortized time while stack do (3a) pop a vertex v = c i c i+1 from stack (3b) push the cut past vertex v and update the data-structures. end Total time = (n 2 ), space = O(n).

49 Step 2 details O(n) time Initialize UHT: Incrementally add L n, L n-1, …, L i+1, L i, …, L 1. Go CCW along the Bay up-wards & eliminate lines until L i is added at the proper place. Implement the Bay as a stack. LiLi L i+1 LnLn Bay 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 : Once N[1..n] is known, stack can be trivially obtained using FACT 3. Initialize M[1..n]: Use sorted order of step 1. new Bay

50 Step 3 details Pop vertex v=c i c i+1 from stack & 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+2 c i+1 ? cici Bay w c i+1 cici v w cut BeforeAfter push vertex v c i proceeds as before along M[i+1] in UHT. c i+1 : CCW scan the Bay starting from leaf c i+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). M[i+1] v

51 CLAIM: Step 3 takes O(1) amortized time per iteration. Corollary: Topological-sweep of an arrangement of n lines in the plane requires O(n 2 ) time but only O(n) space. 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. c i+2 c i+1 ? cici Bay w cut v

52 Application: Smallest Area Triangle Problem: Given n points in the plane, find 3 of the points with minimum possible triangle area. Solution tools used: geometric duality arrangement of lines plane sweep trapezoidal decomposition topological sweep Application: [Degeneracy Test] Are any of the 3 points collinear?

53 Application: Smallest Area Triangle SOLUTIONSTIME SPACE Brute forceO(n 3 )O(n) Geometric DualityO(n 2 log n)O(n 2 ) Geometric Duality +O(n 2 log n)O(n) Plane Sweep Geometric Duality +O(n 2 )O(n 2 ) Arrangement Geometric Duality +O(n 2 )O(n) Topological Sweep of Arrangement OPEN PROBLEM: Known lower and upper bounds on time complexity: (n log n) and O(n 2 ). Resolve the gap between the lower and upper bound. See next pages for details

54 Geometric Duality Primal spaceDual space Point p = (a,b) line p*: y = ax + b Line L: y = ax + b point L* = (-a, b) Technicality: Vertical lines cant 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: L i = p* i line dual to point p i. d(p,q) = Euclidean distance between the two points p and q. d(p,L) = orthogonal distance of point p from line L L(p i, p j ) = line (not line-segment) through points p i & p j.

55 Geometric Duality Primal Space: Take 2 points p i, p j. Find 3rd point p k that minimizes d(p k, L(p i,p j )). Then, triangle p i p j p k is the smallest area triangle with (p i,p j ) as one of its sides. Triangle Area = ½ d(p i,p j ) d(p k,L(p i, p j )). pkpk pipi pjpj LkLk LiLi LjLj CLAIM 2: d V (p k,L(p i, p j )) = d V ( (L i, L j ), L k ) Proof: Algebra exercise. CLAIM 1: The ratio d(p k,L(p i, p j )) d V (p k,L(p i, p j )) is fixed as p k varies among the remaining n-2 points. d(p,L) p L d V (p,L) Define: d V (p k,L(p i, p j )) = vertical distance of p k from L(p i, p j ). (L i, L j ) = intersection point of dual lines L i & L j.

56 Solution 1: Geometric Duality CONSEQUENCE: In the dual space consider the arrangement of lines L 1, L 2, …, L n and observe that vertical distance between (L i, L j ) and L k is attained only when L k is the line that is immediately above or below point (L i, L j ). Therefore, it belong to the same face of the Arrangement. ALGORITHM 1: 1.Sort by x-coordinate all O(n 2 ) intersection points (L i, L j ), 1 i < j n. 2.Order all L 1, L 2, …, L n 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 (L i, L j ), swap L i & L j 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(n 2 log n) time. The rest takes O(n 2 ) time by spending O(1) time per intersection point. Space is O(n 2 ).

57 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(n 2 log n) time and O(n) space. [O(log n) time per intersection point processed.]

58 Solution 3: Trapezoidal Decomposition in dual space ALGORITHM 3: Construct the arrangement of dual lines L 1, L 2, …, L n. (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(n 2 ) time and O(n 2 ) space.

59 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=c i c i+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(n 2 ) time and O(n) space.

60 Exercises

61 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(n 2 ) 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

62 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 {H 1, H 2, …, H n } 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(n 2 ) 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.] r e f P

63 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.) (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(n 2 ) 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. q

64 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 = { l 0, l 1,..., l n-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 l i is y = a i x + b i, then a 0 < a 1 <... < a n-1. Consider the arrangement A (L) of L in the plane. Let denote the set of all polygonal regions in the arrangement. Let denote the subset of consisting of only unbounded regions. For each polygonal region R, let size(R) denote the number of boundary edges of R. (a) Show that size(R) 2 | R } = O(n 2 ). [Hint: use aggregate of zones of lines in A (L).] (b) Show that size(R) | R } = 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 q i be the intersection of lines l i and l (i+1)modn, for i = 0.. n 1. Prove that CH(S) = CH(q 0, q 1,..., q n-1 ). (f) Show that CH(S) can be computed in O(n) time.

65 END

Download ppt "COSC 6114 Prof. Andy Mirzaian. References: [Preparata-Shamos85] chapter 1.3 [Edelsbrunner87] chapter 1.6, 4.2, 14 [ORourke98] chapter 6 [Matoušek] Lecture."

Similar presentations

Ads by Google