poly-overlap
v1.0.5
Published
Utility to check if polygons overlap.
Downloads
2
Maintainers
Readme
poly-overlap
Geometry utiltiy for node.js and web.
Check if
- polygons overlap
- point inside polygon
- lines intersect
- polygon boundaries
Install
npm install poly-overlap
Usage
Polygons overlap
const p0 = [[0,0], [1,0], [1,1]];
const p1 = [[0.5,0.5], [1.5,0.5], [1.5,1.5]];
assert(pu.overlap(p0, p1)===true);
Line segments intersect
assert(pu.intersect(0,0, 1,1, 0,1, 1,0)===true);
Point inside polygon
const point = [1,1];
const poly = [[0,0], [2,0], [2,2], [0,2], [0,0]];
assert(pu.inside(point, poly)===true);
Tests
mocha
Sources
- http://math.stackexchange.com/questions/254569/concave-polygons-overlapping-test
- http://ptspts.blogspot.no/2010/06/how-to-determine-if-two-line-segments.html
- http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html