poly-to-pslg
Converts a polygon into a planar straight line graph.
Example
var poly2pslg = var polygon = -2 2 2 2 2 -2 -2-2 -1 1 1 1 1 -1 -1-1 var pslg = console
Output
points: -2 2 2 2 2 -2 -2 -2 -1 1 1 1 1 -1 -1 -1 edges: 0 1 1 2 2 3 3 0 4 5 5 6 6 7 7 4
Install
npm i poly-to-pslg
API
var graph = require('poly-to-pslg')(loops[, options])
Converts a polygon into a planar straight line graph.
loops
is an array of loops determining the vertices of the polygon. If only one loop is specified, this is inferred automatically.options
is an object storing some optional parametersoptions.clean
if this flag is set to true, then clean up the resulting graph usingclean-pslg
. (Defaulttrue
)options.nested
if this flag is set to true, then assume the polygon is an array of loops. Iffalse
, then suppose that the polygon is just one array.
Returns An object with two properties
points
are the vertex coordinate of the pslgedges
are the edges of the pslg
License
(c) 2015 Mikola Lysenko. MIT License