|
1 | 1 | # delaunator-cpp |
2 | 2 |
|
3 | | -**c_cpp_properties.json** |
| 3 | +A really fast C++ library for |
| 4 | +[Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation) of 2D points. |
4 | 5 |
|
5 | | -``` |
6 | | -{ |
7 | | - "configurations": [ |
8 | | - { |
9 | | - "name": "CPP Mac", |
10 | | - "includePath": [ |
11 | | - "${workspaceFolder}/**", |
12 | | - "/usr/include/**" |
13 | | - ], |
14 | | - "defines": [], |
15 | | - "macFrameworkPath": [ |
16 | | - "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks" |
17 | | - ], |
18 | | - "compilerPath": "/usr/bin/clang", |
19 | | - "cStandard": "c11", |
20 | | - "cppStandard": "c++17", |
21 | | - "intelliSenseMode": "clang-x64", |
22 | | - "compileCommands": "${workspaceFolder}/build/compile_commands.json" |
23 | | - } |
24 | | - ], |
25 | | - "version": 4 |
| 6 | +delaunator-cpp is a C++ port from https://github.com/mapbox/delaunator a JavaScript implementation of very fast 2D Delaunay algorithm. |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +* Probably the fastest C++ open source 2D Delaunay implementation |
| 11 | +* Roughly 3 times faster then JS version. |
| 12 | +* Example showing triangulation of GeoJson points |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +```CPP |
| 17 | +#include "delaunator.h" |
| 18 | +#include <cstdio> |
| 19 | + |
| 20 | +//... |
| 21 | +int main(int, char* argv[]) { |
| 22 | + //... |
| 23 | + const vector<double> coords = {/* x0, y0, x1, y1, ... */}; |
| 24 | + Delaunator delaunator(coords); //triangulation happens here |
| 25 | + for(long int i = 0; i < delaunator.triangles.size(); i+=3) { |
| 26 | + printf( |
| 27 | + "Triangle points: [[%f, %f], [%f, %f], [%f, %f]]\n", |
| 28 | + delaunator.coords[2 * delaunator.triangles[i]], //tx0 |
| 29 | + delaunator.coords[2 * delaunator.triangles[i] + 1], //ty0 |
| 30 | + delaunator.coords[2 * delaunator.triangles[i + 1]], //tx1 |
| 31 | + delaunator.coords[2 * delaunator.triangles[i + 1] + 1], //ty1 |
| 32 | + delaunator.coords[2 * delaunator.triangles[i + 2]], //tx2 |
| 33 | + delaunator.coords[2 * delaunator.triangles[i + 2] + 1], //ty2 |
| 34 | + ) |
| 35 | + } |
26 | 36 | } |
27 | | -``` |
| 37 | +``` |
| 38 | +
|
| 39 | +For full example see `src/triangulate.cpp` |
| 40 | +
|
| 41 | +## TODO |
| 42 | +
|
| 43 | +* Benchmarks |
| 44 | +* Unit tests |
0 commit comments