Chan's algorithm
{{Short description|Algorithm for finding the convex hull of a set of points in the plane}}
In computational geometry, Chan's algorithm,{{cite journal
| last1=Chan | first1=Timothy M.
| title=Optimal output-sensitive convex hull algorithms in two and three dimensions
| doi=10.1007/BF02712873 | doi-access=free
| journal=Discrete & Computational Geometry
| volume=16
| pages=361–368
| date=1996| issue=4
}} 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 (the convex hull). In the planar case, the algorithm combines an algorithm (Graham scan, 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{{cite book
| last1=Nielsen | first1=Frank
| chapter=Grouping and Querying: A Paradigm to Get Output-Sensitive Algorithms
| title=Discrete and Computational Geometry
| series=Lecture Notes in Computer Science
| volume=1763
| pages=250–257
| date=2000
| doi=10.1007/978-3-540-46515-7_21 | isbn=978-3-540-67181-7
| doi-access=free}} has been independently developed by Frank Nielsen in his Ph.D. thesis.
Frank Nielsen. "[http://hal.inria.fr/tel-00832414/ Adaptive Computational Geometry]".
Ph.D. thesis, INRIA, 1996.
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), 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 {{clarify|reason=Why to the right and not to the left?|date=March 2018}}, 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{{how|date=March 2018}}. 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 {{math|''m''}}=
If an arbitrary value is chosen for , it may happen that
At that moment,
The idea is to make multiple passes of the algorithm with increasing values of
== Squaring Strategy ==
One possible strategy is to square the value of
| last1=Chazelle | first1=Bernard | authorlink1=Bernard Chazelle
| last2=Matoušek | first2=Jiří | authorlink2=Jiří Matoušek (mathematician)
| title=Derandomizing an output-sensitive convex hull algorithm in three dimensions
| journal=Computational Geometry
| volume=5
| pages=27–32
| date=1995
| doi=10.1016/0925-7721(94)00018-Q | doi-access=free}} Starting from a value of 2, at iteration
:
with the logarithm taken in base
:
=In three dimensions=
=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,
:Input: Set
:Output: Set
:: (Pick a point of
:: (This operation takes
::
::(
:: so that to compute the second point,
:: (Note:
::(For more info, see the comments close to the corresponding part of the Chan's algorithm.)
::
:: (Note:
:: (These are the iterations needed to discover the value of
:: (
:: (More specifically, we want
:: and so that the time complexity of this Chan's algorithm is
:: (As explained above in this article, a strategy is used where at most
:: (Note: the final
:: (Nevertheless, this Chan's algorithm stops once
:: that is, even if
:: (For more info, see the Jarvis march part of this algorithm below, where
::for
::: (Set parameter
::: There are other schemes: for example, the "doubling scheme", where
::: If the "doubling scheme" is used, though, the resulting time complexity of this Chan's algorithm is
:::
::: (Initialize an empty list (or array) to store the points of the convex hull of
:::
:::
::: (Arbitrarily split set of points
:::
::: (Compute the convex hull of all
::: (It takes
::: If
:::for
:::: (Compute the convex hull of subset
:::: (
::::
::: (At this point, the convex hulls
::: (Now, use a modified version of the Jarvis march algorithm to compute the convex hull of
::: (Jarvis march performs in
::: (Given that Jarvis march is an output-sensitive algorithm, its running time depends on the size of the convex hull,
::: (In practice, it means that Jarvis march performs
::: At each of these iterations, it performs at most
::: (We want
::: (If the current
::: (In this modified version of Jarvis march, we perform an operation inside the innermost loop which takes
::: Hence, the total time complexity of this modified version is
:::
::: If
:::for
:::: (Note: here, a point in the convex hull of
:::: (In this inner for loop,
:::: (Each of these
:::: that is,
:::: (Note:
:::: (Note: at each iteration
:::: for
::::: (
::::: where
::::: (Angles do not need to be calculated directly: the orientation test can be used {{how|date=March 2018}}.)
::::: (
::::: (Note: at the iteration
::::: in this case, it is the point of
:::::
:::: (Choose the point
::::
:::: (Jarvis march terminates when the next selected point on the convext hull,
::::if
::::: (Return the convex hull of
::::: (Note: of course, no need to return
::::: return
::::else
:::::
::: (If after
::: (We need to start over with a higher value for
Implementation
Chan's paper contains several suggestions that may improve the practical performance of the algorithm, for example:
- When computing the convex hulls of the subsets, eliminate the points that are not in the convex hull from consideration in subsequent executions.
- The convex hulls of larger point sets can be obtained by merging previously calculated convex hulls, instead of recomputing from scratch.
- With the above idea, the dominant cost of algorithm lies in the pre-processing, i.e., the computation of the convex hulls of the groups. To reduce this cost, we may consider reusing hulls computed from the previous iteration and merging them as the group size is increased.
Extensions
Chan's paper contains some other problems whose known algorithms can be made optimal output sensitive using his technique, for example:
- Computing the lower envelope
L(S) of a setS ofn line segments, which is defined as the lower boundary of the unbounded trapezoid of formed by the intersections. - Hershberger{{cite journal
| last1=Hershberger | first1=John
| title=Finding the upper envelope of n line segments in O(n log n) time
| journal=Information Processing Letters
| volume=33
| issue=4
| pages=169–174
| date=1989
| doi=10.1016/0020-0190(89)90136-1}} gave an
- Constructing output sensitive algorithms for higher dimensional convex hulls. With the use of grouping points and using efficient data structures,
O(n\log h) complexity can be achieved provided h is of polynomial order inn .
See also
References
{{reflist}}