Apex › Storage & databases

Convex hull — the rubber band around your points

The smallest convex polygon enclosing a set of points — the shape a rubber band makes snapped around a bed of nails. Andrew's monotone chain sorts the points, then sweeps once for the lower hull and once for the upper, using the cross product (turn left / right / straight — no trig) to pop any point that would make a dent. O(n log n), and that's optimal. Click to add points and watch the hull re-form.

More in Storage & databases