Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day."— Presentation transcript:

1 Convex Hull

2

3 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. 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. 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) --ScienceDaily (June 5, 2012)

4

5 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. 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 q R 1 p q R 2 Concave

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

7 The Convex Hull Problem Input: a set P = {p 1, p 2, …, p n } of points. Output: a list of vertices of CH(P) in counterclockwise order. Example: CH(P)= { p 2, p 9, p 5, p 7, p 10, p 8 } 8 p p p p p p p p p p 9 2 10 5 76 1 3 4

8 Graham Scan – incremental approach – incremental approach (similar to selection sort/insertion sort) p 0 p p p p p p p p p p 1 2 3 4 p 5 6 7 8 9 10 11

9 Graham Scan Steps: Sort the angles Sort the angles form a convex hull of 1 st three points, add them to a stack form a convex hull of 1 st 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 push/pop the rest of the point on the list based on we are make a right turn or left turn

10 Polar Angle p polar angle x y q r

11 Stack Initialization p p p p p p p p p p p 0 1 2 3 4 p 5 6 7 8 9 10 11 p p p S 0 1 2

12 p p p p p p p p pp p 0 1 2 3 4 p 5 6 7 8 9 10 11 p p p S 0 1 3

13 p p p p p p p p pp p 0 1 2 3 4 p 5 6 7 8 9 10 11 p p p S 0 1 4

14 p p p p p p p p pp p 0 1 2 3 4 p 5 6 7 8 9 10 11 p p p S 0 1 4 p 5

15 p p p p p p p p pp p 0 1 2 3 4 p 5 6 7 8 9 10 11 p p p S 0 1 4 p 6

16 p p p p p p p p pp p 0 1 2 3 4 p 5 6 7 8 9 10 11 p p p S 0 1 4 p 6 p 7 p 8

17 p p p p p p p p pp p 0 1 2 3 4 p 5 6 7 8 9 10 11 p p p S 0 1 4 p 6 p 7

18 p p p p p p p p pp p 0 1 2 3 4 p 5 6 7 8 9 10 11 p p p S 0 1 4 p 6 p 9 p 10

19 p p p p p p p p pp p 0 1 2 3 4 p 5 6 7 8 9 11 p p p S 0 1 4 p 6 p 9 p

20 Finish p p p p p p p p pp p 0 1 2 3 4 p 5 6 7 8 9 10 11 p p p S 0 1 4 p 6 p 9 p

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

22 Jarvis march Gift wrapping Gift wrappingalgorithm How do we find the How do we find theangle? Complexity is O(hn) Complexity is O(hn)

23 Convex Hull - Divide and Conquer Algorithm: Algorithm: Find a point with a median x coordinate (time: O(n)) Find a point with a median x coordinate (time: O(n)) Compute the convex hull of each half (recursive execution) Compute the convex hull of each half (recursive execution) Combine the two convex hulls by finding common tangents. Combine the two convex hulls by finding common tangents.

24 Convex Hull - Divide and Conquer If n ≤ 3, compute the hull by brute force If n ≤ 3, compute the hull by brute force o.w. divide points into A, B, where x i <x j,  p i  A, p j  B. o.w. divide points into A, B, where x i <x j,  p i  A, p j  B. Recursively compute HA = Hull(A) and HB = Hull(B). 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. 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.

25 Convex Hull - Combine Finding the Lower Tangent LowerTangent (HA ; HB ) : Let a be the rightmost point of HA. Let a be the rightmost point of HA. Let b be the leftmost point of HB. 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 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 HA do a = a - 1 (move a clockwise). While ab is not a lower tangent to HB do b = b + 1 (move b counterclockwise). While ab is not a lower tangent to HB do b = b + 1 (move b counterclockwise). Return ab. Return ab.

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

27 Complexity Complexity: O(nlogn) Complexity: O(nlogn)

28 Quick Hull Quick hull – based on the idea of quick sort Quick hull – based on the idea of quick sort S

29 Quick Hull Partition Partition l r L S (1) S (2)

30 Quick Hull l r

31 l r L L1L1 L2L2 S (1,1) S (1,2) eliminated h

32 Quick Hull L l r L1L1 L2L2 S (1,2,2) h S (1,2)

33 Quick Hull Complexity Complexity T(n) = O(n 2 ) worst case T(n) = O(n 2 ) worst case T(n) = O(nlogn) average and best case T(n) = O(nlogn) average and best case

34 Graphs


Download ppt "Convex Hull. University of Manchester biologists used lasers to measure the minimum amount of skin required to wrap around the skeletons of modern-day."

Similar presentations


Ads by Google