advanced32 min studyLesson 922 in Mathematics

Convex hulls and output-sensitive bounds

Specify the hull output before comparing sorting, wrapping, and Chan’s algorithm.

On this page

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 hh. 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.

Tchain(n)=O(nlog⁡n),Twrap(n,h)=O(nh),TChan(n,h)=O ⁣(nlog⁡max⁡{2,h}).T_{\mathrm{chain}}(n)=O(n\log n),\qquad T_{\mathrm{wrap}}(n,h)=O(nh),\qquad T_{\mathrm{Chan}}(n,h)=O\!\left(n\log\max\{2,h\}\right).
The bounds concern planar hull vertices under the declared output and unit-predicate conventions.↔ Scroll wide equations horizontally.

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.

mt=min⁡{n,22t},∑j=0tlog⁡mj=O(log⁡mt).m_t=\min\{n,2^{2^t}\},\qquad \sum_{j=0}^{t}\log m_j=O(\log m_t).
Doubly exponential guesses keep total phase cost proportional to the final phase cost.↔ Scroll wide equations horizontally.

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.

Five extreme vertices among eight input points

Consider (0,0),(4,0),(5,2),(3,5),(0,4),(1,1),(2,2),(2,0)(0,0),(4,0),(5,2),(3,5),(0,4),(1,1),(2,2),(2,0). 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.

  1. The extreme boundary in counterclockwise order is A=(0,0)A=(0,0), B=(4,0)B=(4,0), C=(5,2)C=(5,2), D=(3,5)D=(3,5), E=(0,4)E=(0,4). Consecutive orientation values are 8,7,11,12,168,7,11,12,16, all positive.

  2. The points (1,1)(1,1) and (2,2)(2,2) lie inside the polygon. The point (2,0)(2,0) lies between AA and BB, so our strict-vertex convention omits it. Thus n=8n=8 and h=5h=5.

  3. The two shoelace sums are 4545 and 66, giving area (45−6)/2=39/2(45-6)/2=39/2. If all boundary input locations are required, insert (2,0)(2,0) between AA and BB, increasing that output count to six without changing area.

The result

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.

Explore the model

Interactive lab

Interactive lab · matrix

Transform a hull and track its area

Pause/Reset and set BOTH controls to a=1a=1, b=0b=0: the unit square has area 11. For a fresh comparison Pause/Reset and set BOTH to a=0.5a=0.5, b=1b=1. Predict transformed vertices (0,0),(0.5,0),(1.5,1),(1,1)(0,0),(0.5,0),(1.5,1),(1,1) and area 0.50.5. The readout describes the final matrix even while playback interpolates; control changes retain the paused clock.

Transform a hull and track its areaThe 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. Current readings: Area scale · det A: 1.4; Singular values · σmax, σmin: 1.597, 0.876; Condition number · κ₂(A): 1.823. All parameters are adjustable with the labeled controls below.Matrix A with first row 1.4, 0.6 and second row zero, one; display interpolates between identity and A while final determinant remains 1.4.−4−2024−2−1012x · equal geometric scaleyA = [ 1.4 0.6 ; 0 1 ]Display blend: 0% · final values below
Interpolated geometryOriginal unit squareSelected final transform
Area scale · det A
1.4
Singular values · σmax, σmin
1.597, 0.876
Condition number · κ₂(A)
1.823
t = 0 s

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.

Check your understanding

Under this lesson’s hull-output convention, what should gift wrapping do when several candidates lie on the same outward supporting ray?

Try it yourself

A data set contains (0,0),(1,0),(2,0),(3,0)(0,0),(1,0),(2,0),(3,0) and another copy of (0,0)(0,0). State the distinct extreme-vertex output and its value of hh. 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 (0,0)(0,0) to (3,0)(3,0), so the extreme-vertex representation has h=2h=2. 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.

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.