MCPcopy Create free account
hub / github.com/ANYbotics/grid_map / triangulate

Method triangulate

grid_map_core/src/Polygon.cpp:223–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223std::vector<Polygon> Polygon::triangulate(const TriangulationMethods& method) const
224{
225 // TODO Add more triangulation methods.
226 // https://en.wikipedia.org/wiki/Polygon_triangulation
227 std::vector<Polygon> polygons;
228 if (vertices_.size() < 3)
229 return polygons;
230
231 size_t nPolygons = vertices_.size() - 2;
232 polygons.reserve(nPolygons);
233
234 if (nPolygons < 1) {
235 // Special case.
236 polygons.push_back(*this);
237 } else {
238 // General case.
239 for (size_t i = 0; i < nPolygons; ++i) {
240 Polygon polygon({vertices_[0], vertices_[i + 1], vertices_[i + 2]});
241 polygons.push_back((polygon));
242 }
243 }
244
245 return polygons;
246}
247
248Polygon Polygon::fromCircle(const Position center, const double radius,
249 const int nVertices)

Callers 2

toTriangleListMarkerMethod · 0.80
TESTFunction · 0.80

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.64