Convex Hull Algorithms

Jarvis march (gift wrapping) finds the convex hull in O(nh) time where h is hull size — optimal for small hulls. Graham scan runs in O(n log n) by first sorting by polar angle. Click to add points, then animate either algorithm.

Controls

Click canvas to add points, or generate random set.
Jarvis march:
O(nh), h=hull size
Wraps around CCW

Graham scan:
O(n log n)
Sort + stack

Cross product test:
(B-A)×(C-A) > 0
↔ left turn