A Convex Hull is the smallest convex polygon that encloses a given set of points. It is a fundamental concept in computational geometry with applications in collision detection, image processing, and pattern recognition. The algorithm visualized here is the Jarvis March or Gift Wrapping algorithm, which finds the convex hull by iteratively wrapping a'gift' around the set of points.
The Jarvis March algorithm starts by finding the leftmost point and then iteratively wrapping a 'gift' around the set of points. It uses the orientation of three points to determine if a point is inside or outside the hull. If a point is outside the hull, it is added to the hull and the next point is selected. This process continues until the hull is complete.
1) Find the point with the lowest Y-coordinate (anchor). 2) Sort remaining points by polar angle relative to the anchor. 3) Iterate through sorted points using a stack: push points and pop non-left turns (cross product ≤ 0) until all points are processed in O(n log n) time.
Graham's Scan is O(n log n) due to initial polar angle sorting. Jarvis March runs in O(n * h) time, where h is the number of vertices on the Convex Hull. When h is small (h < log n), Jarvis March is faster, but degrades to O(n²) if all points lie on the hull.
Used in collision detection (enclosing robot body shapes in minimal bounding convex hulls), GIS geographical boundary enclosing, pattern recognition, and image processing shape analysis.
Sign in to join the discussion
Hand-picked resources to deepen your understanding
© 2025 See Algorithms. Code licensed under MIT, content under CC BY-NC 4.0