Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness,

Slides:



Advertisements
Similar presentations
Two Segments Intersect?
Advertisements

Polygon Triangulation
Incremental Linear Programming Linear programming involves finding a solution to the constraints, one that maximizes the given linear function of variables.
Spatial Information Systems (SIS) COMP Terrain modeling and geometric problems (part 2)
Computational Geometry
Map Overlay Algorithm. Birch forest Wolves Map 1: Vegetation Map 2: Animals.
Dynamic Planar Convex Hull Operations in Near- Logarithmic Amortized Time TIMOTHY M. CHAN.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
1/13/15CMPS 3130/6130: Computational Geometry1 CMPS 3130/6130: Computational Geometry Spring 2015 Convex Hulls Carola Wenk.
Brute-Force Triangulation
2/3/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Triangulations and Guarding Art Galleries II Carola Wenk.
9/12/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries II Carola Wenk.
1 Closest Points A famous algorithmic problem... Given a set of points in the plane (cities in the U.S., transistors on a circuit board, computers on a.
9/5/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Plane Sweep Algorithms and Segment Intersection Carola Wenk.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
November 4, Algorithms and Data Structures Lecture XIV Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Computational Geometry Piyush Kumar (Lecture 3: Convexity and Convex hulls) Welcome to CIS5930.
CS138A Line Segment Intersection Peter Schröder.
Computational Geometry -- Voronoi Diagram
17. Computational Geometry Chapter 7 Voronoi Diagrams.
Convex Hulls Computational Geometry, WS 2006/07 Lecture 2 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
Line Segment Intersection Computational Geometry, WS 2007/08 Lecture 3 – Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Lecture 12 : Special Case of Hidden-Line-Elimination Computational Geometry Prof. Dr. Th. Ottmann 1 Special Cases of the Hidden Line Elimination Problem.
Special Cases of the Hidden Line Elimination Problem Computational Geometry, WS 2007/08 Lecture 16 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen,
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Computational Geometry Overview from Cormen, et al. Chapter 33
Hidden-Line Elimination Computational Geometry, WS 2006/07 Lecture 14 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät.
Point Location Computational Geometry, WS 2007/08 Lecture 5 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik Fakultät für.
Closest Pair of Points Computational Geometry, WS 2006/07 Lecture 9, Part II Prof. Dr. Thomas Ottmann Khaireel A. Mohamed Algorithmen & Datenstrukturen,
Lecture 6: Point Location Computational Geometry Prof. Dr. Th. Ottmann 1 Point Location 1.Trapezoidal decomposition. 2.A search structure. 3.Randomized,
Line Segment Intersection Computational Geometry, WS 2006/07 Lecture 3 – Part II Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
Line Segment Intersection Computational Geometry, WS 2006/07 Lecture 3 – Part I Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen, Institut für Informatik.
Lection 1: Introduction Computational Geometry Prof.Dr.Th.Ottmann 1 History: Proof-based, algorithmic, axiomatic geometry, computational geometry today.
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
Brute-Force Triangulation
Advanced Algorithm Design and Analysis (Lecture 9) SW5 fall 2004 Simonas Šaltenis E1-215b
1 Geometric Intersection Determining if there are intersections between graphical objects Finding all intersecting pairs Brute Force Algorithm Plane Sweep.
9/7/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries Carola Wenk.
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
UNC Chapel Hill M. C. Lin Linear Programming Reading: Chapter 4 of the Textbook Driving Applications –Casting/Metal Molding –Collision Detection Randomized.
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
Line Arrangement Chapter 6. Line Arrangement Problem: Given a set L of n lines in the plane, compute their arrangement which is a planar subdivision.
14/13/15 CMPS 3130/6130 Computational Geometry Spring 2015 Windowing Carola Wenk CMPS 3130/6130 Computational Geometry.
The Lower Bounds of Problems
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 8 Arrangements and Duality.
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 8 Arrangements and Duality.
2/19/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Voronoi Diagrams Carola Wenk Based on: Computational Geometry:
CMPS 3130/6130 Computational Geometry Spring 2015
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness)
Computational Geometry: Intersection Search Joseph S. B. Mitchell Stony Brook University.
1 Chapter 6 Heapsort. 2 About this lecture Introduce Heap – Shape Property and Heap Property – Heap Operations Heapsort: Use Heap to Sort Fixing heap.
9/8/10CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2010 Triangulations and Guarding Art Galleries Carola Wenk.
Center for Graphics and Geometric Computing, Technion 1 Computational Geometry Chapter 9 Line Arrangements.
1/20/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Plane Sweep Algorithms I Carola Wenk.
Polygon Triangulation
Computational Geometry
CMPS 3130/6130 Computational Geometry Spring 2017
Computational Geometry
CMPS 3130/6130 Computational Geometry Spring 2017
Algorithm design techniques Dr. M. Gavrilova
CMPS 3130/6130 Computational Geometry Spring 2017
Divide and Conquer / Closest Pair of Points Yin Tat Lee
Computational Geometry Capter:1-2.1
CMPS 3130/6130 Computational Geometry Spring 2017
CMPS 3130/6130 Computational Geometry Spring 2017
Kinetic Collision Detection for Convex Fat Objects
Computational Geometry
CMPS 3120: Computational Geometry Spring 2013
Algorithms and Data Structures Lecture XIV
Presentation transcript:

Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness, and a good use for complicated data structures from CSE241). Some slides in this lecture come from Carola Wenk, Univ. Texas, San Antonio

