Skip to content

anvaka/cnvx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Calculates convex hull for the set of 2d points

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published