triangulate-contours
Triangulates a series of contours using Tess2.js. Returns a simplicial complex with { positions, cells }
. Works with 2D and 3D coordinates, and contours can be in reverse winding order for holes.
var triangulate = var contours = 1050 55 23 15 62 23 63 63 21 11 -2 5050 6221 2452 var results = console/* { positions: [ ... ], cells: [ ... ] } */
positions
are a series of points with the same number of components as the input, and cells
is a list of faces with indices into the positions array.
Usage
triangulate(contours[, opts])
Triangulates an array of polylines, each polyline representing a contour. The options will be pushed into Tess2
constructor; but if no vertexSize
is specified, it will be guessed based on the input array (i.e. 2-dimensional vs. 3-dimensional vectors).
Returns a simplicial complex, i.e. a simple object:
positions: xy cells: abc
See Also
For more robust triangulation than Tess2, see the following:
License
MIT, see LICENSE.md for details.