I'd like to play around with some (2D) Delaunay triangulations, and am looking for a reasonably small library to work with. I'm aware of CGAL, but I was wondering if there was something fairly simple and straightforward out there.
Things I would like to do:
Suggestions?
Delaunay triangulations are often used to generate meshes for space-discretised solvers such as the finite element method and the finite volume method of physics simulation, because of the angle guarantee and because fast triangulation algorithms have been developed.
There exists a Delaunay triangulation for any set of points in two dimensions. It is always unique as long as no four points in the point set are co-circular.
The Delaunay triangulation ensures that no vertex lies within the interior of any of the circumcircles of the triangles in the network. If the Delaunay criterion is satisfied everywhere on the TIN, the minimum interior angle of all triangles is maximized.
You should probably detail your goals a bit, so that more relevant answers can be provided, but let me first mention Triangle, a 2D Delaunay generation tool, which is written in C, and can be used both as a standalone program, or called from your own code.
Then, about CGAL, here is a typical small example, in case you still consider it:
#include <vector> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Delaunay_triangulation_2.h> typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Delaunay_triangulation_2<K> Delaunay; typedef K::Point_2 Point; void load_points(std::vector< Point >& points) { points.push_back(Point(1., 1.)); points.push_back(Point(2., 1.)); points.push_back(Point(2., 2.)); points.push_back(Point(1., 2.)); } int main() { std::vector< Point > points; load_points(points); Delaunay dt; dt.insert(points.begin(), points.end()); std::cout << dt.number_of_vertices() << std::endl; return 0; }
See also poly2tri, it looks nice: https://github.com/greenm01/poly2tri
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With