You are on page 1of 9

Outline

Computational Geometry:
Convex Hulls

Definitions
Algorithms

Definition I

Definition I

A set S is convex if for any two points


p,qS, the line segment pqS.

A set S is convex if for any two points


p,qS, the line segment pqS.

S
p
q
Not Convex

Definition I

Definition II

A set S is convex if for any two points


p,qS, the line segment pqS.

A set S is convex if it is the intersection


of (possibly infinitely many) half-spaces.

Not Convex

Convex?

Not Convex

Convex?

Definition II

Outline

A set S is convex if it is the intersection


of (possibly infinitely many) half-spaces.

Definitions
Algorithms

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 PC.

Definition:
Given a finite set of points P={p1,,pn},
the convex hull of P is the smallest
convex set C such that PC.

p1

p1

p2

pn

p2

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

pn

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

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

Algorithms

Quickhull

There are many algorithms for


computing the convex hull:

Key Idea:
For all a,b,cP, the points contained in
abcP 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,cP, the points contained in
abcP cannot be on the convex hull.

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

Quickhull

Quickhull

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

Given a line segment ab

Given a line segment ab


Find the point c, rightmost from ab

b
c

Quickhull

Quickhull

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

Given a line segment ab


Find the point c, rightmost from ab
If c doesnt exist, return ab

Given a line segment ab


Find the point c, rightmost from ab
If c doesnt exist, return ab
Discard the points in abc

Quickhull

Quickhull

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

b
c

Given a line segment ab


Find the point c, rightmost from ab
If c doesnt exist, return ab
Discard the points in abc
Repeat for left of bc and ca

b
c

Given a line segment ab


Find the point c, rightmost from ab
If c doesnt exist, return ab
Discard the points in abc
Repeat for left of bc and ca
Repeat for left of ba

Quickhull

Quickhull

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

b
c
d
a

Given a line segment ab


Find the point c, rightmost from ab
If c doesnt 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 doesnt exist, return ab
Discard the points in abc
Repeat for left of bc and ca
Repeat for left ba

Quickhull

Quickhull

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

Key Idea:
For all a,b,cP, the points contained in
abcP cannot be on the convex hull.

b
c
d
e

Given a line segment ab


Find the point c, rightmost from ab
If c doesnt exist, return ab
Discard the points in abc
Repeat for left of bc and ca
Repeat for left ba

b
c
d
e

Given a line segment ab


Find the point c, rightmost from ab
If c doesnt exist, return ab
Discard the points in abc
Repeat for left of bc and ca
Repeat for left of ba

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

Lower Tangent

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

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:

Find an edge ab between A and B that does


not intersect the two hulls.

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

a
A

Divide and Conquer

a
b

b
B
a

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

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

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

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)

You might also like