Page Title
This visualization demonstrates the convex hull algorithm, which finds the smallest convex polygon that contains a set of randomly generated points. The process animates step by step: first locating the highest point, then identifying subsequent points by measuring the smallest angle from the previous line segment using dot products, and finally drawing the boundary polyline as the algorithm progresses. The visualization uses D3.js v3 with SVG elements, including circles for data points, a polyline for the boundary, and animated lines representing the sweep line and ray. Points turn red as they join the hull, while the sweep line rotates to test each candidate point against the current angle threshold.
AI-generated descriptionThis program demonstrates an algorithm for finding the smallest convex polygon containing a given set of points (Convex hull).
The algorithm works as follows
- Find the highest point A.
- Find the second point by searching for a point B such that AB makes the smallest angle with the positive x direction.
- Find the remaining points recursively by searcing for a point Z such that YZ makes the smallest angle with XY where X and Y are the last two points found (Y after X). Include the initial point A in the search. When the search ends in A, then the path is complete.
The dot product is used to find the angle between two vectors.