Skip to content

Instantly share code, notes, and snippets.

@ialhashim
ialhashim / voronoi.hpp
Last active November 24, 2022 04:36
Header-only C++ implementation to generate Voronoi diagrams (nice data structure)
// Source: https://github.com/samkusin/gamelabs/tree/master/voronoi
// with a bug fix (ennetws)
/* Usage:
using namespace cinekine;
...
voronoi::Sites sites;
for(int i = 0; i < 5; i++) sites.push_back(voronoi::Vertex(rand()*xBound/RAND_MAX,rand()*yBound/RAND_MAX));
...
voronoi::Graph graph = voronoi::build(std::move(sites), xBound, yBound);
...