Convex hull algorithms
Algorithms that construct convex hulls of various objects have a broad range of applications in mathematics and computer science.
In computational geometry, numerous algorithms are proposed for computing the convex hull of a finite set of points, with various computational complexities.
Computing the convex hull means that a non-ambiguous and efficient representation of the required convex shape is constructed. The complexity of the corresponding algorithms is usually estimated in terms of n, the number of input points, and sometimes also in terms of h, the number of points on the convex hull.
Planar case
Consider the general case when the input to the algorithm is a finite unordered set of points on a Cartesian plane. An important special case, in which the points are given in the order of traversal of a simple polygon's boundary, is described later in a separate subsection.If not all points are on the same line, then their convex hull is a convex polygon whose vertices are some of the points in the input set. Its most common representation is the list of its vertices ordered along its boundary clockwise or counterclockwise. In some applications it is convenient to represent a convex polygon as an intersection of a set of half-planes.
Lower bound on computational complexity
For a finite set of points in the plane the lower bound on the computational complexity of finding the convex hull represented as a convex polygon is easily shown to be the same as for sorting using the following reduction. For the set numbers to sort consider the set of points of points in the plane. Since they lie on a parabola, which is a convex curve it is easy to see that the vertices of the convex hull, when traversed along the boundary, produce the sorted order of the numbers. Clearly, linear time is required for the described transformation of numbers into points and then extracting their sorted order. Therefore, in the general case the convex hull of n points cannot be computed more quickly than sorting.The standard Ω lower bound for sorting is proven in the decision tree model of computing, in which only numerical comparisons but not arithmetic operations can be performed; however, in this model, convex hulls cannot be computed at all. Sorting also requires Ω time in the algebraic decision tree model of computation, a model that is more suitable for convex hulls, and in this model convex hulls also require Ω time. However, in models of computer arithmetic that allow numbers to be sorted more quickly than O time, for instance by using integer sorting algorithms, planar convex hulls can also be computed more quickly: the Graham scan algorithm for convex hulls consists of a single sorting step followed by a linear amount of additional work.
Optimal output-sensitive algorithms
As stated above, the complexity of finding a convex hull as a function of the input size n is lower bounded by Ω. However, the complexity of some convex hull algorithms can be characterized in terms of both input size n and the output size h. Such algorithms are called output-sensitive algorithms. They may be asymptotically more efficient than Θ algorithms in cases when h = o.The lower bound on worst-case running time of output-sensitive convex hull algorithms was established to be Ω in the planar case. There are several algorithms which attain this optimal time complexity. The earliest one was introduced by Kirkpatrick and Seidel in 1986. A much simpler algorithm was developed by Chan in 1996, and is called Chan's algorithm.
Algorithms
Known convex hull algorithms are listed below, ordered by the date of first publication. Time complexity of each algorithm is stated in terms of the number of inputs points n and the number of points on the hull h. Note that in the worst case h may be as large as n.- Gift wrapping, a.k.a. Jarvis march — O
One of the simplest planar algorithms. Created independently by Chand & Kapur in 1970 and R. A. Jarvis in 1973. It has O time complexity, where n is the number of points in the set, and h is the number of points in the hull. In the worst case the complexity is Θ. - Graham scan — O
A slightly more sophisticated, but much more efficient algorithm, published by Ronald Graham in 1972. If the points are already sorted by one of the coordinates or by the angle to a fixed vector, then the algorithm takes O time. - Quickhull
Created independently in 1977 by W. Eddy and in 1978 by A. Bykat. Just like the quicksort algorithm, it has the expected time complexity of O, but may degenerate to O in the worst case. - Divide and conquer — O
Another O algorithm, published in 1977 by Preparata and Hong. This algorithm is also applicable to the three dimensional case. - , a.k.a. Andrew's algorithm— O
Published in 1979 by A. M. Andrew. The algorithm can be seen as a variant of Graham scan which sorts the points lexicographically by their coordinates. When the input is already sorted, the algorithm takes O time. - Incremental convex hull algorithm — O
Published in 1984 by Michael Kallay. - Kirkpatrick–Seidel algorithm — O
The first optimal output-sensitive algorithm. It modifies the divide and conquer algorithm by using the technique of marriage-before-conquest and low-dimensional linear programming. Published by Kirkpatrick and Seidel in 1986. - Chan's algorithm — O
A simpler optimal output-sensitive algorithm created by Chan in 1996. It combines gift wrapping with the execution of an O algorithm on small subsets of the input.Akl–Toussaint heuristic
On-line and dynamic convex hull problems
The discussion above considers the case when all input points are known in advance. One may consider two other settings.- Online convex hull problem: Input points are obtained sequentially one by one. After each point arrives on input, the convex hull for the pointset obtained so far must be efficiently computed.
- Dynamic convex hull maintenance: The input points may be sequentially inserted or deleted, and the convex hull must be updated after each insert/delete operation.
The online version may be handled with O per point, which is asymptotically optimal. The dynamic version may be handled with O per operation.
Simple polygon
The convex hull of a simple polygon is divided by the polygon into pieces, one of which is the polygon itself and the rest are pockets bounded by a piece of the polygon boundary and a single hull edge. Although many algorithms have been published for the problem of constructing the convex hull of a simple polygon, a majority of them have been incorrect.McCallum and Avis provided the first correct algorithm.
A later simplification by and uses only a single stack data structure. Their algorithm traverses the polygon clockwise, starting from its leftmost vertex. As it does, it stores a convex sequence of vertices on the stack, the ones that have not yet been identified as being within pockets. At each step, the algorithm follows a path along the polygon from the stack top to the next vertex that is not in one of the two pockets adjacent to the stack top. Then, while the top two vertices on the stack together with this new vertex are not in convex position, it pops the stack, before finally pushing the new vertex onto the stack. When the clockwise traversal reaches the starting point, the algorithm returns the sequence of stack vertices as the hull.
Higher dimensions
A number of algorithms are known for the three-dimensional case, as well as for arbitrary dimensions. Chan's algorithm is used for dimensions 2 and 3, and Quickhull is used for computation of the convex hull in higher dimensions.For a finite set of points, the convex hull is a convex polyhedron in three dimensions, or in general a convex polytope for any number of dimensions, whose vertices are some of the points in the input set. Its representation is not so simple as in the planar case, however. In higher dimensions, even if the vertices of a convex polytope are known, construction of its faces is a non-trivial task, as is the dual problem of constructing the vertices given the faces. The size of the output face information may be exponentially larger than the size of the input vertices, and even in cases where the input and output are both of comparable size the known algorithms for high-dimensional convex hulls are not output-sensitive due both to issues with degenerate inputs and with intermediate results of high complexity.