Line-Segment Intersection Map Overlay
Document Sample


Chapter 2
Line-Segment Intersection
or:
Map Overlay
Alexander Wolff TU/e Geometric Algorithms (2IL55)
Line-Segment Intersection
Application ?
Line-Segment Intersection
Application: map overlay (GIS)
Line-Segment Intersection
Application: map overlay (GIS)
Definition:
Line-Segment Intersection
Application: map overlay (GIS)
Definition: Is an intersection?
Line-Segment Intersection
Application: map overlay (GIS)
Definition: Is an intersection?
Answer: Check application!
Line-Segment Intersection
Application: map overlay (GIS)
Definition: Is an intersection?
Answer: Check application!
Problem: Given a set S of n closed non-overlapping line
segments in the plane, compute:
– all points where at least two segments intersect
and
– for each such point report all segments
that contain it.
Line-Segment Intersection
Application: map overlay (GIS)
Definition: Is an intersection?
Answer: Check application! yes!
Problem: Given a set S of n closed non-overlapping line
segments in the plane, compute:
– all points where at least two segments intersect
and
– for each such point report all segments
that contain it.
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def.
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Store event pts in balanced binary search tree acc. to
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Store event pts in balanced binary search tree acc. to
⇒ nextEvent() and del/insEvent() take O(log |Q|) time
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Store event pts in balanced binary search tree acc. to
⇒ nextEvent() and del/insEvent() take O(log |Q|) time
2) (sweep-line) status T
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Store event pts in balanced binary search tree acc. to
⇒ nextEvent() and del/insEvent() take O(log |Q|) time
2) (sweep-line) status T
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Store event pts in balanced binary search tree acc. to
⇒ nextEvent() and del/insEvent() take O(log |Q|) time
2) (sweep-line) status T
Store the segments intersected by in left-to-right order.
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Store event pts in balanced binary search tree acc. to
⇒ nextEvent() and del/insEvent() take O(log |Q|) time
2) (sweep-line) status T
Store the segments intersected by in left-to-right order.
How?
Data structures for a top-to-bottom sweep
1) event (-point) queue Q
p q ⇔def. yp > yq or (yp = yq and xp < xq )
p q
Store event pts in balanced binary search tree acc. to
⇒ nextEvent() and del/insEvent() take O(log |Q|) time
2) (sweep-line) status T
Store the segments intersected by in left-to-right order.
How? In a balanced binary search tree!
Sweep-line algorithm
findIntersections(S)
Input: set S of n non-overlapping closed line segments
Output: set I of intersection pts
for each p ∈ I every s ∈ S with p ∈ s
Sweep-line algorithm
findIntersections(S)
Input: set S of n non-overlapping closed line segments
Output: set I of intersection pts
for each p ∈ I every s ∈ S with p ∈ s
Q ← ∅; T ← ∅
foreach s ∈ S do
Q.insert(upperEndPt(s))
Q.insert(lowerEndPt(s))
Sweep-line algorithm
findIntersections(S)
Input: set S of n non-overlapping closed line segments
Output: set I of intersection pts
for each p ∈ I every s ∈ S with p ∈ s
Q ← ∅; T ← ∅
foreach s ∈ S do
Q.insert(upperEndPt(s))
Q.insert(lowerEndPt(s))
while Q = ∅ do
p ← Q.nextEvent()
Q.deleteEvent(p)
handleEvent(p)
Correctness and running time
Lemma: findIntersections() correctly computes all inter-
section points & the segments that contain them.
Correctness and running time
Lemma: findIntersections() correctly computes all inter-
section points & the segments that contain them.
Lemma: findIntersections() finds I intersection points
among n non-overlapping line segments in
O((n + I) log n) time.
Correctness and running time
Lemma: findIntersections() correctly computes all inter-
section points & the segments that contain them.
Lemma: findIntersections() finds I intersection points
among n non-overlapping line segments in
O((n + I) log n) time.
Theorem: We can report all I intersection points among n
non-overlapping line segments in the plane and
report the segments involved in the intersections in
O((n + I) log n) time and O(n) space.
Doubly-Connected Edge List
Motivation: – data structure for planar subdivisions
– map overlay (e.g., rivers and streets)
– “walk” on the map, from region to region
Doubly-Connected Edge List
Motivation: – data structure for planar subdivisions
– map overlay (e.g., rivers and streets)
– “walk” on the map, from region to region
graph
nodes
arcs
abstract
adjacency
information
Doubly-Connected Edge List
Motivation: – data structure for planar subdivisions
– map overlay (e.g., rivers and streets)
– “walk” on the map, from region to region
graph subdivision
nodes vertices
arcs edges
abstract
adjacency
information
Doubly-Connected Edge List
Motivation: – data structure for planar subdivisions
– map overlay (e.g., rivers and streets)
– “walk” on the map, from region to region
graph subdivision geometry
nodes vertices points in R2
arcs edges line segments
(or: circular arcs...)
abstract
adjacency
information
Doubly-Connected Edge List
Motivation: – data structure for planar subdivisions
– map overlay (e.g., rivers and streets)
– “walk” on the map, from region to region
graph subdivision geometry
nodes vertices points in R2
incident
arcs edges line segments
(or: circular arcs...)
abstract
adjacency faces
information
Doubly-Connected Edge List
Motivation: – data structure for planar subdivisions
– map overlay (e.g., rivers and streets)
– “walk” on the map, from region to region
graph subdivision geometry
nodes vertices points in R2
incident
arcs edges line segments
(or: circular arcs...)
abstract
adjacency faces
information maximal connected subsets of the plane
without vertices and edges
Doubly-Connected Edge List
Motivation: – data structure for planar subdivisions
– map overlay (e.g., rivers and streets)
– “walk” on the map, from region to region
graph subdivision geometry
nodes vertices points in R2
adjacent
incident
arcs edges line segments
(or: circular arcs...)
abstract
adjacency faces
information maximal connected subsets of the plane
without vertices and edges
Doubly-Connected Edge List
Motivation: – data structure for planar subdivisions
– map overlay (e.g., rivers and streets)
– “walk” on the map, from region to region
gy
graph subdivision geometry
lo
po
to
nodes vertices points in R2
adjacent
incident
arcs edges line segments
(or: circular arcs...)
abstract
adjacency faces
information maximal connected subsets of the plane
without vertices and edges
Doubly-Connected Edge List
Motivation: – data structure for planar subdivisions
– map overlay (e.g., rivers and streets)
– “walk” on the map, from region to region
gy
graph subdivision geometry
lo
po
to
nodes vertices points in R2
adjacent
incident
arcs edges line segments
(or: circular arcs...)
abstract
adjacency faces
information maximal connected subsets of the plane
without vertices and edges
complexity of a subdiv. := #vertices + #edges + #faces
DCEL: Notation and an Example
twin(e)
origin(e)
e
next(e)
prev(e)
face(e)
DCEL: Notation and an Example
twin(e) Note: Half-edges are oriented
origin(e) such that incident face
e lies locally to the left.
next(e)
prev(e)
face(e)
DCEL: Notation and an Example
twin(e) Note: Half-edges are oriented
origin(e) such that incident face
e lies locally to the left.
next(e)
prev(e)
face(e)
v1 e11 v2
f2
e21
e41
f1 v3
e32
v4 e31
DCEL: Notation and an Example
twin(e) Note: Half-edges are oriented
origin(e) such that incident face
e lies locally to the left.
next(e)
prev(e)
face(e)
v1 e11 v2
f2
e21 edge origin twin face next prev
e41
e11 v1 e22 f1 e21 e41
f1 v3 e12 v2 e11 f2 e42 e22
e32
e21 v2 e22 f1 e31 e11
v4 e31
...
DCEL: Notation and an Example
twin(e) vertex coordinates edge
origin(e) v1 (0, 3) e11
e v2 (2, 3) e21
next(e) v3 (2, 1) e31
prev(e)
v4 (1, 0) e22
face(e)
v1 e11 v2
f2
e21 edge origin twin face next prev
e41
e11 v1 e22 f1 e21 e41
f1 v3 e12 v2 e11 f2 e42 e22
e32
e21 v2 e22 f1 e31 e11
v4 e31
...
DCEL: Notation and an Example
twin(e) vertex coordinates edge
origin(e) v1 (0, 3) e11
e v2 (2, 3) e21
next(e) v3 (2, 1) e31
prev(e)
v4 (1, 0) e22
face(e)
face outerComp. innerComp.
e11 f1 nil e11
v1 v2 f2 e22 nil
f2
e21 edge origin twin face next prev
e41
e11 v1 e22 f1 e21 e41
f1 v3 e12 v2 e11 f2 e42 e22
e32
e21 v2 e22 f1 e31 e11
v4 e31
...
Map Overlay
Input: subdivisions S1 , S2 as DCELs
S2
S1
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D
D
S2
S1
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
D
S2
S1
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
D
S2
S1
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
D
S2
S1
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
D
S2
S1
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Why do we need the big union? —
Think and/or ask!
D
S2
S1
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Idea: “recycle” findIntersections()
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Idea: “recycle” findIntersections()
problem:
input = set of segm.
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Idea: “recycle” findIntersections()
problem:
input = set of segm.
Changes:
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Idea: “recycle” findIntersections()
problem:
input = set of segm.
Changes: without finding/treating faces [book, p. 36–38]
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Idea: “recycle” findIntersections()
problem:
input = set of segm.
Changes: without finding/treating faces [book, p. 36–38]
self-study
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Idea: “recycle” findIntersections()
problem:
input = set of segm.
Changes: without finding/treating faces [book, p. 36–38]
• if all segments incident to an event pt belong to
one subdivision, keep going!
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Idea: “recycle” findIntersections()
problem:
input = set of segm.
Changes: without finding/treating faces [book, p. 36–38]
• if all segments incident to an event pt belong to
one subdivision, keep going!
• otherwise “stitch” DCELs together
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Idea: “recycle” findIntersections()
problem:
input = set of segm.
Changes: without finding/treating faces [book, p. 36–38]
• if all segments incident to an event pt belong to
one subdivision, keep going!
• otherwise “stitch” DCELs together. Cases, e.g.,
Map Overlay
Input: subdivisions S1 , S2 as DCELs
Output: DCEL D with interpreted as line segments
V (D) = V (S1 ) ∪ V (S2 ) ∪ {e1 ∩ e2 | ei ∈ E(Si )}
E(D) = conn. comp. of E(S1 ) ∪ E(S2 ) \ V (D)
Idea: “recycle” findIntersections()
problem:
input = set of segm.
Changes: without finding/treating faces [book, p. 36–38]
• if all segments incident to an event pt belong to
one subdivision, keep going!
• otherwise “stitch” DCELs together. Cases, e.g.,
– edge of S1 passes through vertex of S2
– edges of S1 and edges of S2 intersect
Get documents about "