⚠️ NOTE:⚠️ This project is being merged into a monorepo here. This repo will soon be archived.
js-convex-hull gets the convex hull of a set of 2D points using the "gift-wrapping" (AKA "Jarvis march") algorithm.
npm install --save @jrc03c/js-convex-hull
Add the script to your page:
<script src="path/to/js-convex-hull.js"></script>
Or require
it for use with bundlers:
const getConvexHull = require("@jrc03c/js-convex-hull")
Then call the getConvexHull
function (which returns the subset of points that represents the hull), passing in an array of 2D points:
let points = [
[0, 5],
[7, 2],
[-3, 8],
[4, -5],
...
]
let hull = getConvexHull(points)
Check out the demo to see it in action!