# triangulate-contours

> triangulates a series of 2D contours

Latest version **1.0.2** (published 2015-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install triangulate-contours
pnpm add triangulate-contours
yarn add triangulate-contours
bun add triangulate-contours
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2015-10-01 |
| First published | 2014-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | triangulation, tris, tri, triangulate, triangulated, poly, polyline, mesh, polys, polygon, path, shape, 2d |

## Links

- npm: https://www.npmjs.com/package/triangulate-contours
- Repository: https://github.com/mattdesl/triangulate-contours
- Issues: https://github.com/mattdesl/triangulate-contours/issues
- npm.io page: https://npm.io/package/triangulate-contours

## Dependencies (2)

- [tess2](https://npm.io/package/tess2.md) ^1.0.0
- [xtend](https://npm.io/package/xtend.md) ^4.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2015-10-01
- 1.0.1 — 2014-11-05
- 1.0.0 — 2014-11-05

## README

# triangulate-contours

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Triangulates a series of contours using [Tess2.js](https://github.com/memononen/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. 

```js
var triangulate = require('triangulate-contours')

var contours = [
    [ [10,50], [55, 23], [15, 62], [23, 63], [63, 21], [11, -2] ],
    [ [50,50], [62,21], [24,52] ]
]

var results = triangulate(contours)

console.log(results)
/*
    { 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

[![NPM](https://nodei.co/npm/triangulate-contours.png)](https://nodei.co/npm/triangulate-contours/)

#### `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](https://github.com/mikolalysenko/simplicial-complex), i.e. a simple object: 

```js
{ 
    positions: [ [x,y], .. ], 
    cells: [ [a,b,c], .. ] 
}
```

## See Also

For more robust triangulation than Tess2, see the following:

- [triangulate-polyline](https://www.npmjs.com/package/triangulate-polyline)
- [cdt2d](https://www.npmjs.com/package/cdt2d)

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/triangulate-contours/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/triangulate-contours · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
