210 likes | 418 Views
Convex Hull A lgorithms. What is the convex hull problem?. Definition: Given a set of points, find the sub set of points that makes up the convex hull polygon of the given points. What is a Convex hull polygon?. The smallest convex polygon that can contain all the given points.
E N D
What is the convex hull problem? • Definition: • Given a set of points, find the sub set of points that makes up the convex hull polygon of the given points
What is a Convex hull polygon? The smallest convex polygon that can contain all the given points. (Informal Definition) The polygon or shape that will be formed if a rubber band is stretched and released around a bunch of pins.
Three Convex hull Algorithms • Divide and Conquer • Quick Hull • Gift Wrap or Jarvis's march
Background Math Concepts • Cross Products • Perpendicular distance between a line and point
Cross Product A binary operation carried out on two vectors. It is represented by an “X” symbol A X B = |A||B| sin(θ) B A Cross Product also gives the area of a parallelogram whose edges are defined by the two vectors B A
Useful properties of the cross product B A A X B = 0 B B A A CCW CW B X A < 0 A X B > 0
Position of points relative to line Given three points: P1, P2, and P3 P3 B , ) B P1 A P2 A , ) • If A X B > 0 • then P3 is to the left of the line formed by P1 and P2 • If A X B < 0 • then P3 is to the right of the line formed by P1 and P2 • If A X B = 0 • then P3 lies on the line formed by P1 and P2
Perpendicular distance from point to line P3 d P2 B A P1 d
Divide and Conquer • Same idea as the merge sort algorithm • Sort the points using the x values • Divide the points into smaller chunks that you can handle ( 3 or less points) • Then merge the individual sub convex hulls • O (n log n)
How do you merge? Given the two polygons below: • Find a point such that every other point in the polygon is below/above. • Special case for duplicates 2 • Remove all points in-between 1
Quick Hull • First pick the extreme points that are guaranteed to be part of the convex hull polygon • Then recursive pick the point with the farthest perpendicular distance from the produced line until there are no points to pick • O (n log n)
Gift Wrap or Jarvis's march • Pick the lowest point • Draw a vector with every other point and pick the point such that every other point lies above the vector • Make this point your next point and continue till you reach the start point • O ()
Applications of convex hull algorithms • Computer visualization, ray tracing • (e.g. video games, replacement of bounding boxes) • Path finding • (e.g. embedded AI of Mars mission rovers) • Geographical Information Systems (GIS) • (e.g. computing accessibility maps) • Visual pattern matching • (e.g. detecting car license plates) • Verification methods • (e.g. bounding of Number Decision Diagrams) • Geometry • (e.g. diameter computation)