Robert Pless, CS 546: Computational Geometry Lecture #3 Geometric Intersections Basic problem in Computational Geometry Solid modeling: Robotics: –Collision detection and avoidance Geographic information systems: –Overlay two subdivisions (e.g., road network and river network) Computer graphics: –Ray shooting/Photon Mapping to render scenes From UNC This environment consists of 25,000 tetrahedra (100,000 triangles) randomly placed within the scene. The flying object is a 747, which consists of nearly 15,000 triangles. (From Universitaat Salzburg). Photon mapped virtual environment: (w. chang, ucsd).

Robert Pless, CS 546: Computational Geometry Lecture #3 Line Segment Intersection Input: A set S={s 1, …, s n } of (closed) line segments in R 2 Output: All intersection points between segments in S

Robert Pless, CS 546: Computational Geometry Lecture #3 The basics. Two line segments ab and cd Write in terms of convex combinations: p(s) = (1-s) a + s b for 0  s  1 q(t) = (1-t) c + t d for 0  t  1 Intersection if p(s)=q(t)  Equation system (1-s) a x + s b x = (1-t) c x + t d x (1-s) a y + s b y = (1-t) c y + t d y Solve for s and t. –When is there no solution? –When do the segments intersect? a b

Robert Pless, CS 546: Computational Geometry Lecture #3 Bounds How many intersections can n line segments have? –0 < k < n 2 Really, from 0 to (n choose 2) Brute force algorithm? –Try out all pairs of line segments –Takes O(n 2 ) time, is optimal in worst case Challenge: Develop an output-sensitive algorithm –Runtime depends on size k of the output, 0  k  n 2 –What is best possible run time to expect? – O( n log n + k) (will talk about on next slide). –Our algorithm will have runtime: O( (n+k) log n) (with many intersections, this is worse than brute force).

Robert Pless, CS 546: Computational Geometry Lecture #3 Complexity Why is runtime O( n log n + k) optimal? –Element uniqueness: Given n real numbers, are all of them distinct? –The element uniqueness problem requires  (n log n) time ( in algebraic decision tree model of computation ) Reduction: element uniqueness to line segment intersection: –Take n numbers, convert into vertical line segments. There is an intersection iff there are duplicate numbers. –If we could solve line segment intersection in o(n log n) time, i.e., strictly faster than  (n log n), then element uniqueness could be solved faster. Contradiction.

Robert Pless, CS 546: Computational Geometry Lecture #3 Design of Plane Sweeps Plane sweep algorithms (also called sweep line algorithms) are a special kind of incremental algorithms Their correctness follows inductively by maintaining the cleanliness property –Algorithm is “clean” if the problem is “solved” to the left of the sweep line. Common runtimes in the plane are O(n log n): –n events are processed –Update of sweep line status takes O(log n) –Update of event queue: O(log n) per event

Robert Pless, CS 546: Computational Geometry Lecture #3 Event Q Sweep Line

