Convex Hull

Views:
 
Category: Education
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Convex Hull:

Convex Hull 1 Given a set of pins on a pinboard And a rubber band around them How does the rubber band look when it snaps tight? We represent the convex hull as the sequence of points on the convex hull polygon, in counter-clockwise order. 0 2 1 3 4 6 5 By Ravikiran kalal

Defination:

Defination Informal definition: Convex hull of a set of points in plane is the shape taken by a rubber band stretched around the nails pounded into the plane at each point Convex hull of a set of points S is the set of all convex combinations of points of S Convex hull of S is denoted by conv S , sometimes the notation (S) is also used By Ravikiran kalal

Extreme Points :

Extreme Points The extreme points of a set S of points in the plane are the vertices of the convex hull at which the interior angle is less than π Also a point is extreme iff there exists a line through that point that other wise does not touch the convex hull By Ravikiran kalal

Extreme Edges:

Extreme Edges for each i do for each j ≠ i do for each k ≠ i ≠ j do if p k is not left or on ( p i , p j ) then ( p i , p j ) is not extreme There are three nested loops in this algorithm Hence the order is O(n 3 ) For each of the n 2 pair of points, the test for extremeness costs n The vertices that are extreme can now be found By Ravikiran kalal

Applications:

Applications Computer Visualization, Ray Tracing, Video Games. Geographical Information Systems (GIS) - Computing Accessibility Maps Visual Pattern Matching - Detecting Car License Plates Path Finding - Embedded AI of Mars mission Rovers Replacement of Bounding Boxes By Ravikiran kalal

Bounding box:

Bounding box By Ravikiran kalal

Convex Hull: Divide & Conquer:

Convex Hull: Divide & Conquer 7 Preprocessing: sort the points by x-coordinate Divide the set of points into two sets A and B : A contains the left  n/2  points, B contains the right  n/2  points Recursively compute the convex hull of A Recursively compute the convex hull of B Merge the two convex hulls A B By Ravikiran kalal

Merging in O(n) time:

Merging in O( n ) time 8 Find upper and lower tangents in O( n ) time Compute the convex hull of A B: walk counterclockwise around the convex hull of A, starting with left endpoint of lower tangent when hitting the left endpoint of the upper tangent , cross over to the convex hull of B walk counterclockwise around the convex hull of B when hitting right endpoint of the lower tangent we’re done This takes O( n ) time A B 1 2 3 4 5 6 7 By Ravikiran kalal

Finding the lower tangent in O(n) time :

Finding the lower tangent in O( n ) time 9 a = rightmost point of A b = leftmost point of B while T= ab not lower tangent to both convex hulls of A and B do{ while T not lower tangent to convex hull of A do{ a=a-1 } while T not lower tangent to convex hull of B do{ b=b+1 } } A B 0 a=2 1 5 3 4 0 1 2 3 4=b 5 6 7 By Ravikiran kalal

Convex Hull: Runtime:

Convex Hull: Runtime 10 Preprocessing: sort the points by x-coordinate Divide the set of points into two sets A and B : A contains the left  n/2  points, B contains the right  n/2  points Recursively compute the convex hull of A Recursively compute the convex hull of B Merge the two convex hulls O(n log n) just once O(1) T(n/2) T(n/2) O(n) By Ravikiran kalal

Convex Hull: Runtime:

Convex Hull: Runtime 11 Runtime Recurrence: T(n) = 2 T(n/2) + cn Solves to T(n) =  (n log n) By Ravikiran kalal

Quickhull:

Quickhull QuickHull uses a divide and conquer approach similar to the QuickSort algorithm . Benchmarks showed it is quite fast in most average cases. Recursive nature allows a fast and yet clean implementation. By Ravikiran kalal

Initial input:

Initial input The initial input to the algorithm is an arbitrary set of points. By Ravikiran kalal

First two points on the convex hull:

