convex hull
TRANSCRIPT
- 1.Convex Hull
1
4
5
3
6
2
1
0
- Given a set of pins on a pinboard
- 2. And a rubber band around them
3. How does the rubber band look when it snaps tight? 4. We
represent the convex hull as the sequence of points on the convex
hull polygon, in counter-clockwise order.By Ravikirankalal
5. 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 convS,
sometimes the notation
(S) isalso used
By Ravikirankalal
6. 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 Ravikirankalal
7. Extreme Edges
for each i do
for each j i do
for each k i j do
if pkis not left or on (pi ,pj)
then (pi ,pj)isnot extreme
There are three nested loops in this algorithm
Hence the order is O(n3)
For each of the n2 pair of points, the test for extremeness costs
n
The vertices that are extreme can now be found
By Ravikirankalal
8. 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 Ravikirankalal
9. Bounding box
By Ravikirankalal
10. 7
A
B
Convex Hull: Divide & Conquer
- Preprocessing: sort the points by x-coordinate
11. Divide the set of points into two sets A and B: 12. A
contains the left n/2 points, 13. B contains the right n/2 points
14. Recursively compute the convex hull of A 15. Recursively
compute the convex hull of B 16. Merge the two convex hullsBy
Ravikirankalal
17. Merging in O(n) time
8
- Find upper and lower tangents in O(n) time
18. Compute the convex hull ofAB: 19. walk counterclockwise
around the convex hull of A, starting with left endpoint of lower
tangent 20. when hitting the left endpoint of the upper tangent,
cross over to the convex hull of B 21. walk counterclockwise around
the convex hull of B 22. when hitting right endpoint of the lower
tangent were done 23. This takes O(n) time4
5
3
6
2
7
1
A
B
By Ravikirankalal
24. Finding the lower tangent in O(n) time
9
3
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 toconvex hull of A do{a=a-1}while T not
lower tangent to convex hull of B do{b=b+1 } }
4=b
4
2
3
5
5
a=2
6
1
7
1
0
0
A
B
By Ravikirankalal
25. Convex Hull: Runtime
10
O(n log n)just once
- Preprocessing: sort the points by x-coordinate
26. Divide the set of points into two sets A and B: 27. A
contains the left n/2 points, 28. B contains the right n/2 points
29. Recursively compute the convex hull of A 30. Recursively
compute the convex hull of B 31. Merge the two convex
hullsO(1)
T(n/2)
T(n/2)
O(n)
By Ravikirankalal
32. Convex Hull: Runtime
11
- RuntimeRecurrence:
T(n) = 2 T(n/2) + cn
- Solves to T(n) = (n log n)
By Ravikirankalal
33. 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 Ravikirankalal
34. Initial input
The initial input to the algorithm is an arbitrary set of
points.
By Ravikirankalal
35. 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 Ravikirankalal
36. 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 Ravikirankalal
37. 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 Ravikirankalal
38. 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 Ravikirankalal
39. 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 Ravikirankalal
40. 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 Ravikirankalal
41. 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 wheren1+n2