iDynTree::Polygon class

Class representing a 2D Polygon expressed in the 3D space.

A poligon is a geomtric object consisting of a number of points (called vertices) and an equal number of line segments (called sides), namely a cyclically ordered set of points in a plane, with no three successive points collinear, together with the line segments joining consecutive pairs of the points. In other words, a polygon is closed broken line lying in a plane.

Public static functions

static auto XYRectangleFromOffsets(const double front, const double back, const double left, const double right) -> Polygon
Return the polygon of a rectangle on the XY plane given the front (x positive), back (x negative), left (y positive) and right (y negative) offsets.

Constructors, destructors, conversion operators

Polygon()
Default constructor: build an invalid polygon without any vertex.

Public functions

void setNrOfVertices(size_t size)
Set the number of vertices (the vertices can then be accessed with the operator()
auto getNrOfVertices() const -> size_t
Get the number of vertices in the Polygon.
auto isValid() const -> bool
Check if a polygon is valid.
auto applyTransform(const Transform& newFrame_X_oldFrame) const -> Polygon
Apply a transform on the polygon.
auto operator()(const size_t idx) -> Position&
auto operator()(const size_t idx) const -> const Position&

Public variables

std::vector<Position> m_vertices

Function documentation

size_t iDynTree::Polygon::getNrOfVertices() const

Get the number of vertices in the Polygon.

Returns the number of vertices

bool iDynTree::Polygon::isValid() const

Check if a polygon is valid.

Returns true if is valid, false otherwise.

The condition for the validity of the polygon are: It has at least three points.

Polygon iDynTree::Polygon::applyTransform(const Transform& newFrame_X_oldFrame) const

Apply a transform on the polygon.

Returns the transformed polygon.