Robert Pless, CS 546: Computational Geometry Lecture #3 Plane sweep algorithm Cleanliness property: –All intersections to the left of sweep line l have been reported Sweep line status: –Store segments that intersect the sweep line l, ordered by y-coordinate. Events: –When sweep line status changes combinatorially Left segment endpoints (known at beginning) Right segment endpoints (known at beginning) Intersection points (computed on the fly)

Robert Pless, CS 546: Computational Geometry Lecture #3 General position Assume that “nasty” special cases don’t happen: –No line segment is vertical –Two segments intersect in at most one point –No three segments intersect in a common point –(problems with this?)

Robert Pless, CS 546: Computational Geometry Lecture #3 Event Queue Need to keep events sorted: –Lexicographic order (first by x-coordinate, and if two events have same x-coordinate then by y-coordinate) Need to be able to remove next point, and insert new points in O(log n) time Use a priority queue (heap)

Robert Pless, CS 546: Computational Geometry Lecture #3 Sweep Line Status Store segments that intersect the sweep line l, ordered along the intersection with l. Need to insert, delete, and find adjacent neighbor in O(log n) time Use balanced binary search tree, storing the order in which segments intersect l in leaves b c d e cbedcbed

Robert Pless, CS 546: Computational Geometry Lecture #3 Event Handling Left segment endpoint –Add segment to sweep line status –Test adjacent segments on sweep line l for intersection with new segment (see Lemma) –Add new intersection points to event queue a b c d e cbdcbd cbedcbed

Robert Pless, CS 546: Computational Geometry Lecture #3 Event Handling 2. Intersection point –Report new intersection point –Two segments change order along l ? Test new adjacent segments for new intersection points (to insert into event queue) a b c d e cebdcebd cbedcbed Note: “new” intersection might have been detected before.

Robert Pless, CS 546: Computational Geometry Lecture #3 Event Handling 3. Right segment endpoint –Delete segment from sweep line status –Two segments become adjacent. Check for intersection points (to insert in event queue) a b c d e ecbdecbd ecdecd

Robert Pless, CS 546: Computational Geometry Lecture #3 Correctness proof. We only report intersections that actually occur. Do we report all intersections? We only check for intersections between segments that are neighbors in the sweep line data structure. Is that enough? Intersection Lemma Lemma: Let s, s’ be two non-vertical segments whose interiors intersect in a single point p. Assume there is no third segment passing through p. Then there is an event point to the left of p where s and s’ become adjacent (and hence are tested for intersection). Proof: Consider placement of sweep line infinitesimally left of p. s and s’ are adjacent along sweep line. Hence there must have been a previous event point where s and s’ become adjacent. p s s’

Robert Pless, CS 546: Computational Geometry Lecture #3 Runtime Sweep line status updates: O(log n) Event queue operations: O(log n), as the total number of stored events is  2n + k, and each operation takes time O(log(2n+k)) = O(log n 2 ) = O(log n) There are O(n+k) events. Hence the total runtime is O((n+k) log n) k = O(n 2 )

Robert Pless, CS 546: Computational Geometry Lecture #3 Backing out of general position. Suppose a segment is vertical. How can you fix the algorithm? –Function specialVerticalEvent: Suppose 3 segments intersect in a point Two segments overlap (intersect in more than one point?) sisi sjsj

Robert Pless, CS 546: Computational Geometry Lecture #3 Table of good stuff Running time definitions: O(n log n) –At most n log n. –It is correct to say that binary search is O(n log n). (it is also correct to say that it is O(log n). o(n log n) –Stricty better than n log n.  (n log n) –Exactly n log n (up to constant factors). Lower Bounds: Sorting: O(n log n) Element Uniqueness O(n log n). Data Structures Heap: Extract min: O(1) Insert-element O(log n) Delete element O(log n) Balanced Binary Tree: Insert: O(log n) Delete: O(log n) Find neighbors: O(log n) Lexicographic order (like alphabetical order, sort by first element, then by second element, etc.).

Robert Pless, CS 546: Computational Geometry Lecture #3 Example problem for sweep line? Problem: Given P  R 2, |P|=n, find the distance of the closest pair in P