cnvx
v0.1.0
Published
Calculates convex hull for the set of 2d points
Downloads
57
Readme
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)
.
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