computational geometry - uni-wuerzburg.de
Post on 30-Apr-2022
13 Views
Preview:
TRANSCRIPT
1 - 1
Computational Geometry
Lecture #1
Convex Hullor
Mixing Things
Dr. Philipp Kindermann Winter Semester 2018
1 - 2
Computational Geometry
Lecture #1
Convex Hullor
Mixing Things
Dr. Philipp Kindermann Winter Semester 2018
2 - 1
Chair I
a) Efficient Algorithms
b) Knowledge-Based SystemsProf. Dietmar Seipel
c) Theoretical Comp. ScienceProf. Christian Glaßer
2 - 2
Chair I
a) Efficient Algorithms
b) Knowledge-Based SystemsProf. Dietmar Seipel
Alexander Wolff Philipp Kindermann
Thomas van Dijk
Steven Chaplick
c) Theoretical Comp. ScienceProf. Christian Glaßer
Professor PostDoc
PostDocMyroslav Kryven
Oksana Firman
Johannes ZinkAndre Loffler
PostDoc
3 - 1
Philipp Kindermannfirstname.lastname@uni-wuerzburg.deEmail:
3 - 2
Philipp Kindermannfirstname.lastname@uni-wuerzburg.deEmail:
Wurzburg 2006 – 2011: Study
3 - 3
Philipp Kindermannfirstname.lastname@uni-wuerzburg.deEmail:
Wurzburg 2006 – 2011: Study2011 – 2015: PhD
3 - 4
Philipp Kindermannfirstname.lastname@uni-wuerzburg.deEmail:
Wurzburg
Hagen
2006 – 2011: Study2011 – 2015: PhD
2015 – 2018:PostDoc
3 - 5
Philipp Kindermannfirstname.lastname@uni-wuerzburg.deEmail:
Wurzburg
Hagen
2006 – 2011: Study2011 – 2015: PhD
2015 – 2018:PostDoc
3 - 6
Philipp Kindermannfirstname.lastname@uni-wuerzburg.deEmail:
Waterloo
3 - 7
Philipp Kindermannfirstname.lastname@uni-wuerzburg.deEmail:
Waterloo
3 - 8
Philipp Kindermannfirstname.lastname@uni-wuerzburg.deEmail:
Office hours: Wed, 14–15h
3 - 9
Philipp Kindermannfirstname.lastname@uni-wuerzburg.de
Office:
Email:
E14 @ Former Math Build. (M8)Office hours: Wed, 14–15h
3 - 10
Philipp Kindermannfirstname.lastname@uni-wuerzburg.de
Office:
Email:
E14 @ Former Math Build. (M8)Office hours: Wed, 14–15h
3 - 11
Philipp Kindermannfirstname.lastname@uni-wuerzburg.de
Office:
Email:
E14 @ Former Math Build. (M8)Office hours: Wed, 14–15h
Research areas:
– Comp. Geometry– Graph Algorithms– Graph Visualization
4 - 1
Computational GeometryLearning goals: At the end of this lecture you will be able to
4 - 2
Computational GeometryLearning goals:
– decide which algorithms help to solve a number offundamental geometric problems,
At the end of this lecture you will be able to
4 - 3
Computational GeometryLearning goals:
– decide which algorithms help to solve a number offundamental geometric problems,
At the end of this lecture you will be able to
– analyze new problems and find – with the concepts ofthe lecture – efficient solutions.
4 - 4
Computational GeometryLearning goals:
– decide which algorithms help to solve a number offundamental geometric problems,
Requirements:
At the end of this lecture you will be able to
– analyze new problems and find – with the concepts ofthe lecture – efficient solutions.
– Big-Oh notation (Landau); e.g., O(n log n)
4 - 5
Computational GeometryLearning goals:
– decide which algorithms help to solve a number offundamental geometric problems,
Requirements:
At the end of this lecture you will be able to
– analyze new problems and find – with the concepts ofthe lecture – efficient solutions.
– Some basic Algorithms & Data Structures– Big-Oh notation (Landau); e.g., O(n log n)
(Balanced) binary search tree, priority queue
4 - 6
Computational GeometryLearning goals:
– decide which algorithms help to solve a number offundamental geometric problems,
Requirements:
At the end of this lecture you will be able to
– analyze new problems and find – with the concepts ofthe lecture – efficient solutions.
– Some basic Algorithms & Data Structures
– Some basic Algorithmic Graph Theory
– Big-Oh notation (Landau); e.g., O(n log n)
(Balanced) binary search tree, priority queue
Breadth-first search, Dijkstra’s algorithm
4 - 7
Computational GeometryLearning goals:
– decide which algorithms help to solve a number offundamental geometric problems,
Requirements:
At the end of this lecture you will be able to
– analyze new problems and find – with the concepts ofthe lecture – efficient solutions.
– Some basic Algorithms & Data Structures
– Some basic Algorithmic Graph Theory
– Oral exam at the end of the semester
– Big-Oh notation (Landau); e.g., O(n log n)
(Balanced) binary search tree, priority queue
Breadth-first search, Dijkstra’s algorithm
4 - 8
Computational GeometryLearning goals:
– decide which algorithms help to solve a number offundamental geometric problems,
Requirements:
My vision: • “hands-on”• interactive
At the end of this lecture you will be able to
– analyze new problems and find – with the concepts ofthe lecture – efficient solutions.
– Some basic Algorithms & Data Structures
– Some basic Algorithmic Graph Theory
– Oral exam at the end of the semester
– Big-Oh notation (Landau); e.g., O(n log n)
(Balanced) binary search tree, priority queue
Breadth-first search, Dijkstra’s algorithm
5
Content1. Convex Hull in 2D2. Map Overlay3. Polygon Triangulation4. Linear Programming5. Orthogonal Range Queries6. Point Location7. Voronoi Diagram8. Delaunay Triangulation9. Convex Hull in 3D
10. Motion Planning11. Simplex Range Searching12. Arrangements and Duality13. Binary Space Partition14. Randomized Triangulation
6 - 1
LiteratureM. de Berg, O. Cheong, M. van Kreveld, M. Overmars:Computational Geometry: Algorithms & Applications.Springer, 3rd edition, 2008
Main resource for this course!Abbreviated as: Comp. Geom A&A
6 - 2
Literature
Rolf Klein:Algorithmische Geometrie: Grundlagen, Methoden,Anwendungen.Springer, 2nd edition, 2005
M. de Berg, O. Cheong, M. van Kreveld, M. Overmars:Computational Geometry: Algorithms & Applications.Springer, 3rd edition, 2008
Main resource for this course!Abbreviated as: Comp. Geom A&A
6 - 3
Literature
Rolf Klein:Algorithmische Geometrie: Grundlagen, Methoden,Anwendungen.Springer, 2nd edition, 2005
M. de Berg, O. Cheong, M. van Kreveld, M. Overmars:Computational Geometry: Algorithms & Applications.Springer, 3rd edition, 2008
Ketan Mulmuley:Computational Geometry: An Introduction ThroughRandomized Algorithms. Prentice Hall, 1st edition, 1993
Main resource for this course!Abbreviated as: Comp. Geom A&A
7
Week 1
Mixing Thingsor
Convex Hull
[Comp. Geom A&A : Chapter 1, (see also Ch. 11)]
8 - 1
Mixing Things
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
Given...
8 - 2
Mixing Things
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
Given...
subst. fract. A fract. Bq1 25 % 28 %q2 15 % 15 %
can we mix
?using s1, s2, s3
8 - 3
Mixing Things
.1 .2 .3 .4
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
.4
.3
.2
.1
B
A
s1
s2
s3
Given...
subst. fract. A fract. Bq1 25 % 28 %q2 15 % 15 %
can we mix
?using s1, s2, s3
8 - 4
Mixing Things
.1 .2 .3 .4
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
.4
.3
.2
.1
B
A
s1
s2
s3
Given...
subst. fract. A fract. Bq1 25 % 28 %q2 15 % 15 %
can we mix
q1
q2
?using s1, s2, s3
8 - 5
Mixing Things
.1 .2 .3 .4
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
.4
.3
.2
.1
B
A
s1
s2
s3
Given...
subst. fract. A fract. Bq1 25 % 28 %q2 15 % 15 %
can we mix
q1
q2
?using s1, s2, s3
8 - 6
Mixing Things
.1 .2 .3 .4
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
.4
.3
.2
.1
B
A
s1
s2
s3
Given...
subst. fract. A fract. Bq1 25 % 28 %q2 15 % 15 %
can we mix
q1
q2
?using s1, s2, s3
Observe: Given a set S ⊂ R2 of substances, we can mix asubstance q ∈ R2 using the substances in S ⇔
8 - 7
Mixing Things
.1 .2 .3 .4
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
.4
.3
.2
.1
B
A
s1
s2
s3
Given...
subst. fract. A fract. Bq1 25 % 28 %q2 15 % 15 %
can we mix
q1
q2
?using s1, s2, s3
Observe: Given a set S ⊂ R2 of substances, we can mix asubstance q ∈ R2 using the substances in S ⇔q ∈ CH(S).
8 - 8
Mixing Things
.1 .2 .3 .4
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
.4
.3
.2
.1
B
A
s1
s2
s3
Given...
subst. fract. A fract. Bq1 25 % 28 %q2 15 % 15 %
can we mix
q1
q2
?using s1, s2, s3
Observe: Given a set S ⊂ R2 of substances, we can mix asubstance q ∈ R2 using the substances in S ⇔q ∈ CH(S).
s4
8 - 9
Mixing Things
.1 .2 .3 .4
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
.4
.3
.2
.1
B
A
s1
s2
s3
Given...
subst. fract. A fract. Bq1 25 % 28 %q2 15 % 15 %
can we mix
q1
q2
?using s1, s2, s3
Observe: Given a set S ⊂ R2 of substances, we can mix asubstance q ∈ R2 using the substances in S ⇔q ∈ CH(S).
s4
s5
8 - 10
Mixing Things
.1 .2 .3 .4
subst. fract. A fract. Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %
.4
.3
.2
.1
B
A
s1
s2
s3
Given...
subst. fract. A fract. Bq1 25 % 28 %q2 15 % 15 %
can we mix
q1
q2
?using s1, s2, s3
Observe: Given a set S ⊂ R2 of substances, we can mix asubstance q ∈ R2 using the substances in S ⇔q ∈ CH(S).
d
d
s4
s5
9 - 1
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
9 - 2
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
Physics approach:
9 - 3
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
Physics approach: – take (large enough) elastic rope
9 - 4
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
Physics approach: – take (large enough) elastic rope– stretch and let go
9 - 5
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
Physics approach: – take (large enough) elastic rope– stretch and let go
9 - 6
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
Physics approach: – take (large enough) elastic rope– stretch and let go– take area inside (and on) the rope
9 - 7
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
Physics approach: – take (large enough) elastic rope– stretch and let go– take area inside (and on) the rope
9 - 8
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
Physics approach: – take (large enough) elastic rope– stretch and let go– take area inside (and on) the rope
Math approach:
9 - 9
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
Physics approach: – take (large enough) elastic rope– stretch and let go– take area inside (and on) the rope
Math approach: – define convex
9 - 10
Formally. . .
Given S ⊂ R2, how do we define the convex hull CH(S)?
Physics approach: – take (large enough) elastic rope– stretch and let go– take area inside (and on) the rope
Math approach: – define convex– define CH(S) =
⋂C⊇S : C convex
C
10 - 1
Towards Computation
Problem with math approach:
CH(S) =def⋂
C⊇S : C convex
C
10 - 2
Towards Computation
Problem with math approach:
CH(S) =def⋂
C⊇S : C convex
C
This set is HUGE!
10 - 3
Towards Computation
Problem with math approach:
CH(S) =def⋂
C⊇S : C convex
C
This set is HUGE!
Maybe we can do with a little less?
10 - 4
Towards Computation
Problem with math approach:
CH(S) =def⋂
C⊇S : C convex
C
This set is HUGE!
Maybe we can do with a little less?
Claim: CH(S) =
10 - 5
Towards Computation
Problem with math approach:
CH(S) =def⋂
C⊇S : C convex
C
This set is HUGE!
Maybe we can do with a little less?
Claim: CH(S) =⋂
H⊇S :
H
H closed halfplane
10 - 6
Towards Computation
Problem with math approach:
CH(S) =def⋂
C⊇S : C convex
C
This set is HUGE!
Maybe we can do with a little less?
Claim: CH(S) =⋂
H⊇S :
H =
H closed halfplane
10 - 7
Towards Computation
Problem with math approach:
CH(S) =def⋂
C⊇S : C convex
C
This set is HUGE!
Maybe we can do with a little less?
Claim: CH(S) =⋂
H⊇S :
H =⋂
H⊇S : H cl. halfplane,
H
|∂H ∩ S| ≥ 2H closed halfplane
11 - 1
Computer Science ApproachInput: set S of n points in the plane, that is, S ⊂ R2
11 - 2
Computer Science ApproachInput: set S of n points in the plane, that is, S ⊂ R2
11 - 3
Computer Science ApproachInput: set S of n points in the plane, that is, S ⊂ R2
11 - 4
Computer Science ApproachInput:
Output:
set S of n points in the plane, that is, S ⊂ R2
list of vertices of CH(S) in clockwise order
11 - 5
Computer Science ApproachInput:
Output:
set S of n points in the plane, that is, S ⊂ R2
list of vertices of CH(S) in clockwise order
Observation. (p, q) is an edge of CH(S) ⇔
p q
11 - 6
Computer Science ApproachInput:
Output:
set S of n points in the plane, that is, S ⊂ R2
list of vertices of CH(S) in clockwise order
Observation. (p, q) is an edge of CH(S) ⇔each point in S lies– strictly to the right of the directed line −→pq or– on the line segment pq
p q−→pq
12 - 1
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
12 - 2
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
// test: (p, q) edge of CH(S)?
12 - 3
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
// test: (p, q) edge of CH(S)?
12 - 4
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
r strictly right of −→pqm∣∣∣∣∣∣
xr yr 1xp yp 1xq yq 1
∣∣∣∣∣∣ < 0
12 - 5
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
r strictly right of −→pqm∣∣∣∣∣∣
xr yr 1xp yp 1xq yq 1
∣∣∣∣∣∣ < 0
Important:Test takes O(1) time!
12 - 6
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
r strictly right of −→pqm∣∣∣∣∣∣
xr yr 1xp yp 1xq yq 1
∣∣∣∣∣∣ < 0
Important:Test takes O(1) time!
12 - 7
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
r strictly right of −→pqm∣∣∣∣∣∣
xr yr 1xp yp 1xq yq 1
∣∣∣∣∣∣ < 0
Important:Test takes O(1) time!
12 - 8
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
r strictly right of −→pqm∣∣∣∣∣∣
xr yr 1xp yp 1xq yq 1
∣∣∣∣∣∣ < 0
Important:Test takes O(1) time!
12 - 9
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
r strictly right of −→pqm∣∣∣∣∣∣
xr yr 1xp yp 1xq yq 1
∣∣∣∣∣∣ < 0
Important:Test takes O(1) time!
12 - 10
Finally, an Algorithm
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
r strictly right of −→pqm∣∣∣∣∣∣
xr yr 1xp yp 1xq yq 1
∣∣∣∣∣∣ < 0
Important:Test takes O(1) time!
13 - 1
Running Time Analysis
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
13 - 2
Running Time Analysis
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
13 - 3
Running Time Analysis
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
Θ(1)
13 - 4
Running Time Analysis
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
Θ(1)
Θ(n)
13 - 5
Running Time Analysis
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
Θ(1)
Θ(n)
(n2 − n)·
13 - 6
Running Time Analysis
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
Θ(1)
Θ(n)
(n2 − n)·
Θ(n
3 )
13 - 7
Running Time Analysis
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
Θ(1)
Θ(n)
(n2 − n)·
Θ(n
3 )O(n
2 )
13 - 8
Running Time Analysis
FirstConvexHull(S)E← ∅foreach (p, q) ∈ S× S with p 6= q do
valid← trueforeach r ∈ S do
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
if valid thenE← E ∪ {(p, q)}
from E construct sorted list L of vertices of CH(S)return L
Θ(1)
Θ(n)
(n2 − n)·
Θ(n
3 )O(n
2 )
Lemma. We can compute the convex hull of n pts in theplane in Θ(n3) time.
14 - 1
Discussion if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
14 - 2
Discussion
r
p
q E
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
14 - 3
Discussion
r
p
q E
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
14 - 4
Discussion
r
p
q E
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
Test may returnwrong answer(floating pt arithmetic!):
r right of −→pq :-(
14 - 5
Discussion
r
p
q E
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
E
Test may returnwrong answer(floating pt arithmetic!):
r right of −→pq :-(
p
r
q
14 - 6
Discussion
r
p
q E
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
E
Test may returnwrong answer(floating pt arithmetic!):
r right of −→pq :-(
p not right of −→rq
p
r
q
14 - 7
Discussion
r
p
q E
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
E
Test may returnwrong answer(floating pt arithmetic!):
r right of −→pq :-(
p not right of −→rq
q not right of −→pr
p
r
q
14 - 8
Discussion
r
p
q E
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
E
Test may returnwrong answer(floating pt arithmetic!):
r right of −→pq :-(
p not right of −→rq
q not right of −→pr
p
r
q
14 - 9
Discussion
r
p
q E
if not (r strictly right of −→pq or r ∈ pq) thenvalid← false
E
Test may returnwrong answer(floating pt arithmetic!):
r right of −→pq :-(
p not right of −→rq
q not right of −→pr
p
r
q
Observation. Algorithm FirstConvexHull is not robust.
15 - 1
New Ideas (Graham Scan)
15 - 2
New Ideas (Graham Scan)• split computation in two
15 - 3
New Ideas (Graham Scan)• split computation in two
upper convex hull
15 - 4
New Ideas (Graham Scan)• split computation in two
upper convex hull
lower convex hull
15 - 5
New Ideas (Graham Scan)• split computation in two
• bring pts in lexicographic order
upper convex hull
lower convex hull
15 - 6
New Ideas (Graham Scan)• split computation in two
• bring pts in lexicographic order
upper convex hull
lower convex hull• proceed incrementally
15 - 7
New Ideas (Graham Scan)• split computation in two
• bring pts in lexicographic order
upper convex hull
lower convex hullUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
• proceed incrementally
15 - 8
New Ideas (Graham Scan)• split computation in two
• bring pts in lexicographic order
upper convex hull
lower convex hullUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
• proceed incrementally
15 - 9
New Ideas (Graham Scan)• split computation in two
• bring pts in lexicographic order
upper convex hull
lower convex hullUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
• proceed incrementally
15 - 10
New Ideas (Graham Scan)• split computation in two
• bring pts in lexicographic order
upper convex hull
lower convex hullUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
• proceed incrementally
// compute upper convex hull of {p1, p2, . . . , pi}
15 - 11
New Ideas (Graham Scan)• split computation in two
• bring pts in lexicographic order
upper convex hull
lower convex hullUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
• proceed incrementally
// compute upper convex hull of {p1, p2, . . . , pi}
15 - 12
New Ideas (Graham Scan)• split computation in two
• bring pts in lexicographic order
upper convex hull
lower convex hullUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
• proceed incrementally
// compute upper convex hull of {p1, p2, . . . , pi}
16 - 1
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
16 - 2
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
O(n log n)
16 - 3
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
O(n log n)
(n− 2)·
16 - 4
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
O(n log n)
(n− 2)·
?
16 - 5
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
O(n log n)
(n− 2)·
?
Amortized analysis:
16 - 6
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
O(n log n)
(n− 2)·
?
Amortized analysis:– each pt p2, . . . , pn−1 pays 1e for its potential removal later on
16 - 7
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
O(n log n)
(n− 2)·
?
Amortized analysis:– each pt p2, . . . , pn−1 pays 1e for its potential removal later on– this pays for the total effort of all executions of the while loop
16 - 8
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
O(n log n)
(n− 2)·
?
Amortized analysis:– each pt p2, . . . , pn−1 pays 1e for its potential removal later on– this pays for the total effort of all executions of the while loop
16 - 9
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
O(n log n)
(n− 2)·
?
Amortized analysis:– each pt p2, . . . , pn−1 pays 1e for its potential removal later on– this pays for the total effort of all executions of the while loop
O(n)
16 - 10
Running Time AnalysisUpperConvexHull(S: set of pts in the plane)〈p1, p2, . . . , pn〉 ← sort S lexicographicallyL← 〈p1, p2〉for i← 3 to n do
L.append(pi)while |L| > 2 and last 3 pts in L make no right turn do
remove second last pt from L
return L
O(n log n)
(n− 2)·
?
Amortized analysis:– each pt p2, . . . , pn−1 pays 1e for its potential removal later on– this pays for the total effort of all executions of the while loop
O(n)
Theorem. We can compute the convex hull of n pts in theplane in O(n log n) time – in a robust way.
17 - 1
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 2
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 3
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 4
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 5
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 6
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 7
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 8
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 9
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 10
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
17 - 11
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
Runtime?
17 - 12
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
Runtime? O(n · h)
17 - 13
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
. . . where h = |CH(S)| = size of the output
Runtime? O(n · h)
17 - 14
Output-Sensitive Algorithms• Jarvis’ gift-wrapping algorithm (aka Jarvis’ march)
• Chan’s exponential-search algorithm O(n log h)
. . . where h = |CH(S)| = size of the output
Runtime? O(n · h)
18 - 1
Chan’s Algorithm P1P2
P4
P3
18 - 2
Chan’s Algorithm P1P2
P4
P3
[in O(m log m) time]
18 - 3
Chan’s Algorithm P1P2
P4
P3
[in O(m log m) time]
p1
p0
18 - 4
Chan’s Algorithm P1P2
P4
P3
[in O(m log m) time]
p1
p0
18 - 5
Chan’s Algorithm P1P2
P4
P3
q1
q3q4
q2
[in O(m log m) time]
pk
pk−1
pk+1
p1
p0
18 - 6
Chan’s Algorithm P1P2
P4
P3
q1
q3q4
q2
[in O(m log m) time]
pk
pk−1
pk+1
p1
p0
18 - 7
Chan’s Algorithm P1P2
P4
P3
q1
q3q4
q2
[in O(m log m) time]
pk
pk−1
pk+1
p1
p0
19
Chan’s AlgorithmInitially, we assume that the value of h is known and make a parameter m = h. This assumption is not realistic, but weremove it later. The algorithm starts by arbitrarily partitioning P into at most 1 + n
m subsets Q with at most m pointseach. Then, it computes the convex hull of each subset Q using an O(n log n) algorithm – Graham’s scan. Note that, asthere are O(n/m) subsets of O(m) points each, this phase takes O(n/m) ·O(m log m) = O(n log m) time.
The second phase consists of executing the Jarvis’ march algorithm algorithm and using the precomputed convex hullsto speed up the execution. At each step in Jarvis’s march, we have a point pi in the convex hull, and need to find a pointpi+1 = f (pi , P) such that all other points of P are to the right of the line pi pi+1. If we know the convex hull of a set Qof m points, then we can compute f (pi , Q) in O(log m) time, by using binary search. We can compute f (pi , Q) for allthe O(n/m) subsets Q in O(n/m log m) time. Then, we can determine f (pi , P) using the same technique as normallyused in Jarvis’s march, but only considering the points that are f (pi , Q) for some subset Q. As Jarvis’s march repeatsthis process O(h) times, the second phase also takes O(n log m) time, and therefore O(n log h) time if m = h.By running the two phases described above, we can compute the convex hull of n points in O(n log h) time, assumingthat we know the value of h. If we make m < h, we can abort the execution after m + 1 steps, therefore spending onlyO(n log m) time (but not computing the convex hull). We can initially set m as a small constant (we use 2 for ouranalysis, but in practice numbers around 5 may work better), and increase the value of m until m > h, in which case weobtain the convex hull as a result.If we increase the value of m too slowly, we may need to repeat the steps mentioned before too many times, and theexecution time will be large. On the other hand, if we increase the value of m too quickly, we risk making m much largerthan h, also increasing the execution time. Similar to strategy used by Chazelle and Matousek’s algorithm, Chan’salgorithm squares the value of m at each iteration, and makes sure that m is never larger than n. In other words, at
iteration t (starting at 1), we have m = min(
n, 22t)
. The total running time of the algorithm is
dlog log he∑
t=1O(
n log(22t)
)= O(n)
dlog log he∑
t=1O(2t ) = O
(n · 21+dlog log he) = O(n log h).
To generalize this construction for the 3-dimensional case, an O(n log n) algorithm to compute the 3-dimensionalconvex hull should be used instead of Graham scan, and a 3-dimensional version of Jarvis’s march needs to be used.The time complexity remains O(n log h).
[Text copied on October 17, 2017 from:https://en.wikipedia.org/wiki/Chan’s algorithm]
top related