https://github.com/rowanwins/triangulation-wk
A basic triangulation implementation based on work by Wijeweera & Kodituwakku
https://github.com/rowanwins/triangulation-wk
computational-geometry geometry polygon tesselation triangulation
Last synced: 7 months ago
JSON representation
A basic triangulation implementation based on work by Wijeweera & Kodituwakku
- Host: GitHub
- URL: https://github.com/rowanwins/triangulation-wk
- Owner: rowanwins
- Created: 2019-04-11T05:55:32.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-22T23:07:35.000Z (about 7 years ago)
- Last Synced: 2025-10-02T09:47:30.172Z (8 months ago)
- Topics: computational-geometry, geometry, polygon, tesselation, triangulation
- Language: JavaScript
- Homepage: https://rowanwins.github.io/triangulation-wk/debug/
- Size: 604 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Based on the paper [Accurate, simple and efficient triangulation of a polygon by ear removal with lowest memory consumption](https://www.researchgate.net/publication/311245887_Accurate_simple_and_efficient_triangulation_of_a_polygon_by_ear_removal_with_lowest_memory_consumption)
Limitations
- Doesn't yet work on polygons with holes
- Mutates the input data (currently - hoping to work around that)
### Usage
Install via `npm install triangulation-wk`
````
const triangulate = require('triangulation-wk')
const polygon = [ [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ], [ 1, 1 ] ] ];
const triangles = triangulate(polygon)
````
### Comparisons
````
triangulation-wk x 95.80 ops/sec ±10.71% (75 runs sampled)
mapbox/earcut x 960 ops/sec ±1.62% (87 runs sampled)
Fastest is mapbox/earcut
````