convex hull. university of manchester biologists used lasers to measure the minimum amount of skin...

34
Convex Hull

Upload: gervais-bryan

Post on 17-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Convex Hull

Page 2: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day
Page 3: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day mammals, including reindeer, polar bears, giraffes and elephants.

They discovered that the animals had almost exactly 21% more body mass than the minimum skeletal 'skin and bone' wrap volume, and applied this to a giant Brachiosaur skeleton in Berlin's Museum für Naturkunde.

--ScienceDaily (June 5, 2012)

Page 4: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day
Page 5: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Convex Sets & Concave Sets

A planar region R is called convex if and only if for any pair of points p, q in R, the line segment pq lies completely in R. Otherwise, it is called concave.

Convex

p

qR 1

p

qR 2

Concave

Page 6: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Convex Hull The convex hull CH(Q) of a set Q is

the smallest convex region that contains Q. When Q is finite, its convex hull is the unique convex polygon whose vertices are from Q and that contains all points of Q.

Rubber band

Page 7: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

The Convex Hull Problem

Input: a set P = {p1, p2, …, pn} of points.

Output: a list of vertices of CH(P) in counterclockwise order.

Example:

CH(P)= { p2, p9, p5, p7, p10, p8}

8

pp

p

p

p

p

p

p

pp

9

210

5

76 1

3 4

Page 8: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Graham Scan

– incremental approach (similar to selection sort/insertion sort)

p 0

pp

pp

p

p

p

pp

p

12

3

4

p5

67

8

9

10

11

Page 9: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Graham Scan

Steps: Sort the angles form a convex hull of 1st three

points, add them to a stack push/pop the rest of the point on the

list based on we are make a right turn or left turn

Page 10: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Polar Angle

p

polar angle

x

y

q

r

Page 11: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Stack Initialization

p

pp

pp

p

p

p

pp

p

0

12

3

4

p5

67

8

9

10

11

p

p

p

S

0

1

2

Page 12: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

p

pp

pp

p

p

p

pp

p

0

12

3

4

p5

67

8

9

10

11

p

p

p

S

0

1

3

Page 13: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

p

pp

pp

p

p

p

pp

p

0

12

3

4

p5

67

8

9

10

11

p

p

p

S

0

1

4

Page 14: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

p

pp

pp

p

p

p

pp

p

0

12

3

4

p5

67

8

9

10

11

p

p

p

S

0

1

4

p 5

Page 15: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

p

pp

pp

p

p

p

pp

p

0

12

3

4

p5

67

8

9

10

11

p

p

p

S

0

1

4

p 6

Page 16: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

p

pp

pp

p

p

p

pp

p

0

12

3

4

p5

67

8

9

10

11

p

p

p

S

0

1

4

p 6

p 7

p 8

Page 17: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

p

pp

pp

p

p

p

pp

p

0

12

3

4

p5

67

8

9

10

11

p

p

p

S

0

1

4

p 6

p 7

Page 18: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

p

pp

p

p

p

p

p

pp

p

0

12

3

4

p5

6

78

9

10

11

p

p

p

S

0

1

4

p 6

p 9

p10

Page 19: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

p

pp

p

p

p

p

p

pp

p

0

12

3

4

p5

6

78

9

10

11

p

p

p

S

0

1

4

p 6

p 9

p11

Page 20: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Finish

p

pp

p

p

p

p

p

pp

p

0

12

3

4

p5

6

78

9

10

11

p

p

p

S

0

1

4

p 6

p 9

p11

Page 21: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Running time

The running time of Graham’s Scan is O(n lg n).

Page 22: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Jarvis march Gift wrapping

algorithm

How do we find the angle?

Complexity is O(hn)

Page 23: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Convex Hull - Divide and Conquer

Algorithm: Find a point with a median x coordinate (time:

O(n)) Compute the convex hull of each half

(recursive execution) Combine the two convex hulls by finding

common tangents.

Page 24: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Convex Hull - Divide and Conquer

If n ≤ 3, compute the hull by brute force o.w. divide points into A, B, where xi<xj,

piA, pjB. Recursively compute HA = Hull(A) and

HB = Hull(B). Merge the two hulls by computing the

upper and lower tangents for HA and HB and discarding all the points lying between these two tangents.

Page 25: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Convex Hull - CombineFinding the Lower Tangent LowerTangent (HA ;

HB ) : Let a be the rightmost point of HA . Let b be the leftmost point of HB . While ab is not a lower tangent for HA and HB do

While ab is not a lower tangent to HA do a = a - 1 (move a clockwise).

While ab is not a lower tangent to HB do b = b + 1 (move b counterclockwise).

Return ab.

Page 26: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Combine (a,b)=(right most, left most) …

a

b

Page 27: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Complexity

Complexity: O(nlogn)

Page 28: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Quick Hull

Quick hull – based on the idea of quick sort

S

Page 29: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Quick Hull Partition

l

r

L

S(1)

S(2)

Page 30: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Quick Hull

l

r

Page 31: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Quick Hull

l

r

LL1

L2

S(1,1)

S(1,2)

eliminated

h

Page 32: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Quick Hull

L

l

r

L1

L2

S(1,2,2)

h

S(1,2)

Page 33: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Quick Hull

Complexity T(n) = O(n2) worst case T(n) = O(nlogn) average and best case

Page 34: Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day

Graphs