I need to create random polygons with n vertices and decided to use CGAL. I found an algorithm for this using Delaunay triangulations implemented in MATlab: https://stackoverflow.com/a/9008916/9519322
I started to adapt it to c++, but I don't know how to handle vertices and (boundary) edges in CGAL and don't understand the follwing MATlab commands.
Could somebody help me to get a working adaption of the algorithm in c++?
assert(n >= 3);
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_real_distribution<double> dist(std::nextafter(0.0, 1.0), 1.0);
int fudge = (int)ceil((double)n/10);
std::vector<Point_2> points;
for (int i = 0; i < n + fudge; ++i)
{
points.emplace_back(dist(mt), dist(mt));
}
Delaunay dt;
dt.insert(points.begin(), points.end());
// get boundary edges of dt
// remaining
I've adapted the other algorithm of the thread yet, but it creates only star shaped polygons.
Aucun commentaire:
Enregistrer un commentaire