commit | 88a05e8f5a8e38ec109a8d7b09d7258f0e01e6b0 | [log] [tgz] |
---|---|---|
author | Blake Thompson <flippmoke@gmail.com> | Thu Sep 06 14:39:06 2018 -0500 |
committer | Blake Thompson <flippmoke@gmail.com> | Thu Sep 06 14:39:06 2018 -0500 |
tree | 2f6b7479dd7c6240528703cc643fd964b48ec144 | |
parent | fb0ec55be7a1b1d919f7f1a1ad89e1bd6fd53991 [diff] |
Small update to readme example
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[]) { //... std::vector<double> coords = {/* x0, y0, x1, y1, ... */}; //triangulation happens here //note moving points to constructor delaunator::Delaunator delaunator(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