Computational Geometry: Intersection Search Joseph S. B. Mitchell Stony Brook University.

Slides:



Advertisements
Similar presentations
Two Segments Intersect?
Advertisements

Polygon Triangulation
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.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
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.
Convex Hull obstacle start end Convex Hull Convex Hull
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
9/12/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries II Carola Wenk.
I. The Problem of Molding Does a given object have a mold from which it can be removed? object not removable mold 1 object removable Assumptions The object.
Overlay of Two Subdivisions
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.
Lecture 7: Voronoi Diagrams Presented by Allen Miu Computational Geometry September 27, 2001.
K-structure, Separating Chain, Gap Tree, and Layered DAG Presented by Dave Tahmoush.
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness,
Computational Geometry -- Voronoi Diagram
17. Computational Geometry Chapter 7 Voronoi Diagrams.
The Half-Edge Data Structure
I/O-Algorithms Lars Arge Aarhus University February 27, 2007.
Lecture 12 : Special Case of Hidden-Line-Elimination Computational Geometry Prof. Dr. Th. Ottmann 1 Special Cases of the Hidden Line Elimination Problem.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 O’Rourke Chapter 7 Search & Intersection.
Special Cases of the Hidden Line Elimination Problem Computational Geometry, WS 2007/08 Lecture 16 Prof. Dr. Thomas Ottmann Algorithmen & Datenstrukturen,
I/O-Algorithms Lars Arge University of Aarhus March 1, 2005.
I/O-Algorithms Lars Arge Spring 2009 March 3, 2009.
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.
Lecture 6: Point Location Computational Geometry Prof. Dr. Th. Ottmann 1 Point Location 1.Trapezoidal decomposition. 2.A search structure. 3.Randomized,
Voronoi Diagrams.
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 Chapter 4: 3D Convex Hulls Monday, 2/23/04.
Lecture 2 Line Segment Intersection Computational Geometry Prof.Dr.Th.Ottmann 1 Line Segment Intersection Motivation: Computing the overlay of several.
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.
ADA: 14. Intro to CG1 Objective o give a non-technical overview of Computational geometry, concentrating on its main application areas Algorithm.
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.
AMS 345/CSE 355 Computational Geometry
UNC Chapel Hill M. C. Lin Line Segment Intersection Chapter 2 of the Textbook Driving Applications –Map overlap problems –3D Polyhedral Morphing.
External Memory Algorithms for Geometric Problems Piotr Indyk (slides partially by Lars Arge and Jeff Vitter)
AMS 345/CSE 355 Computational Geometry Lecture 1: Introduction Joe Mitchell.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Computing Inner and Outer Shape Approximations Joseph S.B. Mitchell Stony Brook University.
CMPS 3130/6130 Computational Geometry Spring 2015
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness)
An Introduction to Computational Geometry Joseph S. B. Mitchell Stony Brook University.
Computational Geometry 2D Convex Hulls
February 17, 2005Lecture 6: Point Location Point Location (most slides by Sergi Elizalde and David Pritchard)
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.
Polygon Triangulation
UNC Chapel Hill M. C. Lin Geometric Data Structures Reading: Chapter 10 of the Textbook Driving Applications –Windowing Queries Related Application –Query.
CMPS 3130/6130 Computational Geometry Spring 2017
Computational Geometry
An Introduction to Computational Geometry
CMPS 3130/6130 Computational Geometry Spring 2017
Segment tree and Interval Tree
Computational Geometry 2
CMPS 3130/6130 Computational Geometry Spring 2017
Computational Geometry Capter:1-2.1
I. The Problem of Molding
Intersection problem.
Collision Detection.
Computational Geometry
Overlay of Two Subdivisions
Algorithms and Data Structures Lecture XIV
Presentation transcript:

Computational Geometry: Intersection Search Joseph S. B. Mitchell Stony Brook University

Intersection Search Input: A set S of geometric objects (segments, polygons, disks, solid models, etc) Input: A set S of geometric objects (segments, polygons, disks, solid models, etc) 2

Intersection Search Versions of the problem: Versions of the problem: DETECT: Answer yes/no: Are there any intersections among the objects S?DETECT: Answer yes/no: Are there any intersections among the objects S? (if “yes”, then we may insist on returning a witness) REPORT: Output all pairs of objects that intersectREPORT: Output all pairs of objects that intersect COMPUTE: Compute the common intersection of all objectsCOMPUTE: Compute the common intersection of all objects COUNT: How many pairs intersect?COUNT: How many pairs intersect? QUERY: Preprocess S to support fast queries of the form “Does object Q intersect any member of S?” (or “Report all intersections with Q”)QUERY: Preprocess S to support fast queries of the form “Does object Q intersect any member of S?” (or “Report all intersections with Q”) 3 May also want to insert/delete in S, or allow objects of S to move.

