<<

Outline

Computational : • Definitions Convex Hulls •

Definition I Definition I

A set S is convex if for any two points A set S is convex if for any two points p,q∈S, the pq⊂S. 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 A set S is convex if it is the intersection p,q∈S, the line segment pq⊂S. 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 • Definitions of (possibly infinitely many) half-spaces. • Algorithms

S S p

q

Not Convex Convex

Convex Hull Convex Hull

Definition: Definition:

Given a finite set of points P={p1,…,pn}, Given a finite set of points P={p1,…,pn}, the convex hull of P is the smallest the convex hull of P is the smallest C such that P⊂C. convex set C such that P⊂C. p p 1 1 C p2 p2

pn pn

Examples Examples

Two Dimensions: Three Dimensions:

The convex hull of P={p1,…,pn} is a set The convex hull of P={p1,…,pn} is a of line segments with endpoints in P. mesh with vertices in P.

p 1 C p2

pn

2 Algorithms Algorithms

Brute Force (2D): Brute Force (2D): Given a set of points P, test each line Given a set of points P, test each line segment to see if it makes up an edge of segment to see if it makes up an edge of the convex hull. 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): Brute Force (2D): Given a set of points P, test each line Given a set of points P, test each line segment to see if it makes up an edge of segment to see if it makes up an edge of the convex hull. If the rest of the points the convex hull. If the rest of the points a3re on one side of the a3re on one side of the Computation time is O(nse)g:ment, the segment Computation time is O(nse)g:ment, the segment O(n) complexity testsis, on the convex hull O(n) complexity testsis, on the convex hull for each of O(n2) edges for each of O(n2) edges Otherwise the segment Otherwise the segment is not on the hull In a d-dimensional spacise ,not on the hull the complexity is O(nd+1).

Algorithms Gift Wrapping

There are many algorithms for Key Idea: computing the convex hull: Iteratively growing edges of the convex – Brute Force: O(n3) hull, we want to turn as little as possible.

– Gift Wrapping • Given a directed edge on the hull… – Quickhull – Divide and Conquer

3 Gift Wrapping Gift Wrapping

Key Idea: Key Idea: Iteratively growing edges of the convex Iteratively growing edges of the convex hull, we want to turn as little as possible. hull, we want to turn as little as possible.

• Given a directed edge on the hull… • Given a directed edge on the hull… • Of all the vertices the next edge can • Of all the vertices the next edge can can connect to… can connect to… • Choose the one which turns least. … …

Gift Wrapping Gift Wrapping

Key Idea: Key Idea: Iteratively growing edges of the convex Iteratively growing edges of the convex hull, we want to turn as little as possible. hull, we want to turn as little as possible.

• Given a directed edge on the hull… • Given a directed edge on the hull… • Of all the vertices the next edge can • Of all the vertices the next edge can can connect to… can connect to… • Choose the one which turns least. • Choose the one which turns least. • Repeat • Repeat

Gift Wrapping Gift Wrapping

Key Idea: Key Idea: Iteratively growing edges of the convex Iteratively growing edges of the convex hull, we want to turn as little as possible. hull, we want to turn as little as possible.

• Given a directed edge on the hull… • Given a directed edge on the hull… • Of all the vertices the next edge can • Of all the vertices the next edge can can connect to… can connect to… • Choose the one which turns least. • Choose the one which turns least. • Repeat • Repeat

4 Algorithms Quickhull

There are many algorithms for Key Idea: computing the convex hull: For all a,b,c∈P, the points contained in – Brute Force: O(n3) ∆abc∩P cannot be on the convex hull. – Gift Wrapping: O(n2) – Quickhull – Divide and Conquer

Quickhull Quickhull

Key Idea: Key Idea: For all a,b,c∈P, the points contained in For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull. ∆abc∩P cannot be on the convex hull.

b b

c c a a

Quickhull Quickhull

Key Idea: Key Idea: For all a,b,c∈P, the points contained in For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull. ∆abc∩P cannot be on the convex hull.

• Given a line segment ab … • Given a line segment ab … b b • Find the point c, rightmost from ab …

c

a a

5 Quickhull Quickhull

