← Lessons

quiz vs the machine

Platinum1780

Algorithms

Rotating Calipers

Spin two parallel supporting lines around a hull to find diameter, width, and more in one pass.

6 min read · advanced · beat Platinum to climb

A pair of jaws

Imagine two parallel lines pressed against opposite sides of a convex polygon, like the jaws of a caliper. Rotating them together while keeping contact lets you read off many geometric quantities cheaply.

The diameter problem

The classic use finds the diameter of a convex polygon, the largest distance between any two of its vertices. The farthest pair must be antipodal, touched by parallel supporting lines.

  • Start with calipers on an extreme pair.
  • Rotate to the next edge by advancing whichever side has the smaller turning angle.

One linear pass

As the calipers spin a full turn, each vertex is visited a bounded number of times, so the whole sweep is linear in the number of hull vertices, after the hull itself is computed.

A versatile tool

The same rotation answers several questions in one framework.

  • The minimum width of the polygon.
  • The smallest enclosing rectangle.
  • The maximum distance between two convex polygons.

Key idea

Rotating calipers presses two parallel lines on a convex hull and spins them once, visiting antipodal pairs in a single linear pass to extract the diameter, minimum width, and tightest bounding rectangle.

Check yourself

Answer to earn rating on the learn ladder.

1. What property holds for the farthest pair of points on a convex polygon?

2. How does the sweep choose which caliper side to advance?