Chan's algorithm


In computational geometry, Chan's algorithm, named after Timothy M. Chan, is an optimal output-sensitive algorithm to compute the convex hull of a set of points, in 2- or 3-dimensional space.
The algorithm takes time, where is the number of vertices of the output. In the planar case, the algorithm combines an algorithm with Jarvis march, in order to obtain an optimal time. Chan's algorithm is notable because it is much simpler than the Kirkpatrick–Seidel algorithm, and it naturally extends to 3-dimensional space. This paradigm has been independently developed by Frank Nielsen in his Ph.D. thesis.

Algorithm

Overview

A single pass of the algorithm requires a parameter which is between 0 and . Ideally, but, the number of vertices in the output convex hull, is not known at the start. Multiple passes with increasing values of are done which then terminates when.
The algorithm starts by arbitrarily partitioning the set of points into subsets with at most points each; notice that.
For each subset, it computes the convex hull,, using an algorithm, where is the number of points in the subset. As there are subsets of points each, this phase takes time.
During the second phase, Jarvis's march is executed, making use of the precomputed convex hulls,. At each step in this Jarvis's march algorithm, we have a point in the convex hull, and need to find a point such that all other points of are to the right of the line, where the notation simply means that the next point, that is, is determined as a function of and. The convex hull of the set,, is known and contains at most points, which allows to compute in time by binary search. Hence, the computation of for all the subsets can be done in time. Then, we can determine using the same technique as normally used in Jarvis's march, but only considering the points instead of the whole set. For those points, one iteration of Jarvis's march is which is negligible compared to the computation for all subsets. Jarvis's march completes when the process has been repeated times, hence the second phase takes time, equivalent to time if is close to .
By running the two phases described above, the convex hull of points is computed in time.

Choosing the parameter m

If an arbitrary value is chosen for, it may happen that. In that case, after steps in the second phase, we interrupt the Jarvis's march as running it to the end would take too much time.
At that moment, a time will have been spent, and the convex hull will not have been calculated.
The idea is to make multiple passes of the algorithm with increasing values of ; each pass terminates in time. If increases too slowly between passes, the number of iterations may be large; on the other hand, if it rises too quickly, the first for which the algorithm terminates successfully may be much larger than, and produce a complexity.

Squaring Strategy

One possible strategy is to square the value of at each iteration, up to a maximum value of . Starting from a value of 2, at iteration, is chosen. In that case, iterations are made, given that the algorithm terminates once we have
with the logarithm taken in base, and the total running time of the algorithm is

In three dimensions

To generalize this construction for the 3-dimensional case, an algorithm to compute the 3-dimensional convex hull by Preparata and Hong should be used instead of Graham scan, and a 3-dimensional version of Jarvis's march needs to be used. The time complexity remains.

Pseudocode

In the following pseudocode, text between parentheses and in italic are comments. To fully understand the following pseudocode, it is recommended that the reader is already familiar with Graham scan and Jarvis march algorithms to compute the convex hull,, of a set of points,

Implementation

Chan's paper contains several suggestions that may improve the practical performance of the algorithm, for example:
Chan's paper contains some other problems whose known algorithms can be made optimal output sensitive using his technique, for example: