1 / 47

COSC 6114

COSC 6114. Prof. Andy Mirzaian. Intersections. TOPICS. Line Segments Intersections Planar Subdivision Thematic Map Overlay. Line Segments Intersections Thematic Map Overlay. Photos courtesy of ScienceGL. Applications :. Graphics: hidden line/surface removal

bien
Download Presentation

COSC 6114

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COSC 6114 Prof. Andy Mirzaian Intersections

  2. TOPICS • Line Segments Intersections • Planar Subdivision • Thematic Map Overlay

  3. Line Segments IntersectionsThematic Map Overlay Photos courtesy of ScienceGL

  4. Applications: • Graphics: hidden line/surface removal • GIS: Geographic Information Systems • Cartography • VLSI circuit layout • Pattern recognition • Optimization: Linear Programming • Arrangement of lines, planes, hyper-planes • Visibility, kernels, etc. • References: • [CLRS] chapter 33 • [M. de Berge et al] chapter 2 • [Preparata-Shamos’85] chapter 7 • [O’Rourke’98] chapter 7

  5. Line Segments Intersection Problem Given a set L={ l1,l2, … , ln } of n line segments in the plane, report all pair-wise intersections in L.(Modes: reporting, counting or disjointness.) • Naïve approach: check every pair in L in O(n2) time. • Can we make this output sensitive? • Suppose there are a total of R intersecting pairs to report, where 0  R  (n2). • O(n log n) time for counting & disjointness mode. • O(R + n log n) time is achievable for reporting mode.See also end of Lecture Slide 7.

  6. Special Case: rectilinear L Assume segments in L arevertical (blue)orhorizontal (red), and each intersection is between a red-blue pair. e.g., in VLSI

  7. Special Case: rectilinear L Assume segments in L are vertical (blue) or horizontal (red), and each intersection is between a red-blue pair. Sweep-line d d c D a a e b b • Plane Sweep Method: vertical sweep-line moving left-to-right. • Active segments: horizontal segments that intersect the sweep-line. • Sweep event schedule: x-sorted segment endpoints (2 per red, 1 per blue). • Sweep Status: y-ordering of the active horizontal segments maintained in an efficient dictionary D.

  8. Special Case: rectilinear L Assume segments in L are vertical (blue) or horizontal (red), and each intersection is between a red-blue pair. Sweep-line d d c c D a a e b b • Plane Sweep Method: vertical sweep-line moving left-to-right. • Active segments: horizontal segments that intersect the sweep-line. • Sweep event schedule: x-sorted segment endpoints (2 per red, 1 per blue). • Sweep Status: y-ordering of the active horizontal segments maintained in an efficient dictionary D.

  9. Special Case: rectilinear L Assume segments in L are vertical (blue) or horizontal (red), and each intersection is between a red-blue pair. Sweep-line d e2 d c c e2 D a a e b b e1 e1 • Plane Sweep Method: vertical sweep-line moving left-to-right. • Active segments: horizontal segments that intersect the sweep-line. • Sweep event schedule: x-sorted segment endpoints (2 per red, 1 per blue). • Sweep Status: y-ordering of the active horizontal segments maintained in an efficient dictionary D.

  10. Special Case: rectilinear L Assume segments in L are vertical (blue) or horizontal (red), and each intersection is between a red-blue pair. Sweep-line d c a e b • Plane Sweep Method: vertical sweep-line moving left-to-right. • Active segments: horizontal segments that intersect the sweep-line. • Sweep event schedule: x-sorted segment endpoints (2 per red, 1 per blue). • Sweep Status: y-ordering of the active horizontal segments maintained in an efficient dictionary D. • Computational Complexity: • O(n) space • O(R + n log n) time - reporting mode • O(n log n) time - counting or disjointness modes.

  11. s2 D O(log n) forcounting or disjointness test RangeReport (s,D)O(Rs+ log n) time Rs = # with s s s1 s1 s2 Total time = O( n log n + s(Rs+ log n) ) = O(R + n log n). • Q  {x-sorted end-points of segments in L} Sweep Schedule • D  Sweep Status • for each event (p,s)Q in sorted order do O(n) iterations • if p is left-end of horizontal s then Insert (s,D) O(log n) time • if p is right-end of horizontal s then Delete (s,D) O(log n) time • if s is vertical then RangeReport (s,D) O(Rs+ log n) time • end AlgorithmRectilinear-Intersection-Report(L)

  12. General Case Bentley-Ottman [1979], “Algorithms for reporting and counting geometric intersections,” IEEE Trans. Comput. C-28:643-647.O((R+n) log n) reporting time & O(n) space. D A sweep-line See also AAW E C B ECBAD EADC ECAD EACD EAD CBAD   ED CBA BA A E Sweep status: • Improvements: • Balaban [1995], “An optimal algorithm for finding segments intersections,” Proc. SoCG, pp:211-219.O(R + n log n) reporting time & O(n) space. • Lecture Slide 7: Randomized Algorithm in O(R + n log n) expected time.

  13. Bentley-Ottman • Data Structures: • Sweep Status D: an efficient dictionary to maintain the linear order of active segments in the order they intersect the sweep-line. • Sweep Schedule Q: a priority queue of sweep events (priority=x-coordinate). segments left/right end pointsEvent points = pair-wise segments intersection pointsBook-keeping:a constant number of two-way pointers between each segment and its contributed events in Q.

  14. Bentley-Ottman Temporary assumption: No two events have the same priority. (lexicographic) FACT:Let p = lilj be an intersection event, and q its predecessor event. Just after q is processed, both li and lj are active and adjacent in the linear ordering of the sweep status D.Proof: The shaded region must be empty of segments. li p q lj Corollary:Every intersection event can eventually be detected and inserted into Q before the sweep-line gets past it.Proof:Each time the sweep status D changes, check its affected adjacent active segment pairs to see if they intersect to the right of the sweep-line.

  15. Time = O( (R+n) log n ) Space used: |D| = O(n) size O(R+n) without “trimming” (see next slide) |Q| = O(n) with “trimming” Algorithm Bentley-Ottman(L) O( (R+n) log n ) time Q  {the 2n end-points of segments in L} n=|L| D   while Q do 2n+R iterations e  DeleteMin(Q) O(log n) time ProcessEvent(e) O(log n) time end

  16. ProcedureProcessEvent(e)O(log n ) time 1. Ife is left end-point of segment s then Insert (s,D); A  Above(s,D); B  Below(s,D) Insert As and/or Bs into Q if they are “future” events Trim: Delete AB from Q if it’s a “future” events 2.If e is right end-point of segment s then A  Above(s,D); B  Below(s,D); Delete(s,D) Insert AB into Q if it’s a “future” event 3.If e is si sjthen{ suppose si = Above(sj,D) } Interchange(si,sj,D); A  Above(sj,D); B  Below(si,D) Insert Asj and/or Bsi into Q if they are “future” events Trim: Delete Asi and Bsj from Q if “future” events REPORT (e = si sj) end A s e B A s e B A si e sj B

  17. How to search in Dictionary D: • D maintains the y-ordering of the active line segments. • Each item in D is a line segment, with no explict “key”. • How do we search in D for an event point e? • Ask “is e vertically above/below node segment?”,then go to right/left subtree accordingly. B E D A D e E C C B A Search path of e in the dictionary sweep line

  18. Generalizations of Bentley-Ottman • edges with common end-points edge – vertex intersections • Trapezoidal Decomposition (or Vertical Visibility Map) These can be done during the plane-sweep without increase in computational complexity.

  19. Sweep technique for intersection of other kinds of objects CONVEXNON-CONVEX A is above B Is A above B? A A B B

  20. Planar Subdivision

  21. Planar Subdivision Euler’s Formula: V – E + F – C = 1 vertex edge face V =10 # verticesE =16 # edgesF = 8 # facesC =1 # connected components

  22. Planar Subdivision Dual vertex  face edge  edge face  vertex

  23. Planar Subdivision Dual vertex  face edge  edge face  vertex

  24. Planar Subdivision Dual

  25. Euler’s Formulaforconnectedplanar graphs V – E + F = 2 For a spanning tree of the graph E=V-1, F=1.(V) – (V-1) + (1) = 2. Formula is satisfied. Now add the missing edges one by one. Each such edge increments E and F by 1.

  26. Euler’s Formulafor connected planar graphs V – E + F = 2 For a spanning tree of the graph E=V-1, F=1.(V) – (V-1) + (1) = 2. Formula is satisfied. Now add the missing edges one by one. Each such edge increments E and F by 1. Furthermore, if V  3 &each face has  3 boundary edges(i.e., no parallel or self-loop edges, e.g., straight-line connected planar subdivision)  In the dual graph each vertex has degree  3.Sum of vertex degrees = 2E. 3F  2E E  3V –6 F  2V –4 Now apply the above inequalityto Euler’s formula.

  27. Linear size Data structures for planar subdivisions • DCEL: Doubly Connected Edge List [Muller-Preparata 78] • WEDS: Winged-Edge Data Structure [Baumgart 75] • QEDS: Quad-Edge Data Structure [Guibas-Stolfi 85] • These can also be used for 3D polyhedral boundary representation. • DCEL can also represent disconnected planar graphs. • QEDS can represent graphs embedded on arbitrary 2-manifolds.

  28. DCEL: Doubly Connected Edge List • Half-Edge-List: Each edge as a pair of oppositely oriented twin half-edges. For each half-edge e: Origin(e), Twin(e), Next(e), Prev(e), IncidentFace(e). Twin(e) IncidentEdge(v) the face on theright side of e v Origin(e) e Prev(e) Next(e) IncidentFace(e) • Vertex-List: For each vertex v: IncidentEdge(v) is an arbitrary half-edge e, such that v = Origin(e). • Face-List: For each face f: OuterComp(f) : an arbitrary half-edge e incident to the outer boundary of f such that f = IncidentFace(e)InnerComps(f) : list of one such incident half-edge per inner-face boundary. f

  29. Components of WEDS and QEDS • Face List: a list indexed by faces. face-edge(f) = an arbitrary edge on the boundary of f. • Vertex List: a list indexed by vertices. vertex-edge(v) = an arbitrary edge incident on vertex v. • Edge Data Structure: This is where WEDS and QEDS differ. WEDS: Winged Edge Data Structure v1 e1- e1+ e f1 f0 e0- e0+ v0 record(e) = v0 , v1 , f0 , f1 , e0- , e0+ , e1- , e1+

  30. each edge-record is in 4 cycles: h 5 C 4 g D 3 d e B f A c 1 0 a b 2 QEDS: Quad Edge Data Structure Simultaneously represents primal & dual on any 2-manifold. C h 5 Dual graph Primal graph 4 4 g’ 5 d’ C g 3 B d A e’ 3 c’ e B f A c 1 f’ b’ 2 a’ h’ 0 a D 1 b 2 D 0

  31. Trapezoidal Decomposition of the overlay map OM(S1,S2) Overlay of two planar straight-line subdivisions Maps S1 and S2

  32. Proof: Let D1 = DCEL(S1) andD2 = DCEL(S2). We want to compute D = DCEL( OM(S1,S2) ).Start with D  D1  D2 and do Bentley-Ottman. • edge-edge intersection: e1 e2 • vertex-edge intersection: e v THEOREM:Let S1 and S2 be straight-line planar subdivisions of complexity n1 and n2 respectively, and n= n1+n2. The overlay map OM(S1,S2) can be constructed by generalization of Bentley-Ottman in O((R+n) log n) time, where R is the complexity of the overlay.

  33. C v(C1) Cycle-Incidence-Graph G: C1 C3 C2 C C1 C3 C0 C5 C4 C6 C0 C2 C7 C4 C7 C6 outer hole C8 C5 C8 How to compute several boundary cycles of a face in the overlay(an outer-face and several inner-face boundaries). • Use the info from the trapzoidization to find which boundary cycles belong to the same face as follows: • v(C)  topmost vertex of boundary cycle C. • The half-edges of C incident to v(C) determine whether C is an outer boundary or a hole. • Use Up-Vertical visibility chord of v(C) for every hole C to construct the • Cycle-Incidence-Graph G • Vertices of each connected component of G are boundary cycles of the same face of the subdivision.

  34. Boolean Operations: An application of the map overlay algorithm. Given simple polygons P1 and P2 , compute: P1 P2 P1 P2 P1 P2 This also takes O( (R+n) log n) time, where n = input complexity, R = output complexity.

  35. U. Finke and K. Hinrichs [1995], “Overlaying simply connected planar subdivisions in linear time,” SoCG’95, pp: 119-126. Show that OM(S1,S2) can be computed in O(R+n) time if S1 and S2 are connected straight-line planar graphs.

  36. Proof: A,B [ (A,B  P Q)  (A,BP)(A,BQ)  (AB  P)  (AB  Q)  (AB  PQ) ]. P Q B A ax + by = c Examples of convex sets: Lines, line segments, convex polygons, half-planes, etc. Line: ax + by = c Half-plane: ax + by  c (or ax + by  c ) ax + by c ax + by  c Intersection of two Convex Sets Fact 0: Intersection of any two convex sets is convex (possibly empty).

  37. Intersection of two Convex Polygons Let P and Q be convex polygons with, respectively, n and m vertices. Consider the convex (possibly empty) polygon R = PQ. Fact 1: R has at most n+m vertices. Proof: Let e be any edge of P. e’ = eQ is convex, hence, either empty, a single vertex of Q, or a sub-segment of e. In the latter case e’ is an edge of R. (Similarly, with e an edge of Q and e’ = eP.) Each edge e of P or Q can contribute at most one such edge e’ to R. P and Q have n and m edges, respectively. Hence, R can have at most n+m edges.

  38. Intersection of two Convex Polygons Fact 2:R = PQ can be computed in O(n+m) time. Proof: Use the plane-sweep method. The upper and lower chains of P and Q are x-monotone (from leftmost to rightmost vertex each). In O(n+m) time, merge these 4 x-sorted vertex-lists to obtain the n+m vertices of P and Q in x-sorted order. This forms the sweep-schedule. These n+m vertical sweep-lines partition the plane into n+m-1 vertical slabs. The intersection of each slab with P or Q is a trapezoid. The two trapezoids within a slab can be intersected in O(1) time. Hence, we can obtain PQ in O(n+m) time. slab

  39. Intersection of n Half-Planes Problem:Given n half-planes H1, H2, … , Hn, compute their intersection R = H1  H2  …  Hn . Input: Hi: ai x + bi y ci , i = 1..nOutput: convex polygon R (empty, bounded or unbounded). R

  40. Intersection of n Half-Planes Problem:Given n half-planes H1, H2, … , Hn, compute their intersection R = H1  H2  …  Hn . Divide-&-Conquerin O(n log n) time: (Use Facts 1 and 2.) (H1  …  Hn/2)  (H n/2 +1  …  Hn Convex P, |P|  n/2 T(n/2) time Convex Q, |Q|  n/2 T(n/2) time Convex R = PQ, |R|  |P|+|Q|  nO(n) time T(n) = 2 T(n/2) + O(n) = O(n log n).

  41. An Art Gallery Problem We are given the floor-plan of an art gallery (with opaque walls) represented by a simple polygon P with n vertices. Is it possible to place a single point camera guard (with 360 vision) in the gallery so that it can “see” every point inside the gallery? • The set of all such points is called the “Kernel” of P. • If Kernel(P) is not empty, then P is called a “star” polygon. P

  42. An Art Gallery Problem We are given the floor-plan of an art gallery (with opaque walls) represented by a simple polygon P with n vertices. Is it possible to place a single point camera guard (with 360 vision) in the gallery so that it can “see” every point inside the gallery? • The set of all such points is called the “Kernel” of P. • If Kernel(P) is not empty, then P is called a “star” polygon. • Kernel(P) is the intersection of n half-planes defined by P’s edges. P

  43. An Art Gallery Problem We are given the floor-plan of an art gallery (with opaque walls) represented by a simple polygon P with n vertices. Is it possible to place a single point camera guard (with 360 vision) in the gallery so that it can “see” every point inside the gallery? • The set of all such points is called the “Kernel” of P. • If Kernel(P) is not empty, then P is called a “star” polygon. • Kernel(P) is the intersection of n half-planes defined by P’s edges. • Kernel(P) can be computed in O(n log n) time by divide-&-conquer. • It can be computed in O(n) time by a careful incremental method that scans the edges of P in order around its boundary. How? P

  44. Exercises

  45. Nested Circles: We are given a set C = {C1 , ... , Cn} of n circles in the plane. Each circle is given by the xy-coordinates of its center and its radius. One of these circles is the bounding circle and encloses the remaining n -1 circles in C. All circles in C have disjoint boundaries. So, for any pair of circles Ci and Cj in C, either they are completely outside each other, or one encloses the other. Therefore, we may have several levels of nesting among these circles. (See Figure 1(a) below.) We say Ci is immediately enclosed by Cj, if Cj is the smallest circle that encloses Ci. This relationship corresponds to the parent-child relationship in the Nesting Tree of C. (See Figure 1(b) below.) The problem is: given C, construct its Nesting Tree by parent pointers, that is, output the array p[1.. n] such that p[i] = j means Ci is immediately enclosed by Cj .(a) Briefly describe a simple O(n2) time algorithm to solve the problem.(b) Design and analyze an O(n log n) time algorithm to solve the problem.

  46. We are given a set T of n triangles and a set P of n points, all in the plane. The triangles in T have disjoint boundaries, but some triangles may enclose some others. There may be several nested levels of such enclosures. Design and analyze an O(n log n) time algorithm that reports all points in P that are outside all triangles in T. • Design efficient plane-sweep algorithms to decide whether a given set S of n objects from a certain object class is pair-wise disjoint for the following cases:(a) Objects are circular disks. (A disk includes the interior.)(b) Objects are circles. (A circle does not include the interior.)(c) Objects are axis-parallel rectangular areas. • We are given n axis-parallel rectangular areas in the plane. Assume the plane background is white and the given rectangle areas are painted blue. Design an O(n log n) time algorithm to compute the total blue area. • We are given two simple polygons P and Q with n and m vertices, respectively.(a) Devise an efficient algorithm to test whether P is completely inside Q?(b) Show an O(n+m) time solution if in addition we know Q is convex. • Show the kernel of a given simple polygon can be computed in linear time.

  47. END

More Related