1.0.5 • Published 8 years ago

poly-overlap v1.0.5

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

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