Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.

Similar presentations


Presentation on theme: "UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing."— Presentation transcript:

1 UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing

2 UNC Chapel Hill M. C. Lin Thematic Map Overlay GIS systems split each map into several layers Each layer is called a thematic map, storing one type of information Find overlay of several maps to locate interesting junctions

3 UNC Chapel Hill M. C. Lin Transform to a Geometric Problem Curves can be approximated by small (line) segments Each thematic map can be viewed as a collection of line segments Finding the overlay of two networks => computing all intersection points between the line segments of two sets

4 UNC Chapel Hill M. C. Lin Let’s Be More Serious & Precise... Segments closed or open? –Take a look at the original problem => should be closed To simplify further, make 2 sets into 1 –But, how do we identify the really interesting one? Filter them out by checking if they are from the same set.

5 UNC Chapel Hill M. C. Lin Problem Analysis Brute Force Approach: O(n 2 ) Desiderata: output(intersection) sensitive –Segments that are close together are the candidates for intersection x y

6 UNC Chapel Hill M. C. Lin Plane Sweep Algorithm Status of l : the set of segments intersecting l Event points: where updates are required l : sweep line event point

7 UNC Chapel Hill M. C. Lin Plane Sweep Algorithm (cont) At a event point: update the status of the sweep line & perform intersection tests Upper: a new segment is added to the status of l and it’s tested against the rest Lower: it’s deleted from the status of l => Only testing pairs of segments for which there is a horizontal line intersects both segments. => But, this is not good enough. It may still be inefficient, O(n 2 ) for some cases. (ex) a set of segments all intersect with x-axis.

8 UNC Chapel Hill M. C. Lin Plane Sweep Algorithm (cont) To include the idea of being close in the horizontal direction, only test segments that are adjacent in the horizontal direction -- Only test each with ones to its left and right New “status”: ordered sequence of segments New “event points”: endpoints and intersects l SjSj SkSk SlSl SmSm

9 UNC Chapel Hill M. C. Lin Nasty Cases (Degeneracies) Horizontal lines Overlapping line segments Multiple line segments intersect at one single point

10 UNC Chapel Hill M. C. Lin Plane-Sweep Algorithm (Recap) Move a horizontal sweep line l downwards Halt l at event points (end pts & intersects) While l moves, maintain ordered sequence of segments intersected by it When l halts at an event point, the sequence of segments changes, status of l needs to be updated and to detect intersections depending on type of events

11 UNC Chapel Hill M. C. Lin Event Types NOTE: only intersection points below l are important, assuming all intersection points above l have been computed correctly. Upper end point: If S i and S k are adjacent on l, a new upper end point of S j appears, check S j with S i and S k for intersections Intersection point of 2 lines: Change their order. Each gets (at most) 1 new neighbor Lower end point: Its two neighbors are now adjacent and must be tested for intersection below the sweep line l

12 UNC Chapel Hill M. C. Lin Data Structure Type: Event queue that stores events Operations –remove next event and return it to be treated –among 2 events with the same y-coordinate, the one with smaller x-coordinate is returned (left-to-right priority order) –allow for insertions & check if it is already there –allow 2++ event points to coincide (ex) two upper end points coincide

13 UNC Chapel Hill M. C. Lin Implementing Event Queue Define an order on event points, according to which they will be handled Store the event points in a balanced binary search tree T according to their orders –both fetching & insertion takes O(log m) time, where m is the number of events Maintain the status of l using T –the left-to-right order of segments on the line l the left-to-right order of leaves in T –segments in internal nodes guide search –each update and search takes O(log m)

14 UNC Chapel Hill M. C. Lin Status Structure, T l SjSj SkSk SlSl SmSm SiSi SiSi SjSj SkSk SlSl SmSm SiSi SjSj SkSk SlSl T

15 UNC Chapel Hill M. C. Lin FindIntersections (S) Input : a set S of line segments in a plane Output : a set of intersections and their associated line segments in S 1. Initialize Q. Insert the end points into Q with their corresponding segments 2. Initialize an empty status structure T 3. While Q is not empty 4. Do Find next event point p in Q & delete it 5. HandleEventPoint ( p )

16 UNC Chapel Hill M. C. Lin Handling Changes in Status l S4S4 S1S1 S3S3 S8S8 S7S7 S5S5 S2S2 S1S1 S3S3

17 UNC Chapel Hill M. C. Lin Handling Changes in Status S7S7 S3S3 S1S1 S8S8 S3S3 S2S2 S1S1 S2S2 S7S7 T S1S1 S3S3 S8S8 S5S5 S4S4 S1S1 S3S3 S7S7 S5S5 S4S4 S7S7 T S2S2 l S4S4 S1S1 S3S3 S8S8 S7S7 S5S5 S1S1 S3S3

18 UNC Chapel Hill M. C. Lin HandleEventPoint (p) 1. Let U(p) be set of segments whose upper end point is p 2. Search in T for set S(p) of all segments that contains p ; they are adjacent in T. Let L(p)  S(p) be the set of segments whose lower endpts in p and C(p)  S(p) be the set of segments that contains p in its interior 3. If L(p)  U(p)  C(p) contains more than 1 segment 4. then Report p as an intersect with L(p), U(p) and C(p) 5. Delete segments in L(p)  C(p) from T 6. Insert segments in U(p)  C(p) into T. Order segments in T according to their order on sweep line just below p. A horizontal one comes last among all containing p.

19 UNC Chapel Hill M. C. Lin HandleEventPoint (p) 7. (Deleting & re-inserting segments of C(p) reverses order) 8. If U(p)  C(p) = 0 9. then Let s l and s r be the left/right neighbors of p in T 10. FindNewEvent (s l, s r, p ) 11.else Let s ’ be the left most segment of U(p)  C(p) in T 12. Let s l be the left neighbor of s ’ in T 13. FindNewEvent( s l, s ’, p ) 14. Find s ’’ be rightmost segment of U(p)  C(p) in T 15. Let s r be the right neighbor of s ’’ in T 16. FindNewEvent( s ’’, s r, p )

20 UNC Chapel Hill M. C. Lin FindNewEvent (s l, s r, p) 1. If s l and s r intersect below the sweep line, or on it and to the right of current point p, and the intersection is not yet present as an event in Q 2. Then Insert the intersection point as an event into Q

21 UNC Chapel Hill M. C. Lin Algorithm Analysis Let S be a set of n segments in a plane All intersections in S can be reported in –O(n log n + I log n) time –O(n) space –where I is the number of intersection points

22 UNC Chapel Hill M. C. Lin Doubly-Connected Edge List 3 records: vertices, faces and “half-edges” Vertex: coordinates(v) & a ptr to a half-edge Face: –OuterComponent(f): bounding edges –InnerComponent(f): edges on the boundary of holes contained in the face, f Edge: a ptr to Origin(e), a ptr to a twin-edge, ptrs to Next(e) & Prev(e) edges and its left IncidentFace(e)

23 UNC Chapel Hill M. C. Lin Computing Overlay of Subdivisions Let S 1, S 2 be two planar subdivisions of complexity n 1 and n 2 respectively; and let n = n 1 + n 2 Overlay of S 1 and S 2 can be constructed in O(n log n + k log n) time, where k is the complexity of overlay

24 UNC Chapel Hill M. C. Lin Boolean Operations Let P 1, P 2 be two polygons with n 1 and n 2 vertices respectively; and let n = n 1 + n 2 Their boolean operations (intersection, union, and difference) can each be computed in O(n log n + k log n) time, where k is the complexity of the output


Download ppt "UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing."

Similar presentations


Ads by Google