{"id":13525003,"url":"https://github.com/hiulit/Delaunator-GDScript","last_synced_at":"2025-04-01T04:30:42.027Z","repository":{"id":48275408,"uuid":"273299885","full_name":"hiulit/Delaunator-GDScript","owner":"hiulit","description":"A GDScript port of Delaunator: A fast library for Delaunay triangulation of 2D points.","archived":false,"fork":false,"pushed_at":"2024-04-06T11:06:47.000Z","size":1190,"stargazers_count":80,"open_issues_count":3,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-30T00:16:52.359Z","etag":null,"topics":["2d","algorithm","computational-geometry","delaunator","delaunay","fast","gdscript","mapbox","triangulation"],"latest_commit_sha":null,"homepage":"","language":"GDScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hiulit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"patreon":"hiulit","ko_fi":"hiulit","custom":"https://www.paypal.me/hiulit"}},"created_at":"2020-06-18T17:27:21.000Z","updated_at":"2024-07-04T23:56:34.000Z","dependencies_parsed_at":"2024-06-19T02:56:12.055Z","dependency_job_id":"a5a277f3-e4c0-4b27-a3a0-6d7da8dbc1a3","html_url":"https://github.com/hiulit/Delaunator-GDScript","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiulit%2FDelaunator-GDScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiulit%2FDelaunator-GDScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiulit%2FDelaunator-GDScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiulit%2FDelaunator-GDScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiulit","download_url":"https://codeload.github.com/hiulit/Delaunator-GDScript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222698201,"owners_count":17024878,"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","delaunator","delaunay","fast","gdscript","mapbox","triangulation"],"created_at":"2024-08-01T06:01:15.246Z","updated_at":"2024-11-02T09:30:40.370Z","avatar_url":"https://github.com/hiulit.png","language":"GDScript","readme":"# Delaunator GDScript\n\n![Godot v3.x](https://img.shields.io/badge/Godot-v3.x-%23478cbf?logo=godot-engine\u0026logoColor=white\u0026style=flat-square) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/hiulit/Delaunator-GDScript?\u0026style=flat-square) ![GitHub license](https://img.shields.io/github/license/hiulit/Delaunator-GDScript?\u0026style=flat-square)\n\nA GDScript port of Delaunator: A fast library for [Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation) of 2D points.\n\n* [Guide to data structures](/DATA_STRUCTURES.md).\n\nThis is a port of [Mapbox's Delaunator](https://github.com/mapbox/delaunator).\n\n**Note**: It seems like GDScript is not that *fast* (in reference of the slogan above, taken from the original library). See the [performance benchmarks](#performance).\n\n![Delaunay triangulation](/examples/00-a-delaunay-triangulation.png)\n*Delaunay triangulation*\n\n![Voronoi cells](/examples/00-b-voronoi-cells.png)\n*Voronoi cells*\n\n## 🚀 Usage\n\n```gdscript\nconst Delaunator = preload(\"res://Delaunator.gd\")\n\nvar points = PoolVector2Array([\n  Vector2(0, 0), Vector2(1024, 0), Vector2(1024, 600), Vector2(0, 600), Vector2(29, 390), Vector2(859, 300), Vector2(65, 342), Vector2(86, 333), Vector2(962, 212), Vector2(211, 351), Vector2(3, 594), Vector2(421, 278), Vector2(608, 271), Vector2(230, 538), Vector2(870, 454), Vector2(850, 351), Vector2(583, 385), Vector2(907, 480), Vector2(749, 533), Vector2(877, 232), Vector2(720, 546), Vector2(1003, 541), Vector2(696, 594), Vector2(102, 306)\n])\n\nvar delaunay = Delaunator.new(points)\n\nprint(delaunay.triangles)\n# \u003e\u003e [11, 16, 12, 11, 13, 16, 22, 20, 16, 16, 15, 12, 20, 18, 16, 13, 22, 16, 20, 22, 18, 18, 15, 16, 15, 5, 12, 9, 13, 11, 8, 19, 5, 5, 19, 12, 12, 0, 11, 18, 14, 15, 15, 8, 5, 17, 14, 18, 0, 23, 11, 11, 23, 9, 9, 4, 13, 14, 17, 15, 21, 17, 2, 23, 7, 9, 23, 6, 7, 7, 4, 9, 17, 8, 15, 19, 1, 12, 6, 4, 7, 2, 17, 18, 17, 21, 8, 22, 2, 18, 21, 1, 8, 4, 10, 13, 13, 3, 22, 22, 3, 2, 4, 3, 10, 10, 3, 13, 2, 1, 21, 8, 1, 19, 1, 0, 12, 23, 0, 6, 6, 0, 4, 4, 0, 3]\n\nprint(delaunay.halfedges)\n# \u003e\u003e [5, 11, 38, 28, 17, 0, 18, 14, 16, 22, 26, 1, 20, 23, 7, 98, 8, 4, 6, 89, 12, 41, 9, 13, 44, 35, 10, 56, 3, 53, 113, 33, 43, 31, 77, 25, 115, 50, 2, 46, 59, 21, 73, 32, 24, 57, 39, 82, 117, 51, 37, 49, 65, 29, 70, 95, 27, 45, 74, 40, 84, 81, 110, 68, 71, 52, 119, 80, 63, 79, 54, 64, 86, 42, 58, 112, 116, 34, 122, 69, 67, 61, 47, 88, 60, 92, 72, 101, 83, 19, 109, 111, 85, 104, 107, 55, 106, 99, 15, 97, -1, 87, 125, 105, 93, 103, 96, 94, -1, 90, 62, 91, 75, 30, -1, 36, 76, 48, 120, 66, 118, 123, 78, 121, -1, 102]\n\nprint(delaunay.hull)\n# \u003e\u003e [1, 0, 3, 2]\n\nprint(delaunay.coords)\n# \u003e\u003e [0, 0, 1024, 0, 1024, 600, 0, 600, 29, 390, 859, 300, 65, 342, 86, 333, 962, 212, 211, 351, 3, 594, 421, 278, 608, 271, 230, 538, 870, 454, 850, 351, 583, 385, 907, 480, 749, 533, 877, 232, 720, 546, 1003, 541, 696, 594, 102, 306]\n\n```\n\n## 📑 API Reference\n\n### Delaunator.new(points)\n\nConstructs a Delaunay triangulation object given an array of points (`Vector2(x, y)`). Duplicate points are skipped.\n\n### Delaunator.new(points).triangles\n\nAn array of triangle vertex indices (each group of three numbers forms a triangle). All triangles are directed counterclockwise.\n\nTo get the coordinates of all triangles, use:\n\n```gdscript\nvar coordinates = []\n\nfor i in range(0, triangles.size(), 3):\n  coordinates.append([\n    points[triangles[i]],\n    points[triangles[i + 1]],\n    points[triangles[i + 2]]\n  ])\n```\n\n### Delaunator.new(points).halfedges\n\nAn 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 (or `-1` for outer half-edges on the convex hull).\n\nThe flat array-based data structures might be counterintuitive, but they're one of the key reasons this library is fast.\n\n### Delaunator.new(points).hull\n\nAn array of indices that reference points on the convex hull of the input data, counter-clockwise.\n\n### Delaunator.new(points).coords\n\nAn array of input coordinates in the form `[x0, y0, x1, y1, ...]`, of the type provided in the constructor.\n\n### Delaunator.new(points).update()\n\nUpdates the triangulation if you modified `Delaunator.new(points).coords` values in place, avoiding expensive memory allocations. Useful for iterative relaxation algorithms such as [Lloyd's](https://en.wikipedia.org/wiki/Lloyd%27s_algorithm).\n\n## 📈 Performance\n\nBenchmark results performed on a Macbook Pro Retina 15\" 2015 with Godot 3.2 and 3.3 using this method:\n\n```gdscript\nvar start = OS.get_ticks_msec()\nvar delaunay = Delaunator.new(points)\nvar elapsed = OS.get_ticks_msec() - start\nprint(elapsed)\n```\n\n| | 10 points | 100 points | 1.000 points | 10.000 points | 100.000 points |\n| :-- | --: | --: | --: | --: | --: |\n| **Godot 3.2** | ~1ms | ~6ms | ~67ms | ~760ms | ~9.4s |\n| **Godot 3.3** | ~1ms | ~8ms | ~77ms | ~850ms | ~10.0s |\n\n\n## 🗒️ Changelog\n\nSee [CHANGELOG](/CHANGELOG.md).\n\n## 👤 Author\n\n**hiulit**\n\n- Twitter: [@hiulit](https://twitter.com/hiulit)\n- GitHub: [@hiulit](https://github.com/hiulit)\n\n## 🤝 Contributing\n\nFeel free to:\n\n- [Open an issue](https://github.com/hiulit/Delaunator-GDScript/issues) if you find a bug.\n- [Create a pull request](https://github.com/hiulit/Delaunator-GDScript/pulls) if you have a new cool feature to add to the project.\n- [Start a new discussion](https://github.com/hiulit/Delaunator-GDScript/discussions) about a feature request.\n\n\n## 🙌 Supporting this project\n\nIf you love this project or find it helpful, please consider supporting it through any size donations to help make it better ❤️.\n\n[![Become a patron](https://img.shields.io/badge/Become_a_patron-ff424d?logo=Patreon\u0026style=for-the-badge\u0026logoColor=white)](https://www.patreon.com/hiulit)\n\n[![Suppor me on Ko-Fi](https://img.shields.io/badge/Support_me_on_Ko--fi-F16061?logo=Ko-fi\u0026style=for-the-badge\u0026logoColor=white)](https://ko-fi.com/F2F7136ND)\n\n[![Buy me a coffee](https://img.shields.io/badge/Buy_me_a_coffee-FFDD00?logo=buy-me-a-coffee\u0026style=for-the-badge\u0026logoColor=black)](https://www.buymeacoffee.com/hiulit)\n\n[![Donate Paypal](https://img.shields.io/badge/PayPal-00457C?logo=PayPal\u0026style=for-the-badge\u0026label=Donate)](https://www.paypal.com/paypalme/hiulit)\n\nIf you can't, consider sharing it with the world...\n\n[![](https://img.shields.io/badge/Share_on_Twitter-1DA1F2?style=for-the-badge\u0026logo=twitter\u0026logoColor=white)](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Fhiulit%2FDelaunator-GDScript\u0026text=%22Delaunator-GDScript%22%0AA%20GDScript%20port%20of%20Delaunator%3A%20A%20fast%20library%20for%20Delaunay%20triangulation%20of%202D%20points%20by%20%40hiulit)\n\n... or giving it a [star ⭐️](https://github.com/hiulit/Delaunator-GDScript/stargazers).\n\n## 👏 Credits\n\nThanks to:\n\n- [Vladimir Agafonkin](https://github.com/mourner) - For creating [Delaunator](https://github.com/mapbox/delaunator), the original JavaScript library.\n- [Amit Patel](https://github.com/redblobgames) - For the [Delaunator guide](https://mapbox.github.io/delaunator/), which my data structures guide is based of.\n- [Hakan Seven](https://github.com/HakanSeven12) - For the [Delaunator-Python](https://github.com/HakanSeven12/Delaunator-Python) port, which I used for some reference code.\n\n## 📝 Licenses\n\n- Source code: [MIT License](/LICENSE).\n- Mapbox's Delaunator: [ISC License](/LICENSE_MABOX_DELAUNATOR.txt).","funding_links":["https://patreon.com/hiulit","https://ko-fi.com/hiulit","https://www.paypal.me/hiulit","https://www.patreon.com/hiulit","https://ko-fi.com/F2F7136ND","https://www.buymeacoffee.com/hiulit","https://www.paypal.com/paypalme/hiulit"],"categories":["Plugins and scripts","GDScript"],"sub_categories":["3D"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiulit%2FDelaunator-GDScript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiulit%2FDelaunator-GDScript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiulit%2FDelaunator-GDScript/lists"}