Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/incremental-delaunay
Constructs a Delaunay triangulation for a collection of points
https://github.com/mikolalysenko/incremental-delaunay
Last synced: about 2 months ago
JSON representation
Constructs a Delaunay triangulation for a collection of points
- Host: GitHub
- URL: https://github.com/mikolalysenko/incremental-delaunay
- Owner: mikolalysenko
- License: mit
- Created: 2013-10-25T22:00:19.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-05T15:42:08.000Z (over 10 years ago)
- Last Synced: 2024-10-20T14:27:57.433Z (2 months ago)
- Language: JavaScript
- Size: 207 KB
- Stars: 24
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
incremental-delaunay
====================
Incremental Delaunay triangulation data structure.**Warning** This module has problems in >3D. For those cases you should use [delaunay-triangulate](https://www.npmjs.org/package/delaunay-triangulate) instead.
# Example
```javascript
var createTriangulation = require("incremental-delaunay")//Create a 2D triangulation with some points
var triangulation = createTriangulation(2, [
[0,1],
[1,0],
[1,1]
])//Insert some random point
triangulation.insert([1, 2])//Get all points in the triangulation
console.log("points=", triangulation.points)//Get all cells in the triangulation
console.log("cells=", triangulation.cells)//Locate a triangle containing a point
console.log("located triangle=", triangulation.locate([0.5, 0.5]))
```Example output:
```javascript
points= [ [ -1e+30, -1e+30 ],
[ 1e+30, -1e+30 ],
[ 0, 1e+30 ],
[ 0, 1 ],
[ 1, 0 ],
[ 1, 1 ],
[ 1, 2 ] ]cells= [ [ 5, 6, 3 ],
[ 3, 6, 2 ],
[ 6, 1, 2 ],
[ 5, 1, 6 ],
[ 4, 5, 3 ],
[ 4, 1, 5 ],
[ 3, 0, 4 ],
[ 0, 1, 4 ],
[ 0, 3, 2 ] ]located triangle= [ 3, 0, 4 ]
```# API
```javascript
var createTriangulation = require("incremental-delaunay")
```## Constructor
#### `var triangulation = createTriangulation(dimension, points)`
Creates a triangulation* `dimension` is the dimension of the ambient space
* `points` is an array of points**Returns** A `DelaunayTriangulation` object
## Methods
#### `triangulation.cells`
An array of all cells in the triangulation#### `triangulation.points`
An array of all points in the triangulation#### `triangulation.insert(point)`
Adds `point` to the triangulation#### `triangulation.locate(point)`
Returns the simplex containing `point`# Credits
(c) 2013-2014 Mikola Lysenko. MIT License