Key Idea: Key Idea: For all a,b,c∈P, the points contained in For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull. ∆abc∩P cannot be on the convex hull.

• Given a line segment ab … • Given a line segment ab … b • Find the point c, rightmost from ab … b • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • If c doesn’t exist, return ab … c c • Discard the points in ∆abc …

a a

Quickhull Quickhull

Key Idea: Key Idea: For all a,b,c∈P, the points contained in For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull. ∆abc∩P cannot be on the convex hull.

• Given a line segment ab … • Given a line segment ab … b • Find the point c, rightmost from ab … b • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • If c doesn’t exist, return ab … c • Discard the points in ∆abc … c • Discard the points in ∆abc … • Repeat for left of bc and ca … • Repeat for left of bc and ca … • Repeat for left of ba … a a

Quickhull Quickhull

Key Idea: Key Idea: For all a,b,c∈P, the points contained in For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull. ∆abc∩P cannot be on the convex hull.

• Given a line segment ab … • Given a line segment ab … b • Find the point c, rightmost from ab … b • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • If c doesn’t exist, return ab … c • Discard the points in ∆abc … c • Discard the points in ∆abc … • Repeat for left of bc and ca … • Repeat for left of bc and ca … d • Repeat for left of ba … d • Repeat for left ba … a a

6 Quickhull Quickhull

Key Idea: Key Idea: For all a,b,c∈P, the points contained in For all a,b,c∈P, the points contained in ∆abc∩P cannot be on the convex hull. ∆abc∩P cannot be on the convex hull.

• Given a line segment ab … • Given a line segment ab … b • Find the point c, rightmost from ab … b • Find the point c, rightmost from ab … • If c doesn’t exist, return ab … • If c doesn’t exist, return ab … c • Discard the points in ∆abc … c • Discard the points in ∆abc … • Repeat for left of bc and ca … • Repeat for left of bc and ca … d • Repeat for left ba … d • Repeat for left of ba … e a e a

Algorithms Divide and Conquer

There are many algorithms for Key Idea: computing the convex hull: Finding the convex hull of small sets is – Brute Force: O(n3) easier than finding the hull of large ones. – Gift Wrapping: O(n2) – Quickhull: O(nlogn) – O(n2) – Divide and Conquer

Divide and Conquer Divide and Conquer

Key Idea: Merging Hulls: Finding the convex hull of small sets is Need to find the tangents joining the easier than finding the hull of large ones. hulls. All we need is a fast way to merge hulls. Upper Tangent

A B A B

Lower Tangent

7 Divide and Conquer Divide and Conquer

Observation: Proof: The edge ab is a tangent if the two points The edge ab is a tangent if the points on about a and the two points about b are on both hulls are all on one side of it. the same side of ab.

b” b”

B B a’ A a” a’ A a” b’ b’ a b a b

Divide and Conquer Divide and Conquer

Proof: Tangent : The edge ab is a tangent if the points on – Find an edge ab between A and B that does both hulls are all on one side of it. not intersect the two hulls. If a’ and a” are on the same side of ab, b’ then all of A must be on one side of ab. b” a” a b

B B a’ a’ A A a” a” a’ a” b’ b” a b a

Divide and Conquer Divide and Conquer

Tangent Algorithm: Tangent Algorithm: – Find an edge ab between A and B that does – Find an edge ab between A and B that does not intersect the two hulls. not intersect the two hulls. – While a’ and a” are not to the left of ab, – While a’ and a” are not to the left of ab, rotate a clock-wise. rotate a clock-wise. b’ a” b – While b’ and b” are not a” b’ to the left of ab, rotate A B A B a b counter-clock-wise. a b b” b” a’ a’

8 Divide and Conquer Divide and Conquer

Tangent Algorithm: Tangent Algorithm: – Find an edge ab between A and B that does – Find an edge ab between A and B that does not intersect the two hulls. not intersect the two hulls. – While a’ and a” are not to the left of ab, – While a’ and a” are not to the left of ab, rotate a clock-wise. rotate a clock-wise. – While b’ and b” are not a” b” – While b’ and b” are not b” to the left of ab, rotate to the left of ab, rotate A B A B b counter-clock-wise. a b’ b counter-clock-wise. a’ a” b’ b b 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)

9