{"id":13426518,"url":"https://github.com/mapbox/delaunator","last_synced_at":"2025-05-13T20:04:40.635Z","repository":{"id":37761134,"uuid":"91450623","full_name":"mapbox/delaunator","owner":"mapbox","description":"An incredibly fast JavaScript library for Delaunay triangulation of 2D points","archived":false,"fork":false,"pushed_at":"2025-03-17T09:04:39.000Z","size":1364,"stargazers_count":2435,"open_issues_count":5,"forks_count":146,"subscribers_count":157,"default_branch":"main","last_synced_at":"2025-05-06T18:40:54.935Z","etag":null,"topics":["2d","algorithm","computational-geometry","delaunay","fast","javascript","triangulation"],"latest_commit_sha":null,"homepage":"https://mapbox.github.io/delaunator/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mapbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-05-16T11:28:13.000Z","updated_at":"2025-05-06T08:06:05.000Z","dependencies_parsed_at":"2024-06-18T11:10:41.709Z","dependency_job_id":"cf624b73-f9e5-4f18-82a9-1e39c1eed34a","html_url":"https://github.com/mapbox/delaunator","commit_stats":{"total_commits":172,"total_committers":15,"mean_commits":"11.466666666666667","dds":"0.14534883720930236","last_synced_commit":"9274f009450d3ee94b6a82cd24632ba8ba57c2f0"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fdelaunator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fdelaunator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fdelaunator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fdelaunator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mapbox","download_url":"https://codeload.github.com/mapbox/delaunator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253009391,"owners_count":21839709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d","algorithm","computational-geometry","delaunay","fast","javascript","triangulation"],"created_at":"2024-07-31T00:01:36.801Z","updated_at":"2025-05-13T20:04:40.615Z","avatar_url":"https://github.com/mapbox.png","language":"JavaScript","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\u003cimg src=\"delaunator.png\" alt=\"Delaunay triangulation example\" width=\"600\" /\u003e\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 = [168,180, 168,178, 168,179, 168,181, 168,183, ...];\n\nconst delaunay = new Delaunator(coords);\nconsole.log(delaunay.triangles);\n// [623, 636, 619,  636, 444, 619, ...]\n```\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\u003cscript type=\"module\"\u003e\n    import Delaunator from 'https://cdn.skypack.dev/delaunator@5.0.0';\n\u003c/script\u003e\n```\n\nOr use a browser UMD build that exposes a `Delaunator` global variable:\n\n```html\n\u003cscript src=\"https://unpkg.com/delaunator@5.0.0/delaunator.min.js\"\u003e\u003c/script\u003e\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) =\u003e 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, use:\n\n```js\nfor (let i = 0; i \u003c 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\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\u0026nbsp; | uniform 100k | gauss 100k | grid 100k | degen 100k | uniform 1\u0026nbsp;million | gauss 1\u0026nbsp;million | grid 1\u0026nbsp;million | degen 1\u0026nbsp;million\n:-- | --: | --: | --: | --: | --: | --: | --: | --:\n**delaunator** | 82ms | 61ms | 66ms | 25ms | 1.07s | 950ms | 830ms | 278ms\n[faster\u0026#8209;delaunay](https://github.com/Bathlamos/delaunay-triangulation) | 473ms | 411ms | 272ms | 68ms | 4.27s | 4.62s | 4.3s | 810ms\n[incremental\u0026#8209;delaunay](https://github.com/mikolalysenko/incremental-delaunay) | 547ms | 505ms | 172ms | 528ms | 5.9s | 6.08s | 2.11s | 6.09s\n[d3\u0026#8209;voronoi](https://github.com/d3/d3-voronoi) | 972ms | 909ms | 358ms | 720ms | 15.04s | 13.86s | 5.55s | 11.13s\n[delaunay\u0026#8209;fast](https://github.com/ironwallaby/delaunay) | 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\u0026#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","funding_links":[],"categories":["JavaScript","\u003e 1K ⭐️","Libraries"],"sub_categories":["JavaScript"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapbox%2Fdelaunator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmapbox%2Fdelaunator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapbox%2Fdelaunator/lists"}