commit | 6c587c061fcb97de3e38856ada5ae7c2aab50259 | [log] [tgz] |
---|---|---|
author | Vova Bilonenko <bilonenko.v@gmail.com> | Sat Sep 01 09:32:07 2018 +0200 |
committer | Vova Bilonenko <bilonenko.v@gmail.com> | Sat Sep 01 09:32:07 2018 +0200 |
tree | 4a700482189ee98a6ac00d0af7672db9fb193795 | |
parent | 9ab7532aef5fd02fdfc728b83b269563e512b2b4 [diff] |
benchmarks
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.h" #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(move(coords)); for(long int 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 src/triangulate.cpp