Convex hulls and output-sensitive bounds
Specify the hull output before comparing sorting, wrapping, and Chan’s algorithm.
On this page
The question for today
What you’ll understand
- Use an orientation invariant to build the planar hull boundary.
- Distinguish extreme vertices from every input point on the boundary.
- Explain why Chan’s guessing scheme achieves an output-sensitive bound.
The convex hull is a geometric set, but an algorithm must return a finite representation. We return the distinct extreme vertices in counterclockwise cyclic order, omit points strictly inside a hull edge, and write their number as . For a nonempty collinear input the representation contains its two endpoints, or one point if all locations coincide. These conventions affect output size and tie handling. Throughout the complexity discussion, coordinate comparisons and robust orientation tests have unit cost; bit-complexity costs are a separate arithmetic question.
The turn invariant discards a point safely
After sorting distinct points lexicographically, the monotone-chain algorithm constructs lower and upper boundaries. While appending a point, it removes the current last point whenever the new triple fails the required strict counterclockwise turn on the lower chain. Removing collinear intermediate points implements our extreme-vertex convention. The maintained chain stays convex, and each removed point lies on or above the candidate lower boundary rather than becoming a missing extreme point. The upper chain uses the corresponding reversed traversal.
Every point is pushed once and popped at most once on each chain, so the scan after sorting is linear. Sorting dominates at the usual logarithmic factor. Retaining every collinear boundary input changes the zero-orientation policy and requires special care on an entirely collinear input to avoid duplicated traversal. Deduplication is likewise part of the specification: repeated identifiers at one position do not create extra geometric vertices. The output order, rather than an unordered set of locations, is what makes subsequent polygon operations straightforward.
Guessing output size without paying for every guess
Gift wrapping chooses the next supporting vertex by scanning all input points, so a small number of hull vertices can make it attractive. Chan's method instead partitions the input into groups of at most a guessed size, builds each small hull, and uses tangent queries to choose the next wrapped vertex. It stops a phase after the guessed number of wrapping steps. If the hull closes, the phase succeeds; otherwise a larger guess is required. Collinear tangent ties choose the farther extreme point consistently.
Building the small hulls costs the input size times the logarithm of the guess. The bounded wrapping phase has the same asymptotic cost because tangent queries on the small convex polygons are logarithmic. Doubly exponential guesses make the logarithms grow geometrically, so failed phases do not accumulate an extra logarithmic factor. The successful guess is large enough to cover the actual output size. Ordinary exponential guesses would require a different summation and do not yield this particular simple accounting argument.
Output sensitivity is not free sorting
When every input point is extreme, the output-sensitive bound becomes the usual sorting-scale bound. Points on a suitable strictly convex curve can encode a sorting problem through their hull order, explaining the familiar worst-case lower bound in a comparison or algebraic decision-tree setting. Conversely, a huge collection of interior points with a tiny hull can benefit from output sensitivity. These statements depend on the computational model; bounded integer grids or special preordered inputs may permit different algorithmic tradeoffs.
The hull also behaves predictably under an invertible affine transformation: taking the hull and transforming commute, and extreme vertices remain extreme. Area scales by the absolute determinant, although Euclidean lengths and angles generally change. This gives a useful test of geometry without claiming that an affine map preserves every later structure, such as a Euclidean Delaunay triangulation. Hull construction, nearest-neighbor geometry, and geometric measurement each have their own invariant quantities.
Work it through
Five extreme vertices among eight input points
Consider . Find the counterclockwise extreme-vertex hull, its output size, and its area. Explain what changes if every input point on the boundary must be returned.
The extreme boundary in counterclockwise order is , , , , . Consecutive orientation values are , all positive.
The points and lie inside the polygon. The point lies between and , so our strict-vertex convention omits it. Thus and .
The two shoelace sums are and , giving area . If all boundary input locations are required, insert between and , increasing that output count to six without changing area.
The geometric hull is unchanged by the output convention, but its reported list length is not. Complexity statements involving output size must identify which list they count.
The living notebook
Explore the model
Interactive lab · matrix
Transform a hull and track its area
Pause/Reset and set BOTH controls to , : the unit square has area . For a fresh comparison Pause/Reset and set BOTH to , . Predict transformed vertices and area . The readout describes the final matrix even while playback interpolates; control changes retain the paused clock.
- Area scale · det A
- 1.4
- Singular values · σmax, σmin
- 1.597, 0.876
- Condition number · κ₂(A)
- 1.823
The selected matrix is A = [[a,b],[0,1]]. Playback interpolates geometry between the identity and A; readouts always describe A. Its determinant is a and its singular values come from AᵀA. Positive a makes every supported matrix invertible. This two-dimensional family is not a general eigensolver or a learned network. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forThe invertible map preserves the four extreme vertices and scales area by its determinant. It illustrates an affine invariant, rather than implementing a hull algorithm.
Pause & reason
Check your understanding
Your turn
Try it yourself
A data set contains and another copy of . State the distinct extreme-vertex output and its value of . Contrast an output that lists every distinct boundary input point, and explain the zero-turn decision.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Deduplicate geometric locations first, then distinguish a line segment’s extreme points from its other boundary locations.
Compare with the solution
The geometric hull is the segment from to , so the extreme-vertex representation has . An all-boundary-location output lists four distinct points, rather than five input records. On a zero orientation, the strict-vertex monotone chain removes an intermediate point; gift wrapping keeps the farther endpoint. A polygon traversal for collinear data needs an explicit special case to avoid reporting the same chain in both directions.
Keep the idea
Take it with you
- Declare whether output size counts extreme vertices or all boundary records.
- A convex-chain invariant turns repeated local orientation tests into a global hull.
- Chan’s doubly exponential phases produce output sensitivity without a repeated-phase logarithm.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.