lecture intersection search(1)
TRANSCRIPT
-
8/12/2019 Lecture Intersection Search(1)
1/34
-
8/12/2019 Lecture Intersection Search(1)
2/34
Intersection Search
Input: A set Sof geometric objects(segments, polygons, disks, solid models, etc)
2
-
8/12/2019 Lecture Intersection Search(1)
3/34
Intersection Search
Versions of the problem: 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 intersect
COMPUTE: Compute the common intersection of allobjects
COUNT: How many pairs intersect? QUERY: Preprocess Sto support fast queries of
the form Does object Qintersect any member ofS? (or Report all intersections with Q)
3May also want to insert/delete in S, orallow objects of S to move.
-
8/12/2019 Lecture Intersection Search(1)
4/34
Warm Up: 1D Problem
Given n segments (intervals) on a line
DETECT: O(n log n), based on sorting
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
4
Element UniquenessInput: {x1,x2,,xn}Are they distinct?(yes/no)
(n log n)
-
8/12/2019 Lecture Intersection Search(1)
5/34
Intersection Search: Segments
Segment intersection: Given a set Sofnline segments in the plane, determine: Does some pair intersect? (DETECT)
Compute all points of intersection(REPORT)
Nave: O(n2)CG: O(n log n) DETECT, O(k+n log n) REPORT
Lower Bound to DETECT: (n log n) , from ELEMENT UNIQUENESS
Element UniquenessInput: {x1,x2,,xn}Are they distinct?(yes/no)
(n log n)
-
8/12/2019 Lecture Intersection Search(1)
6/34
Primitive Computation
Does segment abintersect segment cd? Types of intersect
Test using Left tests (sign of a crossproduct (determinant), which determinesthe orientation of 3 points)
Time O(1) (constant)
6
a
bc
Left( a, b, c ) = TRUE ab ac > 0c is left of ab
-
8/12/2019 Lecture Intersection Search(1)
7/34
Bentley-Ottmann Sweep
Main idea: Process eventsin order ofdiscovery as a vertical line, L, sweepsover the scene, from left to right
Two data structures: SLS: Sweep Line Status: bottom-to-top
ordering of the segments intersecting L
EQ: Event Queue
7
L
-
8/12/2019 Lecture Intersection Search(1)
8/34
Two data structures:
SLS: Sweep Line Status: bottom-to-topordering of the segments intersecting L
EQ: Event Queue
Initialize: SLS =
EQ = sorted list of segment endpoints
How to store: SLS: balanced binary search tree
(dictionary, support O(log n) insert, delete, search)
EQ: priority queue (e.g., heap)8
O(n log n)
L
-
8/12/2019 Lecture Intersection Search(1)
9/34
Hit left endpt of e
Hit right endpt of e
Hit crossing point e f (only needed in REPORT)
Event Handling
9
O(log n)L
a
b eFind segs a and b above/below ein SLS. Inserte into SLS.Test(a,e), Test(b,e) and insertcrossings (if any) in EQ
a
b
e
L
Find segs a and b above/below ein SLS. Deletee from SLS.Test(a,b), and insert crossing(if any) in EQ
a
b
L
e
f
O(log n)
O(log n)
Exchangee, f in SLS.Test(a,f), Test(b,e) and insertcrossings (if any) in EQ
-
8/12/2019 Lecture Intersection Search(1)
10/34
Summary
10
[Lecture Notes of David Mount, Lecture 6]
-
8/12/2019 Lecture Intersection Search(1)
11/34
-
8/12/2019 Lecture Intersection Search(1)
12/34
Algorithm Analysis Invariantsof algorithm:
SLS is correctly ordered. Test(a,b) for intersection is done whenever segments a and b
become adjacent in the SLS order
Discovered crossings are inserted into EQ
(for REPORT; for DETECT, stop at first detected crossing) Claim:All crossings are discovered
12
[Lecture Notes of David Mount, Lecture 6]
-
8/12/2019 Lecture Intersection Search(1)
13/34
Algorithm Analysis
Time: O(n log n) to DETECT (O(n) events @ O(log n) )
Time: O((n+k)log n) to REPORT (O(n+k) events @ O(log n) )
Example Applet
13
k = # crossings = output size
http://www.lems.brown.edu/~wq/projects/cs252.htmlhttp://www.lems.brown.edu/~wq/projects/cs252.htmlhttp://www.lems.brown.edu/~wq/projects/cs252.htmlhttp://www.lems.brown.edu/~wq/projects/cs252.htmlhttp://www.lems.brown.edu/~wq/projects/cs252.htmlhttp://www.lems.brown.edu/~wq/projects/cs252.html -
8/12/2019 Lecture Intersection Search(1)
14/34
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 theEQ (size 2n+k )
14
Better bounds on size of EQ: O(n log2n)[Pach and Sharir]
-
8/12/2019 Lecture Intersection Search(1)
15/34
Space: Working Memory
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 thecrossing point again (at least once) beforethe actual crossing event.
Note: Now the EQ has at most n-1 crossingevents (and at most 2n endpoint events)
15
-
8/12/2019 Lecture Intersection Search(1)
16/34
16
-
8/12/2019 Lecture Intersection Search(1)
17/34
17
-
8/12/2019 Lecture Intersection Search(1)
18/34
Optimal REPORT algorithms exist: O(k + n log n), O(k+n) space (working memory)
[Chazelle-Edelsbrunner] O(k + n log n), O(n) space [Balaban]
Special Case: REPORT for horiz/vert segs Bentley-Ottmann sweep: O(k + n log n) (optimal!)
Special case: Simplicity testing O(n), from Chazelle triangulation
18
(Complex)
LAll crossings happen when L hits a verticalsegment, si ; just locate (O( log n)) the endpointand walk along vertical segment in SLS to reportall kihorizontal segments crossed along si
-
8/12/2019 Lecture Intersection Search(1)
19/34
Advertisement
Today, 4:00pm, in Math P-131
Talk: Watchman Route Problem
19
-
8/12/2019 Lecture Intersection Search(1)
20/34
Sweeping applies also to Unions
Intersections
Arrangements
20
-
8/12/2019 Lecture Intersection Search(1)
21/34
-
8/12/2019 Lecture Intersection Search(1)
22/34
Map Overlay
22
-
8/12/2019 Lecture Intersection Search(1)
23/34
Data Structures for Planar Subdivisions
Winged Edge Data
Structure. Quad Edge Data
Structure.
Our focus on Doubly
Connected Edge List.
[DCEL: doubly connected edge list]
f0
f1e
e4,0
v1
v0
-represent edge as 2 halves
-lists: vertex, face, edge/twin-facilitates face traversal
es
twin
v2
v7
v6
v5
v3
v4
e0,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 theface
Ack: R. Pless
-
8/12/2019 Lecture Intersection Search(1)
24/34
-
8/12/2019 Lecture Intersection Search(1)
25/34
DCEL
25
-
8/12/2019 Lecture Intersection Search(1)
26/34
Practical Methods, 3D
Uniform grid
Quadtrees
Bounding volume hierarchies26
With each pixel, store alist of objectsintersecting it.Do brute force on
pixel-by-pixel basis.
See Samet books, SANDwebsite
http://www.cs.umd.edu/~brabec/sandjava/index.htmlhttp://www.cs.umd.edu/~brabec/sandjava/index.html -
8/12/2019 Lecture Intersection Search(1)
27/34
-
8/12/2019 Lecture Intersection Search(1)
28/34
QuickCD: Collision Detection
-
8/12/2019 Lecture Intersection Search(1)
29/34
The 2-Box Cover Problem
Find smallest (tightest fitting) pairof bounding boxes
Motivation: Best outer approximation
Bounding volume hierarchies
-
8/12/2019 Lecture Intersection Search(1)
30/34
Bounding Volume Hierarchy
BV-tree:
Level 0 k-dops
-
8/12/2019 Lecture Intersection Search(1)
31/34
BV-tree: Level 1
26-dops
14-dops6-dops
18-dops
-
8/12/2019 Lecture Intersection Search(1)
32/34
BV-tree: Level 2
-
8/12/2019 Lecture Intersection Search(1)
33/34
BV-tree: Level 5
-
8/12/2019 Lecture Intersection Search(1)
34/34
BV-tree: Level 8