simplify-2d-complex
Simplifies a 2D simplicial complex by removing small or nearly flat corners.
Example
var simplify = //Create a circlevar points = var cells = forvar i=0; i<100; ++i var theta = i / 100 * MathPI * 20 points cells //Simplify itconsole
Output:
positions: 06845471059286886 07289686274214116 024868988716485496 09685831611286311 -06374239897486897 07705132427757893 -09297764858882513 036812455268467814 -09510565162951535 -030901699437494773 -07705132427757893 -06374239897486896 -02486898871648553 -0968583161128631 06374239897486893 -07705132427757896 09980267284282716 -006279051952931326 cells: 0 1 1 2 2 3 3 4 8 0 4 5 5 6 6 7 7 8
Install
npm install simplify-2d-complex
API
require("simplify-2d-complex")(cells, positions, minArea)
Simplies the 2D mesh to a fixed tolerance
cells
is a collection of edges in the 2D mesh represented as pairs of indices into the verticespositions
is a list of vertex coordinates encoded as an array of 2D arraysminArea
is the area of the smallest corner in the resulting polygonal region
Returns A simplicial complex with two properties:
positions
is an array of positions for the simplicial complexcells
is an array of edges encoding the cells of the mesh
Credits
(c) 2014 Mikola Lysenko. MIT License