{"name":"delaunator","version":"5.1.0","description":"An incredibly fast JavaScript library for Delaunay triangulation of 2D points","main":"index.js","module":"index.js","type":"module","types":"index.d.ts","jsdelivr":"delaunator.min.js","unpkg":"delaunator.min.js","sideEffects":false,"dependencies":{"robust-predicates":"^3.0.2"},"devDependencies":{"@rollup/plugin-node-resolve":"^16.0.3","@rollup/plugin-terser":"^1.0.0","eslint":"^10.1.0","eslint-config-mourner":"^4.1.0","rollup":"^4.59.1","typescript":"^5.9.3"},"repository":{"type":"git","url":"git+https://github.com/mapbox/delaunator.git"},"scripts":{"lint":"eslint index.js test/test.js bench.js rollup.config.js docs/diagrams.js","pretest":"npm run lint","test":"tsc && node test/test.js","cov":"node --experimental-test-coverage test/test.js","bench":"node bench.js","build":"rollup -c","start":"rollup -cw","prepublishOnly":"npm test && npm run build"},"keywords":["delaunay triangulation","computational geometry","algorithms"],"author":{"name":"Vladimir Agafonkin"},"license":"ISC","gitHead":"3ce65210ba78a8f02ec6e73cf202838d7df14051","_id":"delaunator@5.1.0","bugs":{"url":"https://github.com/mapbox/delaunator/issues"},"homepage":"https://github.com/mapbox/delaunator#readme","_nodeVersion":"24.14.0","_npmVersion":"11.11.0","dist":{"integrity":"sha512-AGrQ4QSgssa1NGmWmLPqN5NY2KajF5MqxetNEO+o0n3ZwZZeTmt7bBnvzHWrmkZFxGgr4HdyFgelzgi06otLuQ==","shasum":"d13271fbf3aff6753f9ea6e235557f20901046ea","tarball":"http://registry-npm.ywwl.com/delaunator/download/delaunator-5.1.0.tgz","fileCount":7,"unpackedSize":66939,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDYrWwMkrmuU/xyKhC0hO80s/CeH737kXH02MBHRx/G+AiBdIlHAnYhDejrqlIfcCCOTjGfHISpME17dayOPewQ+YQ=="}],"size":13548,"noattachment":false,"key":"/delaunator/-/delaunator-5.1.0.tgz"},"_npmUser":{"name":"mourner","email":"agafonkin@gmail.com"},"directories":{},"maintainers":[{"name":"mapbox-npm-01","email":"accounts+npmjs-01@mapbox.com"},{"name":"mapbox-npm-02","email":"accounts+npmjs-02@mapbox.com"},{"name":"mapbox-npm-07","email":"accounts+npmjs-07@mapbox.com"},{"name":"mapbox-npm-03","email":"accounts+npmjs-03@mapbox.com"},{"name":"mapbox-npm-04","email":"accounts+npmjs-04@mapbox.com"},{"name":"mapbox-npm-09","email":"accounts+npmjs-09@mapbox.com"},{"name":"mapbox-npm-05","email":"accounts+npmjs-05@mapbox.com"},{"name":"mapbox-npm-06","email":"accounts+npmjs-06@mapbox.com"},{"name":"mapbox-npm-08","email":"accounts+npmjs-08@mapbox.com"},{"name":"mapbox-npm-advanced-actions","email":"accounts+npmjs-advanced-actions@mapbox.com"},{"name":"mapbox-npm-ci","email":"accounts+npmjs-npm-ci@mapbox.com"},{"name":"mapbox-npm","email":"accounts+npmjs@mapbox.com"},{"name":"mapbox-admin","email":"accounts@mapbox.com"},{"name":"mapbox-machine-user","email":"accounts+npm-mapbox-machine-user@mapbox.com"},{"name":"mbx-npm-ci-staging","email":"yannick.meeus+npm+staging+ci@mapbox.com"},{"name":"mbx-npm-ci-production","email":"yannick.meeus+npm+production+ci@mapbox.com"},{"name":"mbx-npm-01-production","email":"yannick.meeus+npm+prod+01@mapbox.com"},{"name":"mbx-npm-02-production","email":"yannick.meeus+npm+prod+02@mapbox.com"},{"name":"mbx-npm-03-production","email":"yannick.meeus+npm+prod+03@mapbox.com"},{"name":"mbx-npm-04-production","email":"yannick.meeus+npm+prod+04@mapbox.com"},{"name":"mbx-npm-05-production","email":"yannick.meeus+npm+prod+05@mapbox.com"},{"name":"mbx-npm-06-production","email":"yannick.meeus+npm+prod+06@mapbox.com"},{"name":"mbx-npm-07-production","email":"yannick.meeus+npm+prod+07@mapbox.com"},{"name":"mbx-npm-08-production","email":"yannick.meeus+npm+prod+08@mapbox.com"},{"name":"mbx-npm-09-production","email":"yannick.meeus+npm+prod+09@mapbox.com"},{"name":"mbx-npm-02-staging","email":"yannick.meeus@mapbox.com"},{"name":"mbx-npm-advanced-actions-staging","email":"yannick.meeus+npm+staging+advanced+actions@mapbox.com"},{"name":"mbx-npm-advanced-actions-production","email":"yannick.meeus+npm+prod+advanced+actions@mapbox.com"},{"name":"mourner","email":"agafonkin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/delaunator_5.1.0_1774259603677_0.04488503791534493"},"_hasShrinkwrap":false,"readme":"# Delaunator [![CI](https://github.com/mapbox/delaunator/actions/workflows/node.yml/badge.svg)](https://github.com/mapbox/delaunator/actions/workflows/node.yml) [![](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects) [![](https://badgen.net/bundlephobia/minzip/delaunator)](https://unpkg.com/delaunator)\n\nAn incredibly fast and robust JavaScript library for\n[Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation) of 2D points.\n\n- [Interactive Demo](https://mapbox.github.io/delaunator/demo.html)\n- [Guide to data structures](https://mapbox.github.io/delaunator/)\n\n<img src=\"delaunator.png\" alt=\"Delaunay triangulation example\" width=\"600\" />\n\n### Projects based on Delaunator\n\n- [d3-delaunay](https://github.com/d3/d3-delaunay) for Voronoi diagrams, search, traversal and rendering (a part of [D3](https://d3js.org)).\n- [d3-geo-voronoi](https://github.com/Fil/d3-geo-voronoi) for Delaunay triangulations and Voronoi diagrams on a sphere (e.g. for geographic locations).\n\n## Example\n\n```js\nconst coords = [377,479,  453,434,  326,387,  444,359,  511,389,\n                586,429,  470,315,  622,493,  627,367,  570,314];\nconst delaunay = new Delaunator(coords);\nconsole.log(delaunay.triangles);\n// [4,3,1,  4,6,3,  1,5,4,  4,9,6,  2,0,1,  1,7,5,\n//  5,9,4,  6,2,3,  3,2,1,  5,8,9,  0,7,1,  5,7,8]\n```\n\n<img src=\"docs/example.png\" alt=\"Delaunay triangulation example with labeled points\" width=\"600\" />\n\n## Install\n\nInstall with NPM (`npm install delaunator`) or Yarn (`yarn add delaunator`), then import as an ES module:\n\n```js\nimport Delaunator from 'delaunator';\n```\n\nTo use as a module in a browser:\n\n```html\n<script type=\"module\">\n    import Delaunator from 'https://cdn.skypack.dev/delaunator@5.0.0';\n</script>\n```\n\nOr use a browser UMD build that exposes a `Delaunator` global variable:\n\n```html\n<script src=\"https://unpkg.com/delaunator@5.0.0/delaunator.min.js\"></script>\n```\n\n## API Reference\n\n#### new Delaunator(coords)\n\nConstructs a delaunay triangulation object given an array of point coordinates of the form:\n`[x0, y0, x1, y1, ...]` (use a typed array for best performance).\n\n#### Delaunator.from(points[, getX, getY])\n\nConstructs a delaunay triangulation object given an array of points (`[x, y]` by default).\n`getX` and `getY` are optional functions of the form `(point) => value` for custom point formats.\nDuplicate points are skipped.\n\n#### delaunay.triangles\n\nA `Uint32Array` array of triangle vertex indices (each group of three numbers forms a triangle).\nAll triangles are directed counterclockwise.\n\nTo get the coordinates of all triangles when using `Delaunator.from(points)`, use:\n\n```js\nfor (let i = 0; i < triangles.length; i += 3) {\n    coordinates.push([\n        points[triangles[i]],\n        points[triangles[i + 1]],\n        points[triangles[i + 2]]\n    ]);\n}\n```\n\nTo get the coordinates of all triangles when using `new Delaunator(coords)`, use:\n\n```js\nfor (let i = 0; i < triangles.length; i += 3) {\n    coordinates.push([\n        [coords[2 * triangles[i]],     coords[2 * triangles[i] + 1]],\n        [coords[2 * triangles[i + 1]], coords[2 * triangles[i + 1] + 1]],\n        [coords[2 * triangles[i + 2]], coords[2 * triangles[i + 2] + 1]]\n    ]);\n}\n```\n\n#### delaunay.halfedges\n\nA `Int32Array` array of triangle half-edge indices that allows you to traverse the triangulation.\n`i`-th half-edge in the array corresponds to vertex `triangles[i]` the half-edge is coming from.\n`halfedges[i]` is the index of a twin half-edge in an adjacent triangle\n(or `-1` for outer half-edges on the convex hull).\n\nThe flat array-based data structures might be counterintuitive,\nbut they're one of the key reasons this library is fast.\n\n#### delaunay.hull\n\nA `Uint32Array` array of indices that reference points on the convex hull of the input data, counter-clockwise.\n\n#### delaunay.coords\n\nAn array of input coordinates in the form `[x0, y0, x1, y1, ....]`,\nof the type provided in the constructor (or `Float64Array` if you used `Delaunator.from`).\n\n#### delaunay.update()\n\nUpdates the triangulation if you modified `delaunay.coords` values in place, avoiding expensive memory allocations.\nUseful for iterative relaxation algorithms such as [Lloyd's](https://en.wikipedia.org/wiki/Lloyd%27s_algorithm).\n\n## Performance\n\nBenchmark results against other Delaunay JS libraries\n(`npm run bench` on Macbook Pro Retina 15\" 2017, Node v10.10.0):\n\n&nbsp; | uniform 100k | gauss 100k | grid 100k | degen 100k | uniform 1&nbsp;million | gauss 1&nbsp;million | grid 1&nbsp;million | degen 1&nbsp;million\n:-- | --: | --: | --: | --: | --: | --: | --: | --:\n**delaunator** | 82ms | 61ms | 66ms | 25ms | 1.07s | 950ms | 830ms | 278ms\n[faster&#8209;delaunay](https://github.com/Bathlamos/delaunay-triangulation) | 473ms | 411ms | 272ms | 68ms | 4.27s | 4.62s | 4.3s | 810ms\n[incremental&#8209;delaunay](https://github.com/mikolalysenko/incremental-delaunay) | 547ms | 505ms | 172ms | 528ms | 5.9s | 6.08s | 2.11s | 6.09s\n[d3&#8209;voronoi](https://github.com/d3/d3-voronoi) | 972ms | 909ms | 358ms | 720ms | 15.04s | 13.86s | 5.55s | 11.13s\n[delaunay&#8209;fast](https://github.com/darkskyapp/delaunay-fast) | 3.8s | 4s | 12.57s | timeout | 132s | 138s | 399s | timeout\n[delaunay](https://github.com/darkskyapp/delaunay) | 4.85s | 5.73s | 15.05s | timeout | 156s | 178s | 326s | timeout\n[delaunay&#8209;triangulate](https://github.com/mikolalysenko/delaunay-triangulate) | 2.24s | 2.04s | OOM | 1.51s | OOM | OOM | OOM | OOM\n[cdt2d](https://github.com/mikolalysenko/cdt2d) | 45s | 51s | 118s | 17s | timeout | timeout | timeout | timeout\n\n## Papers\n\nThe algorithm is based on ideas from the following papers:\n\n- [A simple sweep-line Delaunay triangulation algorithm](http://www.academicpub.org/jao/paperInfo.aspx?paperid=15630), 2013, Liu Yonghe, Feng Jinming and Shao Yuehong\n- [S-hull: a fast radial sweep-hull routine for Delaunay triangulation](http://www.s-hull.org/paper/s_hull.pdf), 2010, David Sinclair\n- [A faster circle-sweep Delaunay triangulation algorithm](http://cglab.ca/~biniaz/papers/Sweep%20Circle.pdf), 2011, Ahmad Biniaz and Gholamhossein Dastghaibyfard\n\n## Robustness\n\nDelaunator should produce valid output even on highly degenerate input. It does so by depending on [robust-predicates](https://github.com/mourner/robust-predicates), a modern port of Jonathan Shewchuk's robust geometric predicates, an industry standard in computational geometry.\n\n## Ports to other languages\n\n- [delaunator-rs](https://github.com/mourner/delaunator-rs) (Rust)\n- [fogleman/delaunay](https://github.com/fogleman/delaunay) (Go)\n- [delaunator-cpp](https://github.com/abellgithub/delaunator-cpp) (C++)\n- [delaunator-sharp](https://github.com/nol1fe/delaunator-sharp) (C#)\n- [delaunator-ruby](https://github.com/hendrixfan/delaunator-ruby) (Ruby)\n- [Delaunator-Python](https://github.com/HakanSeven12/Delaunator-Python) (Python)\n- [torch-delaunay](https://github.com/ybubnov/torch_delaunay) (Python/Torch)\n- [ricardomatias/delaunator](https://github.com/ricardomatias/delaunator) (Kotlin)\n- [delaunator-java](https://github.com/waveware4ai/delaunator-java) (Java)\n- [delaunay-Stata](https://github.com/asjadnaqvi/stata-delaunay-voronoi) (Stata/Mata)\n- [Delaunator.jl](https://github.com/JuliaGeometry/Delaunator.jl) (Julia)\n","publish_time":1774259603813,"_cnpm_publish_time":1774259603813,"dist-tags":{"latest":"5.1.0"}}