Download presentation

Presentation is loading. Please wait.

1
**Computational Geometry**

Hwangryol Ryu Dongchul Kim

2
**Computational Geometry**

Intersection of line segment Basic geometric objects Point : ( x, y ) Line : {(x1,y1) , (x2,y2) } Line segment : size of line is given (x2,y2) (x2,y2) (x1,y1) (x1,y1)

3
**Basic geometric objects(contd)**

Polygon Convex Non-convex Convex : Each indegree less than 180

4
**Intersection of line segment**

Input : a pair of line segments Output : yes – if they intersect no – otherwise How do we know that intersection(x,y) exits between two lines? (x, y)

5
**Intersection of line segment(…contd)**

Algorithm Find equation of first segment Y=m1x+c1 Find equation of second segment Y=m2x+c2 Find intersection of two lines : (x,y) If ( x1 < x < x2 ) && ( x3 < x < x4 ) Then return (Intersection exits) Else return (No intersection exits) (x2,y2) (x1,y1) (x, y) (x3,y3) (x4,y4)

6
**Intersection of line segment(…contd)**

Is there a pair of line segments intersecting each other? Naive algorithm: Check each two segments for intersection. Complexity: O(n2).

7
**Plane Sweep – Algorithm**

Event is any end point or intersection point. Sweep the plane using a vertical line. Maintain two data structures: Event priority queue – sorted by x coordinate. Sweep line status – Stores segments currently intersected by sweep line and maintain Red-Black Tree to support data structure.

8
**Plane Sweep – Algorithm**

Problem: Given n segments in the plane, compute all their intersections. Assume: No line segment is vertical. No two segments are collinear. No three segments intersect at a common point. Event is any end point or intersection point. Sweep the plane using a vertical line. Maintain two data structures: Event priority queue – sorted by x coordinate. Sweep line status – Stores segments currently intersected by sweep line, sorted by y coordinate.

9
**Plane Sweep - Basic Idea**

We are able to identify all intersections by looking only at adjacent segments in the sweep line status during the sweep. Theorem: Just before an intersection occurs, the two relevant segments are adjacent to each other in the sweep line status.

10
**Plane Sweep - Basic Idea(contd)**

In practice: Look ahead: whenever two line segments become adjacent along the sweep line, check for their intersection to the right of the sweep line.

11
**Plane Sweep – Algorithm**

Initialization: Add all segments’ endpoints to the event queue (O(n log n)). Sweep line status is empty. Algorithm proceeds by inserting and deleting discrete events from the queue until it is empty.

12
**Plane Sweep – Algorithm**

Event A: Beginning of segment Insert segment into sweep line status. Test for intersection to the right of the sweep line with the segments immediately above and below. Insert point (if found) into event queue. Complexity: n such events, O(log n) each O(n log n) total.

13
**Plane Sweep – Algorithm**

Event B: End of segment Delete segment from sweep line status. Test for intersection to the right of the sweep line between the segments immediately above and below. Insert point (if found) into event queue. Complexity: n such events, O(log n) each O(n log n) total.

14
**Plane Sweep – Algorithm**

Event C: Intersection point Report the point. Swap the two line relevant segments in the sweep line status. For the new upper segment – test it against its predecessor for an intersection. Insert point (if found) into event queue. Similar for new lower segment (with successor). Complexity: k such events, O(logn) each O(klogn) total.

15
**Plane Sweep – Example Ex1) s3 e1 s4 s2 s1 s0 Sweep Line Status**

b4 Ex1) s3 e1 s4 a2 a4 b3 s2 b1 b0 s1 b2 s0 a1 a0 Sweep Line Status Event Queue s0,s1,s2,s3 a4, b1, b2, b0, b3, b4

16
**Plane Sweep – Example s3 e1 s4 s2 s1 s0 Insert s4 to SLS**

b4 s3 e1 s4 a2 a4 b3 s2 b1 b0 s1 b2 s0 a1 a0 Insert s4 to SLS Test s4-s3 and s4-s2. Add e1 to EQ s0,s1,s2, s4, s3 b1, e1, b2, b0, b3, b4 Action Sweep Line Status Event Queue

17
**Plane Sweep – Example s3 e1 s4 s2 e2 s1 s0 Delete s1 from SLS Action**

b4 s3 e1 s4 a2 a4 b3 s2 e2 b0 s1 b1 b2 s0 a1 a0 Delete s1 from SLS Test s0-s2. Add e2 to EQ s0,s2,s4,s3 e1, e2, b2, b0, b3, b4 Action Sweep Line Status Event Queue

18
**Plane Sweep – Example s3 e1 s4 s2 e2 s1 s0 Swap s3 and s4 . Action**

b4 s3 e1 s4 a2 a4 b3 s2 e2 b0 s1 b1 b2 s0 a1 a0 Swap s3 and s4 . Test s3-s2. s0,s2,s3,s4 e2, b2, b0, b3, b4 Action Sweep Line Status Event Queue

19
**Plane Sweep – Complexity Analysis**

Total time complexity: O((n+k) logn). If kn2 this is almost like the naive algorithm. Event queue: heap Sweep line status: balanced binary tree Total space complexity: O(n+k).

Similar presentations

Presentation is loading. Please wait....

OK

Polygon Triangulation

Polygon Triangulation

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on railway track design Ppt on shell scripting expect Ppt on k-map simplification Ppt on power grid failure prep Ppt on review of literature science Ppt on applied operational research ppt Ppt on network switching infrastructure Ppt on network monitoring system Ppt on basic etiquette and manners Pdf to ppt online nitro