robust-point-in-polygon
Exactly determines if a point is contained in a 2D polygon.
Example
var classifyPoint = var polygon = 1 1 1 2 2 2 2 1 console
Output:
-1 0 1
Install
npm install robust-point-in-polygon
API
require("robust-point-in-polygon")(loop, point)
Tests if a point is contained in the interior of a simple polygon
loop
is an array of vertices for the polygonpoint
is a 2D point which is classified against the polygon
Returns An integer which determines the position of point
relative to polygon
. This has the following interpretation:
-1
ifpoint
is contained insideloop
0
ifpoint
is on the boundary ofloop
1
ifpoint
is outsideloop
Credits
(c) 2014 Mikola Lysenko. MIT License