570 likes | 863 Views
[CS504 Presentation]. Planar Convex Hull. 2013 / 5 / 9 Group 4 Sungheon Park Jeongho Son. CS504 Presentation. Contents. Definition of convex hull Bruteforce algorithm Graham’s scan Divide and conquer Quickhull Jarvis’ method. CS504 Presentation. What is convex hull?.
E N D
[CS504 Presentation] Planar Convex Hull 2013 / 5 / 9 Group 4 Sungheon Park Jeongho Son CS504 Presentation
Contents • Definition of convex hull • Bruteforce algorithm • Graham’s scan • Divide and conquer • Quickhull • Jarvis’ method CS504 Presentation
What is convex hull? • Let S be a set of points in the plane. • Intuition: Imagine the points of S as being pegs; the convex hull of S is the shape of a rubber-band stretched around the pegs. CS504 Presentation
What is convex hull? • Formal definition: the convex hull of S is the smallest convex polygon that contains all the points of S • Convexity : A set is convex if given any points any convex combination of p and q is in , or equivalently, the line segment . CS504 Presentation
Applications of convex hull computer visualization, ray tracing path finding Geographical Information Systems (GIS) Visual pattern matching CS504 Presentation
Orientation test • Given a triplet of three points , in the plane, is defined as • >0 : oriented counterclockwise • =0 : collinear • <0 : oriented clockwise CS504 Presentation
Graham’s Scan • algorithm • Points are added one at a time, and structure is updated on each new insertion. CS504 Presentation
Graham’s Scan • Algorithm • Sort the points according to increasing order of their -coordinates, denoted . • Push and then onto stack . • for to do: while( and ) pop . Push onto CS504 Presentation
Graham’s Scan • Analysis • Sorting : • Let the number of points that are popped on processing , the amount of time spent processing is is bounded by since each of the points is pushed onto the stack once. Total time complexity is CS504 Presentation
Original Graham’s scan • Initially, points are sorted in increasing angular value • If the point is not convex (concave), it removes the current point from the perimeter list CS504 Presentation
Divide-and-Conquer • algorithm • Recursively compute convex hulls, and merge two hulls by computing upper and lower tangent CS504 Presentation
Divide-and-Conquer • Algorithm finding lower tangent LowerTangent(,) : (1) Let a be the rightmost point of . (2) Let b be the leftmost point of . (3) While (ab is not a lower tangent for and ) do (a) While (ab is not a lower tangent to ) move a clockwise (b) While (ab is not a lower tangent to ) move b counterclockwise (4) Return ab. • Can be done in where . • Overall algorithm runs time. CS504 Presentation
Quickhull • in worst case, but shows better performance in most cases • Discard points that are not on the hull as quickly as possible. • Begin with the quadrilateral which connects maximum and minimum x,y coordinates CS504 Presentation
Quickhull • Find a point that lies on the hull, and connect and • Eliminate the points inside hull, and recursively process for the remaining points. • Performance depends on the distribution of the points, and how a point is selected CS504 Presentation
Quickhull • Analysis • If for some , then the running time will be • Performance depends on the distribution of the points, and how a point is selected CS504 Presentation
Jarvis’s March • Build the hull using “gift wrapping” process CS504 Presentation
Jarvis’s March • Algorithm • Begins with and pick which is known to be on convex hull (e.g. the leftmost point) • Pick the point which minimize the angle between and .(Use polar coordinate system) • Repeat step 2 until . CS504 Presentation
Jarvis’s March • Analysis • Find the point that maximize angle in • Number of vertices on convex hull : • Total time complexity : ⇒ Output-sensitive algorithm CS504 Presentation
Applet • Java applet • http://www.cse.unsw.edu.au/~lambert/java/3d/hull.html • http://www.cs.princeton.edu/courses/archive/spr09/cos226/demo/ah/JarvisMarch.html CS504 Presentation
Chan’s algorithm Jeongho Son CS504 Presentation
Planar Convex Hull • Graham’s Scan : • Jarvis’s March : • Is there any algorithm? CS504 Presentation
Chan’s Algorithm • Chan’s algorithm • combining Graham’s scan and Jarvis’s March together • 3 stages of Chan’s algorithm • divide vertices into partitions • apply Graham’s scan on each partition • apply Jarvis’s March on the small convex hull (repeat 1~3 until we find the hull) CS504 Presentation
Chan’s Algorithm • Stage1 : Partition • Consider arbitrary value , the size of partition • how to decide will be treated later • Partition the points into groups, each of size • is the number of groups CS504 Presentation
Chan’s Algorithm • Stage 1 n = 32 Set m = 8 CS504 Presentation
Chan’s Algorithm • Stage 1 n = 32 Set m = 8 r = 4 CS504 Presentation
Chan’s Algorithm • Stage2 : Graham’s Scan • Compute convex hull of each partition using Graham’s scan • Total time CS504 Presentation
Chan’s Algorithm • Stage 2 (After Stage 1) m = 8 r = 4 CS504 Presentation
Chan’s Algorithm • Stage 2 Using Graham’s Scan for each group -> total = CS504 Presentation
Chan’s Algorithm • Stage3 : Jarvis’s March • How to merge these r hulls into a single hull? • IDEA : treat each hull as a “fat point” and run Jarvis’s March! • # of iteration is at most m • to guarantee the time complexity O(nlogh) CS504 Presentation
Chan’s Algorithm • (-inf,0) -> lowest pt lowest pt CS504 Presentation
Chan’s Algorithm • Find the point that maximize the angle in each hull 1 lowest pt CS504 Presentation
Chan’s Algorithm • Find the point that maximize the angle in each hull 2 1 lowest pt CS504 Presentation
Chan’s Algorithm • Find the point that maximize the angle in each hull 3 2 1 lowest pt CS504 Presentation
Chan’s Algorithm If , then the algorithm will fail! CS504 Presentation
Chan’s Algorithm • FAIL EXAMPLE – too small value m m = 4 4 iteration CS504 Presentation
Chan’s Algorithm In 4(a), how to find such points? CS504 Presentation
Chan’s Algorithm • Find the point that maximize the angle in each hull 1 lowest pt CS504 Presentation
Chan’s Algorithm • Find the point that maximize the angle in a hull CS504 Presentation
Chan’s Algorithm • Finding tangent between a point and a convex -gon 5 1 process 4 3 2 CS504 Presentation
Chan’s Algorithm CS504 Presentation
Chan’s Algorithm Analysis • Suppose God told you some good value for • for stage1~2 • At most h steps in Jarvis’s March • time to compute each tangent • tangent for each iteration • total time • as desired. CS504 Presentation
Chan’s Algorithm • The only question remaining is… how do we know what value to give to ? CS504 Presentation
Chan’s Algorithm • Answer : square search • Try this way - • Then we eventually get to be in ! CS504 Presentation
Chan’s Algorithm • The algorithm stops as soon as • Total time complexity CS504 Presentation
Lower bound for convex hull • Reduction from the sorting problem n points in the x-axis CS504 Presentation
Lower bound for convex hull • Reduction from the sorting problem lifting up to 2D plane CS504 Presentation
Lower bound for convex hull • Reduction from the sorting problem lower convex hull CS504 Presentation
Quiz • Show that the convex hull of n points in the plane can be computed in time if each coordinate of each point is a rational number of the form , with bounded values for and . • hint: don’t use comparison-based sort! CS504 Presentation
Quiz • Solution Instead of comparison-based sort, using radix sort And apply Graham’s scan algorithm. CS504 Presentation
Summary • Finding the convex hull of a set of points is an important problem that is often part of a larger problem • Many different algorithms • Graham’s Scan • Quickhull • Divide-and-Conquer • Jarvis’s March • Chan’s algorithm CS504 Presentation