
In
computational geometry, Chan's algorithm,
named after
Timothy M. Chan, is an optimal
output-sensitive algorithm
In computer science, an output-sensitive algorithm is an algorithm whose running time depends on the size of the output, instead of, or in addition to, the size of the input. For certain problems where the output size varies widely, for example fro ...
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 (the convex hull). In the planar case, the algorithm combines an
algorithm (
Graham scan
Graham's scan is a method of finding the convex hull of a finite set of points in the plane with time complexity O(''n'' log ''n''). It is named after Ronald Graham, who published the original algorithm in 1972. The algorithm finds all vertices ...
, for example) 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
(number of points of our set
). 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
(see below on choosing parameter
).
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 (for example,
Graham scan
Graham's scan is a method of finding the convex hull of a finite set of points in the plane with time complexity O(''n'' log ''n''). It is named after Ronald Graham, who published the original algorithm in 1972. The algorithm finds all vertices ...
), 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 (mini) convex hulls,
. At each step in this Jarvis's march algorithm, we have a point
in the convex hull (at the beginning,
may be the point in
with the lowest y coordinate, which is guaranteed to be in the convex hull of
), 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 (listed in a clockwise or counter-clockwise order), which allows to compute
in
time by
binary search
In computer science, binary search, also known as half-interval search, logarithmic search, or binary chop, is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the m ...
. 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
(i.e. the points in the mini convex hulls) 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 (because, in the way Jarvis march works, after at most
iterations of its outermost loop, where
is the number of points in the convex hull of
, we must have found the convex hull), hence the second phase takes
time, equivalent to
time if
is close to
(see below the description of a strategy to choose
such that this is the case).
By running the two phases described above, the convex hull of
points is computed in
time.
Choosing the parameter
If an arbitrary value is chosen for
, it may happen that