{"id":19219886,"url":"https://github.com/pvigier/mygal","last_synced_at":"2025-05-13T01:08:07.699Z","repository":{"id":40357252,"uuid":"158604232","full_name":"pvigier/MyGAL","owner":"pvigier","description":"MyGAL is a computational geometry algorithms library","archived":false,"fork":false,"pushed_at":"2022-11-21T15:45:55.000Z","size":313,"stargazers_count":39,"open_issues_count":5,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-13T01:07:59.828Z","etag":null,"topics":["delaunay-triangulation","fortune-algorithm","geometric-algorithms","geometry","geometry-library","lloyd-relaxation","voronoi","voronoi-diagram"],"latest_commit_sha":null,"homepage":"https://pvigier.github.io/docs/mygal/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pvigier.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}},"created_at":"2018-11-21T20:46:18.000Z","updated_at":"2025-03-31T21:40:42.000Z","dependencies_parsed_at":"2023-01-23T10:56:28.959Z","dependency_job_id":null,"html_url":"https://github.com/pvigier/MyGAL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvigier%2FMyGAL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvigier%2FMyGAL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvigier%2FMyGAL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvigier%2FMyGAL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pvigier","download_url":"https://codeload.github.com/pvigier/MyGAL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253851060,"owners_count":21973673,"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":["delaunay-triangulation","fortune-algorithm","geometric-algorithms","geometry","geometry-library","lloyd-relaxation","voronoi","voronoi-diagram"],"created_at":"2024-11-09T14:33:11.425Z","updated_at":"2025-05-13T01:08:07.630Z","avatar_url":"https://github.com/pvigier.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MyGAL\n\n[![Build Status](https://travis-ci.org/pvigier/MyGAL.svg?branch=master)](https://travis-ci.org/pvigier/MyGAL)\n[![codecov](https://codecov.io/gh/pvigier/MyGAL/branch/master/graph/badge.svg)](https://codecov.io/gh/pvigier/MyGAL)\n\n\n\nMyGAL is a computational geometry algorithms library.\n\n## Features\n\nFor the moment, the library is essentially based on [my implementation of Fortune's algorithm](https://github.com/pvigier/FortuneAlgorithm). It includes:\n\n* [Voronoi diagram](https://en.wikipedia.org/wiki/Voronoi_diagram)\n* [Lloyd's relaxation](https://en.wikipedia.org/wiki/Lloyd%27s_algorithm)\n* [Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation)\n\nMyGAL is:\n\n* easy to use\n* easy to install (header-only and no external dependency)\n* fast\n* well documented\n* multi-precision\n\n## Getting started\n\nTo get started, you just have to add the `include` folder of MyGAL to the include directories of your project. Then, you just have to add this header to start using MyGAL:\n\n```cpp\n#include \u003cMyGAL/FortuneAlgorithm.h\u003e\n```\n\nTo use the Fortune's algorithm to generate a Voronoi diagram, do the following: \n\n```cpp\nauto points = std::vector\u003cVector2\u003cdouble\u003e\u003e{{0.354, 0.678}, {0.632, 0.189}, {0.842, 0.942}}; // Generate some points\nauto algorithm = FortuneAlgorithm\u003cdouble\u003e(points); // Initialize an instance of Fortune's algorithm\nalgorithm.construct(); // Construct the diagram\n```\n\nThe template parameter corresponds to the floating point type used in computations. `double` is the recommended one.\n\nThe output diagram is unbounded but most of the time you will want a bounded one. To do that, we will compute the intersection between the diagram and a box. In MyGAL, we do that in two steps:\n\n```cpp\nalgorithm.bound(Box\u003cdouble\u003e{-0.05, -0.05, 1.05, 1.05}); // Bound the diagram\nauto diagram = algorithm.getDiagram(); // Get the constructed diagram\ndiagram.intersect(Box\u003cdouble\u003e{0.0, 0.0, 1.0, 1.0}); // Compute the intersection between the diagram and a box\n```\n\nFirstly, we bound the diagram then we compute the intersection. The two steps are due to technical details, you can read [this article](https://pvigier.github.io/2018/11/18/fortune-algorithm-details.html) if you want to know more. It is recommended to use a box slightly bigger for the bounded step than the one for the intersection step. Otherwise you might face numerical issues.\n\nYou can also obtain a Delaunay triangulation from the diagram:\n\n```cpp\nauto triangulation = diagram.computeTriangulation();\n```\n\nOr you can apply Lloyd's algorithm:\n\n```cpp\nauto relaxedPoints = diagram.computeLloydRelaxation()\n```\n\n## Example\n\nIf you want to build the example, you can use the cmake file present in the `example` folder. You will need [SFML](https://www.sfml-dev.org/).\n\nThe controls of the example are:\n\n* `N`: to generate new random points\n* `R`: to apply the Lloyd's algorithm\n* `T`: to show the Delaunay triangulation\n\n## Known issues\n\n* If several points are aligned horizontally (exactly the same y-coordinate), the diagram may be incorrect.\n* At least two points are expected.\n* The algorithms are tuned to work with coordinates between 0 and 1. You may want to scale your data to obtain better results.\n\n## Documentation\n\nThe documentation is available online [here](https://pvigier.github.io/docs/mygal/).\n\nIf you want to build the documentation, you have to have [Doxygen](http://www.doxygen.nl/) installed. Then you just have to execute the `doxygen` command in the `doc` folder.\n\nTo know more about the implementation you can read some [articles](https://pvigier.github.io/tag/geometry) on my blog.\n\n## License\n\nDistributed under the [GNU Lesser GENERAL PUBLIC LICENSE version 3](https://www.gnu.org/licenses/lgpl-3.0.en.html)\n\n## Images\n\nVoronoi diagram:\n\n![Voronoi diagram](https://github.com/pvigier/MyGAL/raw/master/images/voronoi.png)\n\nDelaunay triangulation:\n\n![Delaunay triangulation](https://github.com/pvigier/MyGAL/raw/master/images/delaunay.png)\n\nLloyd's relaxation:\n\n![Lloyd's relaxation](https://github.com/pvigier/MyGAL/raw/master/images/lloyd.gif)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpvigier%2Fmygal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpvigier%2Fmygal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpvigier%2Fmygal/lists"}