First two points on the convex hull Starting with the given set of points the first operation done is the calculation of the two maximal points on the horizontal axis. By Ravikiran kalal

Recursively divide:

Recursively divide Next the line formed by these two points is used to divide the set into two different parts . Everything left from this line is considered one part, everything right of it is considered another one. Both of these parts are processed recursively. By Ravikiran kalal

Max distance search:

Max distance search To determine the next point on the convex hull a search for the point with the greatest distance from the dividing line is done . This point, together with the line start and end point forms a triangle. By Ravikiran kalal

Point exclusion:

Point exclusion All points inside this triangle can not be part of the convex hull polygon, as they are obviously lying in the convex hull of the three selected points. Therefore these points can be ignored for every further processing step. By Ravikiran kalal

Recursively divide:

Recursively divide Having this in mind the recursive processing can take place again . Everything right of the triangle is used as one subset, everything left of it as another one. By Ravikiran kalal

Abort condition:

Abort condition At some point the recursively processed point subset does only contain the start and end point of the dividing line. If this is case this line has to be a segment of the searched hull polygon and the recursion can come to an end. By Ravikiran kalal

Running time:

Running time The running time of Quickhull , as with QuickSort , depends on how evenly the points are split at each stage. T(n ) = 1 if n = 1 T(n1) + T (n2) otherwise where n1+n2<=n If we assume that the points are ``evenly'' distributed, the running time will solve to O(n log n ). if the splits are not balanced, then the running time can easily increase to O(n^2). By Ravikiran kalal

Slide 21:

Think of wrapping a gift. Put the paper in contact with the gift and continue to wrap around from one surface to the next until you get all the way around. By Ravikiran kalal

Algorithm: Gift Wrapping:

Algorithm: Gift Wrapping Find the lowest point (smallest y coordinate) Let i 0 be its index, and set i ← i 0 repeat for each j ≠ i do compute counterclockwise angle θ from previous hull edge Let k be the index of the point with the smallest θ Output ( p i ,p k ) as a hull edge i ← k until i = i 0 We use the lowest point as the anchor The order is O(n 2 ) The cost is O(n) for each hull edge The point set is wrapped by a string that bends the that bends with minimum angle from previous to next hull edge By Ravikiran kalal

Jarvis March - Example:

Jarvis March - Example p 0 p 1 p 3 p 2 p 4 p 5 p 6 p 7 p 8 p 9 p 11 p 12 p 10 By Ravikiran kalal

Slide 24:

p 0 p 1 p 3 p 2 p 4 p 5 p 6 p 7 p 8 p 9 p 11 p 12 p 10 Jarvis March - Example By Ravikiran kalal

Slide 25:

p 0 p 1 p 3 p 2 p 4 p 5 p 6 p 7 p 8 p 9 p 11 p 12 p 10 Jarvis March - Example By Ravikiran kalal

Slide 26:

p 0 p 1 p 3 p 2 p 4 p 5 p 6 p 7 p 8 p 9 p 11 p 12 p 10 Jarvis March - Example By Ravikiran kalal

Slide 27:

p 0 p 1 p 3 p 2 p 4 p 5 p 6 p 7 p 8 p 9 p 11 p 12 p 10 Jarvis March - Example By Ravikiran kalal

Slide 28:

p 0 p 1 p 3 p 2 p 4 p 5 p 6 p 7 p 8 p 9 p 11 p 12 p 10 Jarvis March - Example By Ravikiran kalal

Slide 29:

p 0 p 1 p 3 p 2 p 4 p 5 p 6 p 7 p 8 p 9 p 11 p 12 p 10 Jarvis March - Example By Ravikiran kalal

Running time:

Running time we can find the point q in O(n) time . After repeating this h times, we will return back to the starting point and we are done . Thus, the overall running time is O( nh ). Worst case efficiency will be n 2 . By Ravikiran kalal

thanQ:

t hanQ By Ravikiran kalal