Warm Up: 1D Problem Given n segments (intervals) on a line Given n segments (intervals) on a line DETECT: O(n log n), based on sorting DETECT: O(n log n), based on sorting REPORT: O(k+n log n), based on sorting, then marching through, left to right REPORT: O(k+n log n), based on sorting, then marching through, left to right Lower bound to DETECT: :  (n log n), from ELEMENT UNIQUENESS Lower bound to DETECT: :  (n log n), from ELEMENT UNIQUENESS 4 Element Uniqueness Input: {x 1, x 2, …,x n } Are they distinct? (yes/no)  (n log n)

Intersection Search: Segments Segment intersection: Given a set S of n line segments in the plane, determine: Segment intersection: Given a set S of n line segments in the plane, determine: Does some pair intersect? (DETECT)Does some pair intersect? (DETECT) Compute all points of intersection (REPORT)Compute all points of intersection (REPORT) Naïve: O(n 2 ) CG: O(n log n) DETECT, O(k+n log n) REPORT Lower Bound to DETECT:  (n log n), from ELEMENT UNIQUENESS Element Uniqueness Input: {x 1, x 2, …,x n } Are they distinct? (yes/no)  (n log n)

Primitive Computation Does segment ab intersect segment cd ? Does segment ab intersect segment cd ? Types of “intersect”Types of “intersect” Test using “Left” tests (sign of a cross product (determinant), which determines the orientation of 3 points)Test using “Left” tests (sign of a cross product (determinant), which determines the orientation of 3 points) Time O(1) (“constant”)Time O(1) (“constant”) 6 a b c Left( a, b, c ) = TRUE  ab  ac > 0 c is left of ab

Bentley-Ottmann Sweep Main idea: Process events in order of discovery as a horizontal line, L, “sweeps” over the scene, from top to bottom Main idea: Process events in order of discovery as a horizontal line, L, “sweeps” over the scene, from top to bottom Two data structures: Two data structures: SLS: Sweep Line Status: left-to-right ordering of the segments intersecting LSLS: Sweep Line Status: left-to-right ordering of the segments intersecting L EQ: Event QueueEQ: Event Queue 7 L

Two data structures: Two data structures: SLS: Sweep Line Status: left-to-right ordering of the segments intersecting LSLS: Sweep Line Status: left-to-right ordering of the segments intersecting L EQ: Event QueueEQ: Event Queue Initialize: Initialize: SLS = SLS =  EQ = sorted list of segment endpointsEQ = sorted list of segment endpoints How to store: How to store: SLS: balanced binary search treeSLS: balanced binary search tree (dictionary, support O(log n) insert, delete, search) (dictionary, support O(log n) insert, delete, search) EQ: priority queue (e.g., heap)EQ: priority queue (e.g., heap) 8 O(n log n) L

Hit top endpt of e Hit top endpt of e Hit bottom endpt of e Hit bottom endpt of e Hit crossing point e  f (only needed in REPORT) Hit crossing point e  f (only needed in REPORT) Event Handling 9 O(log n) L a b e Find segs a and b left/right of e in SLS. Insert e into SLS. Test(a,e), Test(b,e) and insert crossings (if any) in EQ a b e L Find segs a and b left/right of e in SLS. Delete e from SLS. Test(a,b), and insert crossing (if any) in EQ a b L e f O(log n) Exchange e, f in SLS. Test(a,f), Test(b,e) and insert crossings (if any) in EQ

Algorithm Analysis Invariants of algorithm: Invariants of algorithm: SLS is correctly ordered.SLS is correctly ordered. Test(a,b) for intersection is done whenever segments a and b become adjacent in the SLS orderTest(a,b) for intersection is done whenever segments a and b become adjacent in the SLS order Discovered crossings are inserted into EQ Discovered crossings are inserted into EQ (for REPORT; for DETECT, stop at first detected crossing) Claim: All crossings are discovered Claim: All crossings are discovered Time: O(n log n) to DETECT (O(n) O(log n) ) Time: O(n log n) to DETECT (O(n) O(log n) ) Time: O((n+k) log n) to REPORT (O(n+k) O(log n) ) Time: O((n+k) log n) to REPORT (O(n+k) O(log n) ) Example Applet Example Applet Example Applet Example Applet 10 k = # crossings = output size

