pn. },. the convex hull of P is the smallest. convex set C such that PâC. p1. p2. pn. C. Examples. Two Dimensions: The
Outline
Computational Geometry: Convex Hulls
• Definitions • Algorithms
Definition I
Definition I
A set S is convex if for any two points p,q∈S, the line segment pq⊂S.
A set S is convex if for any two points p,q∈S, the line segment pq⊂S.
S
S
S
S p q Not Convex
Definition I
Definition II
A set S is convex if for any two points p,q∈S, the line segment pq⊂S.
A set S is convex if it is the intersection of (possibly infinitely many) half-spaces.
S
S
S
S
p
p
q
q
Not Convex
Convex?
Not Convex
Convex?
1
Definition II
Outline
A set S is convex if it is the intersection of (possibly infinitely many) half-spaces.
• Definitions • Algorithms
S
S p q Not Convex
Convex
Convex Hull
Convex Hull
Definition: Given a finite set of points P={p1,…,pn}, the convex hull of P is the smallest convex set C such that P⊂C.
Definition: Given a finite set of points P={p1,…,pn}, the convex hull of P is the smallest convex set C such that P⊂C.
p1
p1
p2
pn
p2
C
pn
Examples
Examples
Two Dimensions: The convex hull of P={p1,…,pn} is a set of line segments with endpoints in P.
Three Dimensions: The convex hull of P={p1,…,pn} is a triangle mesh with vertices in P.
p1
p2
C
pn
2
Algorithms
Algorithms
Brute Force (2D): Given a set of points P, test each line segment to see if it makes up an edge of the convex hull.
Brute Force (2D): Given a set of points P, test each line segment to see if it makes up an edge of the convex hull. If the rest of the points are on one side of the segment, the segment is on the convex hull Otherwise the segment is not on the hull
Algorithms
Algorithms
Brute Force (2D): Given a set of points P, test each line segment to see if it makes up an edge of the convex hull. If the rest of the points
Brute Force (2D): Given a set of points P, test each line segment to see if it makes up an edge of the convex hull. If the rest of the points
are on one side of the
3): Computation time is O(nsegment, the segment is on the convex hull O(n) complexity tests, for each of O(n2) edges
Otherwise the segment is not on the hull
are on one side of the
3): Computation time is O(nsegment, the segment is on the convex hull O(n) complexity tests, for each of O(n2) edges
Otherwise the segment
is not on the hull In a d-dimensional space, the complexity is O(nd+1).
Algorithms
Gift Wrapping
There are many algorithms for computing the convex hull:
Key Idea: Iteratively growing edges of the convex hull, we want to turn as little as possible.
– Brute Force: O(n3) – Gift Wrapping – Quickhull – Divide and Conquer
• Given a directed edge on the hull…
3
Gift Wrapping
Gift Wrapping
Key Idea: Iteratively growing edges of the convex hull, we want to turn as little as possible.
Key Idea: Iteratively growing edges of the convex hull, we want to turn as little as possible.
• Given a directed edge on the hull… • Of all the vertices the next edge can can connect to… …
• Given a directed edge on the hull… • Of all the vertices the next edge can can connect to… • Choose the one which turns least. …
Gift Wrapping
Gift Wrapping
Key Idea: Iteratively growing edges of the convex hull, we want to turn as little as possible.
Key Idea: Iteratively growing edges of the convex hull, we want to turn as little as possible.
• Given a directed edge on the hull… • Of all the vertices the next edge can can connect to… • Choose the one which turns least. • Repeat
• Given a directed edge on the hull… • Of all the vertices the next edge can can connect to… • Choose the one which turns least. • Repeat
Gift Wrapping
Gift Wrapping
Key Idea: Iteratively growing edges of the convex hull, we want to turn as little as possible.
Key Idea: Iteratively growing edges of the convex hull, we want to turn as little as possible.
• Given a directed edge on the hull… • Of all the vertices the next edge can can connect to… • Choose the one which turns least. • Repeat
• Given a directed edge on the hull… • Of all the vertices the next edge can can connect to… • Choose the one which turns least. • Repeat
4
Algorithms
Quickhull
There are many algorithms for computing the convex hull:
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
– Brute Force: O(n3) – Gift Wrapping: O(n2) – Quickhull – Divide and Conquer
Quickhull
Quickhull
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
b
b
c
c
a
a
Quickhull
Quickhull
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
• Given a line segment ab …
b
• Given a line segment ab … • Find the point c, rightmost from ab …
b c
a
a
5
Quickhull
Quickhull
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
• Given a line segment ab … • Find the point c, rightmost from ab … • If c doesn’t exist, return ab …
b
b
c
c
• Given a line segment ab … • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • Discard the points in ∆abc …
a
a
Quickhull
Quickhull
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
b c
• Given a line segment ab … • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • Discard the points in ∆abc … • Repeat for left of bc and ca …
b c
a
• Given a line segment ab … • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • Discard the points in ∆abc … • Repeat for left of bc and ca … • Repeat for left of ba …
a
Quickhull
Quickhull
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
b c d a
• Given a line segment ab … • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • Discard the points in ∆abc … • Repeat for left of bc and ca … • Repeat for left of ba …
b c d
• Given a line segment ab … • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • Discard the points in ∆abc … • Repeat for left of bc and ca … • Repeat for left ba …
a
6
Quickhull
Quickhull
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
Key Idea: For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull.
b c d e
• Given a line segment ab … • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • Discard the points in ∆abc … • Repeat for left of bc and ca … • Repeat for left ba …
a
b c d e
• Given a line segment ab … • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • Discard the points in ∆abc … • Repeat for left of bc and ca … • Repeat for left of ba …
a
Algorithms
Divide and Conquer
There are many algorithms for computing the convex hull:
Key Idea: Finding the convex hull of small sets is easier than finding the hull of large ones.
– Brute Force: O(n3) – Gift Wrapping: O(n2) – Quickhull: O(nlogn) – O(n2) – Divide and Conquer
Divide and Conquer
Divide and Conquer
Key Idea: Finding the convex hull of small sets is easier than finding the hull of large ones. All we need is a fast way to merge hulls.
Merging Hulls: Need to find the tangents joining the hulls. Upper Tangent
A
B
A
B
Lower Tangent
7
Divide and Conquer
Divide and Conquer
Observation: The edge ab is a tangent if the two points about a and the two points about b are on the same side of ab.
Proof: The edge ab is a tangent if the points on both hulls are all on one side of it.
b” A
a’
b”
B
a”
Divide and Conquer
Proof: The edge ab is a tangent if the points on both hulls are all on one side of it. If a’ and a” are on the same side of ab, then all of A must be on one side of ab.
Tangent Algorithm:
A
a’
a
– Find an edge ab between A and B that does not intersect the two hulls.
b
a
Divide and Conquer
Divide and Conquer
Tangent Algorithm:
Tangent Algorithm:
– Find an edge ab between A and B that does not intersect the two hulls. – While a’ and a” are not to the left of ab, rotate a clock-wise.
A a’
b B a
b”
a A
b’
a”
b’
a”
b”
B
a”
b
a
Divide and Conquer
a”
B
a” b’
b
a
a’
A
a’
b’
b’
b B a’
b”
– Find an edge ab between A and B that does not intersect the two hulls. – While a’ and a” are not to the left of ab, rotate a clock-wise. – While b’ and b” are not a” b’ to the left of ab, rotate B A b a b counter-clock-wise. a’
b”
8
Divide and Conquer
Divide and Conquer
Tangent Algorithm:
Tangent Algorithm:
– Find an edge ab between A and B that does not intersect the two hulls. – While a’ and a” are not to the left of ab, rotate a clock-wise. – While b’ and b” are not a” to the left of ab, rotate B A a b’ b counter-clock-wise. a’
b”
b
– Find an edge ab between A and B that does not intersect the two hulls. – While a’ and a” are not to the left of ab, rotate a clock-wise. – While b’ and b” are not to the left of ab, rotate B a” b’ b counter-clock-wise. a’ A – Repeat a
b”
b
Algorithms There are many algorithms for computing the convex hull: – Brute Force: O(n3) – Gift Wrapping: O(n2) – Quickhull: O(nlogn) – O(n2) – Divide and Conquer: O(nlogn)
9