We are given a set P of n points in the plane. We can define the convex hull of P, that is CH(P), as the largest convex polygonwhose vertices are all points in P, or the unique convex polygon that contains P and whose vertices are all points in P. There are two main properties of convex hulls:
One of these properties is that all of the points in the final polygon must be indented outwards, or more formally, convex. If any points are concave, there exists a better path by excluding that point, and drawing a direct line between its two neighbor points, which reduces the overall perimeter point count by one. This property is exploited by Graham's Scan, a pioneering algorithm for convex hulls covered later in the paper.
Another important property is that the most extreme point on any axis is part of the convex hull. This fact is apparent if you consider an example in which an extreme point is not in the convex hull. This would mean the perimeter of the convex hull passes through a point less extreme than that point. However, it is then obvious that the extreme point would not be included in the enclosed set, thus voiding a fundamental characteristic of convex hulls. This property is used by a number of algorithms because they rely on information computed from an initial point in the convex hull[1].
Computing a convex hull (or just "hull") is one of the first sophisticated geometry algorithms, and there are many variations of it. The most common form of this algorithm involves determining the smallest convex set (called the "convex hull") containing a discrete set of points.
The most popular algorithms are the "Graham scan" algorithm [Graham, 1972] and the "divide-and-conquer" algorithm [Preparata & Hong, 1977]. Implementations of both these algorithms are readily available (see [O'Rourke, 1998]). Both are O(n log n) time algorithms, but the Graham has a low runtime constant in 2D and runs very fast there. However, the Graham algorithm does not generalize to 3D and higher dimensions whereas the divide-and-conquer algorithm has a natural extension. We do not consider 3D algorithms here (see [O'Rourke, 1998] for more information)[2].
If the java applet could not run normally, please install SUN JRE 1.4 or higher version.
This is a simple O(n3) convex hull algorithm, which operates by considering each ordered pair of points (p, q),and then determining whether all the remaining points of the set lie within the half-plane lying to the right of thedirected line from p to q.
Back to home
The Graham's Algorithm first explicitly sorts the points in O(nlogn) and then applies a linear-time scanning algorithm to finish building the hull.
We start Graham's scan by finding the leftmost point l. We connect l with all the other points, then according to the angles in polar coordinates of the lines, we connect the points in couterclockwise order, starting and ending at l. Now we get a simple polygon with n vertices.
To change this polygon into convex hull, we apply the three-penny algorithm,the scanning phase takes O(n) time altogether. So the total time is O(nlogn)
Back to home
Jarvis's match algorithm is like wrapping a piece of string around thepoints. It starts by computing the leftmost point l, since we know that the left most point must be a convex hull vertex.This processwill take linear time.Then the algorithm does a series of pivoting steps to find each successive convex hull vertex untill the next vertex is the original leftmost point again.
The algorithm find the successive convex hull vertex like this: the vertex immediately following a point p is the point that appears to be furthest to the right to someone standing atp and looking at the other points. In other words, if q is the vertex following p, and r is any other input point, then thetriple p, q, r is in counter-clockwise order. We can find each successive vertex in linear time by performing a series of O(n) counter-clockwise tests.
Since the algorithm spends O(n) time for each convex hull vertex, the worst-case running time is O(n2). However, if the convex hull has very few vertices, Jarvis's march is extremelyfast. A better way to write the running time is O(nh), where h is the number of convex hull vertices. In the worst case, h = n, and we get our old O(n2) time bound, but in the best case h = 3, and the algorithm only needs O(n) time. This is a so called output-sensitive algorithm, the smaller the output, the faster the algorithm.
Back to home
This is another O(nlogn) time algorithm , which is based on the divide and conquer design technique. It can be viewed as a generalization of the MergeSort sorting algorithm. It begins by sorting the pointsby their x coordinate, in O(nlogn) time. The remainder of the algorithmis shown below.
Back to home
Like the divide-and-conquer algorithm can be viewed as a sort of generalization of MergeSort, the QuickHull algorithm can be thought of as a generalization of the QuickSort sorting procedure. Like QuickSort , this algorithm runs in O(nlogn) time for favorable inputs but can take as long as O(n2) time for unfavorable inputs.
The idea behind QuickHull is to discard points that are not on the hull as quickly as possible. QuickHull begins by computing the points with the maximum and minimum, x- and y- coordinate. Clearly thesepoints must be on the hull, and connect the four points we get a convex quadrilateral, all the points within this quadrilateral canbe eliminated from further consideration. All of this can be done in O(n) time.
Back to home
This is another output-sensitive algorithm, which was discoverd by Timothy Chan in 1993, the running time is O(nlogh). Chan's algorithm involves cleverly combining two slower algorithms, that is , Graham's scan and Jarvis's March,to form an algorithm that is faster than either one.
First suppose we know there are h points on the convex hull, this algorithm starts by shattering the input points in n/h arbitray subsets, each of size h, and computing the convex hull of each subset using (say) Graham's scan. This much of the algorithm requires O((n/h)hlogh) = O(nlogh) time.
Once we have the n/h subhulls, we follow the general outline of Javis'smarch, wrapping a string around the n/h subhulls. Start with the leftmost input point l, starting with p = l we successively find the convex hull vertexes in counter-clockwise order until we return back to the original leftmost point again.
The successor of p must lie on a right tangent line between p and one of the subhulls, a line from p through a vertex of the subhull, such that the subhull lies completely on the right side of the line from p's point of view. We can find the right tangent line between p and any subhull in O(logh) time using a variant of binary search. Since there are n/h subhulls, finding the successor of p takes O((n/h)logh) time together. Since there are h convex hull edges, and we find each edge in O((n/h)logh) time, the overall running time of the algorithm is O(nlogh).
Unfortunately, this algorithm only takes O(nlogh) time if we know the value of h in advance. So how do we know h's value? Chan's trick is to guess the correct value of h, let's denote the guess by h'.Then we shatter the points into n/h' subsets of size h', compute their subhulls, and then find the first h' edges of the globalhull. If h < h', this algorithm computes the complete convex hull in O(nlogh') time. Otherwise, the hull doesn't wrap all theway back around to l, so we know our guess h' is too small.
Chan's algorithm starts with the optimistic guess h' = 3. If we finish an iteration of the algorithm and find that h' is too small, we square h' and try again. In the final iteration, h'<h2, so the last iteration takes O(nlogh') = O (nlogh2) = O(nlogh) time.
The total running time of Chan's algorithm is given by the sum: O(nlog3 + nlog32 + nlog34 + ... + nlog32k) , for some integer k. We can rewrite this as a geometric series: O(nlog3 + 2nlog3 + 4nlog3 + ... + 2knlog3). So Chan's algorithm runs in O(nlogh) time overall, even we don't know the value of h.
In the figures, in order to keep things as clear as possible, the original author [6] have chosenthese subsets so that their convex hulls are disjoint. This is not true in general.
Back to home
The incremental convex hull algorithm are usually relatively simple to implement, and generalize well to higher dimensions. This algorithm operates by inserting points one at a time and incrementally updating the hull. If the new point is inside the hull there is nothing to do. Otherwise, we must delete all the edges that the new point can see.Than we connect the new point to its two neighbor points to update the hull. By repeating this process for the rest points outsidethe hull, finally, we get the convex hull for the points set
The randomized version of the algorithm operates as follows. Permute the points randomly,let P = (p0, p1,..., pn-1) be this sequence. Let H2 = CH(p0, p1, p2)(a triangle). For i running from 3 to n-1, insert pi into the existing hull Hi-1.
As with other randomized algorithms, the expected running time depends on the random order of insertion, but is independent of the point set. By a backwards analysis, we can know its running time is O(nlogn).
Back to home
Andrew's Monotone Chain Convex Hull algorithm is an algorithm which constructs convex hull of a set of 2D points in O(nlogn) time. It does this by first sorting the points lexicographically (first by x-coordinate, and in case of a tie, by y-coordinate), and then constructing upper and lower hulls of the points in O(n) time. An upper hull is the part of the convex hull, which is visible from the above. It runs from its rightmost point to the leftmost point in counterclockwise order. Lower hull is the remaining part of the convex hull.
Back to home
Algorithm | Running Time | Discovered By | ||
Brute Force | O(n3) | —— | ||
Graham Scan | O(nlog n) | Graham, 1972 | ||
Jarvis March | O(nh) | Jarvis, 1973 | ||
QuickHull | O(nh) | Eddy, 1977 ; Bykat, 1978 | ||
Divide-and-Conquer | O(nlog n) | Preparata & Hong, 1977 | ||
Monotone Chain | O(nlog n) | Andrew, 1979 | ||
Incremental | O(nlog n) | Kallay, 1984 | ||
Chan's algorithm | O(nlog h) | Timothy Chan, 1993 |
Back to home
Consider a set S of n on the plane. Compute the convex hull of S, and let S' be the set of points remaining in the interior of the hull. Then compute the convex hull of S' and recursively repeat this process until no more points remain. One ends up with a sequence of nested convex hulls, called the onion-peeling of S[4].
We have a simple algorithm to compute the onion-peeling of the point set S.
The sort process takes time O(nlogn). Each process of compute the convex hull takes time O(n), and in the worst case, each convex hull H computed is a triangle, in which case we need O(n) iterations. So, the total running time is O(n2). There is a sophiscatied and complicated algorithm that computes the onion in time O(nlogn) , thanks to Chazelle [3].
Note that the innermost structure can either be a line segment or a single point, besides a convex polygon. This graph gives information as to the layering of the points, i.e. how "deep" points are relative to each other other.
Back to home
The region between two nested convex hulls is called an annulus. Toussaint (1986) presents a simple algorithm for triangulating an annulus, using the Rotating Calipers. Using his method, once the onion peeling has been obtained, the entire set can be triangulated in linear time. Furthermore, the triangulation has two advantages: it keeps the onion-peeling as a subgraph, and it is hamiltonian, that is the dual of the triangulation graph is a chain.
The algorithm for triangulating an annulus is quite simple. The input is assumed to be a convex hull Q nested in an other hull P, both given in clockwise order.
The above algorithm has linear time complexity. When used to triangulate a set of points, a single convex hull is run (at most) twice through the procedure, once as the inner hull of the annulus, and once as the outer. Then the entire running time for triangulating a set of n points remains O(n)[4].
Back to home
A convex polygon P can be stored as an array of n vertices in sorted order along the boundary, a related question is about how can we test whether a query point q lies inside P?
Without loss of generality, let us assume that the points are in anticlockwise order (if not,we can simply access the elements of the array in reverse order). Let the points in the array be p1,p2, . . . ,pn. Let the first edge p1p2 be the reference edge; we will measure all angles with respect to this edge. We will use sector in the following way: take the diagonals from p1 to two adjacent vertices, extend them away from p1 into half-infinite lines, and the region between the two lines is a sector. Note that because P is convex, it is possible to draw lines to every other vertex from p1 without intersecting the exterior of P.
In general, what we seek to do is to perform a binary search for the sector that q lies in, and then test whether q lies in the triangle bounded by the edge opposite to p1 and the two rays defining the sector. The angle that a point s makes with the reference edge is which between the vectors p1p2 and p1s, denoted as the dot product[5]:
The preprocessing steps are all O(1) operations. The binary search takes O(nlogn); note that we only need to calculate the mapping from points to angles for the points that we compare against in the binary search to avoid the O(n) cost of converting all the points. The post-processing after we have found the value of θi is O(1). In total, the query of whether q lies in P is O(nlogn).
Back to home