JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q57862F
  • License ISC

gets the convex hull of 2D points using the "gift-wrapping" (AKA "Jarvis march") algorithm

Package Exports

  • @jrc03c/js-convex-hull

Readme

Introduction

js-convex-hull gets the convex hull of a set of 2D points using the "gift-wrapping" (AKA "Jarvis march") algorithm.

Installation

npm install --save @jrc03c/js-convex-hull

Usage

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!