class mrpt::math::TPolygon3D¶

3D polygon, inheriting from std::vector<TPoint3D>

#include <mrpt/math/TPolygon3D.h>

class TPolygon3D: public std::vector< TPoint3D >
{
public:
// construction

TPolygon3D();
TPolygon3D(size_t N);
TPolygon3D(const std::vector<TPoint3D>& v);
TPolygon3D(const TPolygon2D& p);

//
methods

double distance(const TPoint3D& point) const;
bool contains(const TPoint3D& point) const;
void getAsSegmentList(std::vector<TSegment3D>& v) const;
bool getPlane(TPlane& p) const;
void getBestFittingPlane(TPlane& p) const;
void generate2DObject(TPolygon2D& p) const;
void getCenter(TPoint3D& p) const;
bool isSkew() const;
void removeRepeatedVertices();
void removeRedundantVertices();
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D& poly);
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D& poly, const mrpt::math::TPose3D& pose);
};

Construction¶

TPolygon3D()

Default constructor.

Creates a polygon with no vertices.

TPolygon3D(size_t N)

Constructor for a given size.

Creates a polygon with a fixed number of vertices, which are initialized to garbage.

TPolygon3D(const std::vector<TPoint3D>& v)

Implicit constructor from a 3D points vector.

TPolygon3D(const TPolygon2D& p)

Constructor from a 2D object.

Zeroes the z.

Methods¶

double distance(const TPoint3D& point) const

Distance to point (always >=0)

bool contains(const TPoint3D& point) const

Check whether a point is inside (or within geometryEpsilon of a polygon edge).

This works for concave or convex polygons.

void getAsSegmentList(std::vector<TSegment3D>& v) const

Gets as set of segments, instead of set of points.

bool getPlane(TPlane& p) const

Gets a plane which contains the polygon.

Returns false if the polygon is skew and cannot be fit inside a plane.

void getBestFittingPlane(TPlane& p) const

Gets the best fitting plane, disregarding whether the polygon actually fits inside or not.

getBestFittingPlane

void generate2DObject(TPolygon2D& p) const

Projects into a 2D space, discarding the z.

void getCenter(TPoint3D& p) const

Get polygon’s central point.

bool isSkew() const

Check whether the polygon is skew.

Returns true if there doesn’t exist a plane in which the polygon can fit.

getBestFittingPlane

void removeRepeatedVertices()

Remove polygon’s repeated vertices.

void removeRedundantVertices()

Erase every redundant vertex, thus saving space.

static void createRegularPolygon(
size_t numEdges,
TPolygon3D& poly
)

Static method to create a regular polygon, given its size and radius.

Parameters:

 std::logic_error if number of edges is less than three, or radius is near zero.
static void createRegularPolygon(
size_t numEdges,
)