Class TPolygon3D

Inheritance Relationships

Base Type

  • public std::vector< TPoint3D >

Class Documentation

class TPolygon3D : public std::vector<TPoint3D>

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

Public Functions

inline TPolygon3D()

Default constructor. Creates a polygon with no vertices.

inline explicit TPolygon3D(size_t N)

Constructor for a given size. Creates a polygon with a fixed number of vertices (uninitialized)

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

Implicit constructor from a 3D points vector.

explicit TPolygon3D(const TPolygon2D &p)

Constructor from a 2D object. Zeroes the z.

inline TPolygon3D(const std::initializer_list<TPoint3D> &&vertices)

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

Throws:

std::logic_error – if number of edges is less than three, or radius is near zero. Constructor from list of vertices data, for example:

const mrpt::math::TPolygon3D p = {
 {-6.0, 0.5, 0.0}, {8.0, 2.0, 1.0}, {10.0, 4.0, 2.0}
 };

mrpt::containers::yaml asYAML() const

Returns a YAML representation of the polygon as a sequence (vertices) of sequences ([x y z] coordinates).

See also

FromYAML

Note

User must include #include <mrpt/containers/yaml.h> if using this method, only a forward declaration is defined here to speed up compilation

Note

(New in MRPT 2.4.1)

double distance(const TPoint3D &point) const

Absolute distance to point

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.

void generate2DObject(TPolygon2D &p) const

Projects into a 2D space, discarding the z.

See also

getPlane,isSkew

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.

void removeRepeatedVertices()

Remove polygon’s repeated vertices.

void removeRedundantVertices()

Erase every redundant vertex, thus saving space.

Public Static Functions

static TPolygon3D FromYAML(const mrpt::containers::yaml &c)

Builds a polygon from a YAML sequence (vertices) of sequences ([x y z] coordinates).

See also

asYAML

Note

User must include #include <mrpt/containers/yaml.h> if using this method, only a forward declaration is defined here to speed up compilation

Note

(New in MRPT 2.4.1)

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)

Static method to create a regular polygon, given its size and radius. The center will be located on the given pose.

Throws:

std::logic_error – if number of edges is less than three, or radius is near zero.