Pseudocode for finding upper tangent and lower tangent is as follows: if the line is crossing the polygon C2 we move to clockwise next and to anti-clockwise next if the line is crossing the polygon C1. So this is the upper tangent for the given polygons.įor finding the lower tangent we need to move inversely through the polygons i.e. Now this line is crossing neither of the points. This line is crossing b so we move to line 5. This again crossing the polygon a so we move to line 4. Now the line is above the polygon C2, fine! But the line is crossing the polygon C1, so we move to the clockwise next point, labelled as 3 in the picture. The line joining them is labelled as L1.Īs this line passes through the polygon C2 (is not above polygon b) so we take the anti-clockwise next point on C2, the line is labelled 2. The rightmost point (say A) of left convex hull C1 and leftmost point (say B) of right convex hull C2. Tangents between two convex polygonsįor finding the upper tangent, we start by taking two points. The merging of these halves would result in the convex hull for the complete set of points. Now recursion comes into the picture, we divide the set of points until the number of points in the set is very small, say 5, and we can find the convex hull for these points by the brute force algorithm. How to find the convex hull for the left and right half S1 and S2? Then the red outline shows the final convex hull. Then the lower and upper tangents are named as T1 and T2 respectively, as shown in the figure. Let the left convex hull be C1 and the right convex hull be C2. This can be done by finding the upper and lower tangent to the right and left convex hulls C1 and C2. Then the problem now is to merge these two convex hulls C1 and C2 and determine the convex hull C for the complete set S. Suppose we know the convex hull of the left half points S1 is C1 and the right half points S2 is C2. Note that all points in S1 is left to all points in S2. Given S: the set of points for which we have to find the convex hull. These algorithms exploit the fact that solutions to smaller problems can be used to solve larger problems. Further, asserts that all instances have exactly the same structure as the original problem and can be solved independently from each other, and so can easily be distributed over a number of parallel processes or threads. The key idea is that is we have two convex hull then, they can be merged in linear time to get a convex hull of a larger set of points.ĭivide and conquer algorithms solve problems by dividing them into smaller instances, solving each instance recursively and merging the corresponding results to a complete solution. In this article, we have explored the divide and conquer approach towards finding the convex hull of a set of points.
0 Comments
Leave a Reply. |