Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 916 Bytes

README.md

File metadata and controls

41 lines (30 loc) · 916 Bytes

cnvx

Calculates convex hull for the set of 2d points. This code was part of VivaGraph now I just extracted it here. Computation complexity is O(n lg n).

Build Status

usage

var getConvexHull = require('cnvx');
var points = [
// square:
  { x: 0, y: 0 },
  { x: 1, y: 0 },
  { x: 0, y: 1 },
  { x: 1, y: 1 },
// And points inside
  { x: 0.5, y: 0.5 }
// ...
];

var hull = (points);
console.log(hull); // prints square points (0,0), (0,1), (1,0), (1,1);

Note: Current implementation modifies underlying collection of points. If you need your original collection of points to remain intact - pass a copy to this method.

install

With npm do:

npm install cnvx

license

MIT