commit | f23e58faca07c40b308a1cde7fe2edefe31bc486 | [log] [tgz] |
---|---|---|
author | Blake Thompson <flippmoke@gmail.com> | Thu Sep 06 14:07:31 2018 -0500 |
committer | Blake Thompson <flippmoke@gmail.com> | Thu Sep 06 14:07:31 2018 -0500 |
tree | 5471a62d1652f359a0302893172a9189b026e712 | |
parent | df8d96302bbb13801572d9a700c7495792233c08 [diff] |
Forgot to add clang tidy and clang format configs
A really fast C++ library for Delaunay triangulation of 2D points.
delaunator-cpp is a C++ port from https://github.com/mapbox/delaunator a JavaScript implementation of very fast 2D Delaunay algorithm.
#include <delaunator.hpp> #include <cstdio> using namespace std; //... int main(int, char* argv[]) { //... const vector<double> coords = {/* x0, y0, x1, y1, ... */}; //triangulation happens here //note moving points to constructor delaunator::Delaunator delaunator(move(coords)); for(std::size_t i = 0; i < delaunator.triangles.size(); i+=3) { printf( "Triangle points: [[%f, %f], [%f, %f], [%f, %f]]\n", delaunator.coords[2 * delaunator.triangles[i]], //tx0 delaunator.coords[2 * delaunator.triangles[i] + 1], //ty0 delaunator.coords[2 * delaunator.triangles[i + 1]], //tx1 delaunator.coords[2 * delaunator.triangles[i + 1] + 1], //ty1 delaunator.coords[2 * delaunator.triangles[i + 2]], //tx2 delaunator.coords[2 * delaunator.triangles[i + 2] + 1], //ty2 ) } }
For full example see examples/triangulate/main.cpp