Space: Working Memory Basic (original) version of B-O sweep: Naively, the EQ has size at most O(n+k), since we store the SLS (O(n)) and the EQ (size 2n+k ) Basic (original) version of B-O sweep: Naively, the EQ has size at most O(n+k), since we store the SLS (O(n)) and the EQ (size 2n+k ) 11 Better bounds on size of EQ: O(n log 2 n) [Pach and Sharir]

Space: Working Memory Modified B-O Sweep: Modified B-O Sweep: Any time 2 segs STOP being adjacent in SLS, remove from EQ the corresponding crossing point (if any); we will re-insert the crossing point again (at least once) before the actual crossing event.Any time 2 segs STOP being adjacent in SLS, remove from EQ the corresponding crossing point (if any); we will re-insert the crossing point again (at least once) before the actual crossing event. Note: Now the EQ has at most n-1 crossing events (and at most 2n endpoint events)Note: Now the EQ has at most n-1 crossing events (and at most 2n endpoint events) 12

13

14

Optimal REPORT algorithms exist: Optimal REPORT algorithms exist: O(k + n log n), O(k+n) space (working memory)O(k + n log n), O(k+n) space (working memory) [Chazelle-Edelsbrunner] [Chazelle-Edelsbrunner] O(k + n log n), O(n) space [Balaban]O(k + n log n), O(n) space [Balaban] Special Case: REPORT for horiz/vert segs Special Case: REPORT for horiz/vert segs Bentley-Ottmann sweep: O(k + n log n) (optimal!)Bentley-Ottmann sweep: O(k + n log n) (optimal!) Special case: Simplicity testing Special case: Simplicity testing O(n), from Chazelle triangulationO(n), from Chazelle triangulation 15 (Complex) L All crossings happen when L hits a horizontal segment, s i ; just locate (O( log n)) the endpoint and walk along horizontal segment in SLS to report all k i vertical segments crossed along s i

Sweeping applies also to Sweeping applies also to UnionsUnions IntersectionsIntersections ArrangementsArrangements 16

Data Structures for Planar Subdivisions Winged Edge Data Structure. Winged Edge Data Structure. Quad Edge Data Structure. Quad Edge Data Structure. Our focus on “Doubly Connected Edge List”. Our focus on “Doubly Connected Edge List”. [ DCEL: doubly connected edge list ] f0f0f0f0 f1f1f1f1 e e 4,0 v1v1v1v1 v0v0v0v0 - represent edge as 2 halves - lists: vertex, face, edge/twin -facilitates face traversal e’s twin v2v2v2v2 v7v7v7v7 v6v6v6v6 v5v5v5v5 v3v3v3v3 v4v4v4v4 e 0,1 Every edge e is struct: –e.org, e.dest: pointer to origin and dest vertices. –e.face is face on left of edge –e.twin is the same edge, oriented the other direction. –e.next is next edge along the face Ack: R. Pless

DCEL f0f0 f1f1 e e 4,0 v1v1 v0v0 Pop quiz. -How to enumerate all edges of a face? -How to enumerate all edges incident on a node? e’s twin v2v2 v7v7 v6v6 v5v5 v3v3 v4v4 e 0,1 Every edge e is struct: –e.org, e.dest: pointer to origin and dest vertices. –e.face is face on left of edge –e.twin is the same edge, oriented the other direction. Each Face has a pointer to one edge of that face. Each vertex has pointer to one edge away from that vertex. Ack: R. Pless

Practical Methods, 3D Uniform grid Uniform grid Quadtrees Quadtrees Bounding volume hierarchies Bounding volume hierarchies 19 With each pixel, store a list of objects intersecting it. Do brute force on pixel-by-pixel basis. See Samet books, SAND websiteSAND

Bounding Volume Hierarchies 20 S Bounding volume Input: Set S of objects.

QuickCD: Collision Detection

The 2-Box Cover Problem Find “smallest” (tightest fitting) pair of bounding boxes Motivation:Motivation: Best outer approximation Best outer approximation Bounding volume hierarchies Bounding volume hierarchies

Bounding Volume Hierarchy BV-tree: Level 0 k-dops

BV-tree: Level 1 26-dops 14-dops 6-dops 18-dops

BV-tree: Level 2

BV-tree: Level 5

BV-tree: Level 8