Function polygon_utils::triangulate(const polygon_msgs::msg::Polygon2D&)

Function Documentation

std::vector<polygon_msgs::msg::Point2D> polygon_utils::triangulate(const polygon_msgs::msg::Polygon2D &polygon)

Decompose a simple polygon into a set of triangles.

See https://en.wikipedia.org/wiki/Polygon_triangulation

Implementation from https://github.com/mapbox/earcut.hpp

Parameters:

polygon – The polygon to deconstruct

Returns:

A vector of points where each set of three points represents a triangle