Class TPolygon2D
Defined in File TPolygon2D.h
Inheritance Relationships
Base Type
public std::vector< TPoint2D >
Derived Type
public mrpt::math::CPolygon(Class CPolygon)
Class Documentation
-
class TPolygon2D : public std::vector<TPoint2D>
2D polygon, inheriting from std::vector<TPoint2D>.
See also
Subclassed by mrpt::math::CPolygon
Public Functions
-
inline TPolygon2D()
Default constructor
-
inline explicit TPolygon2D(size_t N)
Constructor for a given number of vertices (uninitialized)
-
inline TPolygon2D(const std::initializer_list<TPoint2D> &&vertices)
Constructor from list of vertices data, for example:
const mrpt::math::TPolygon2D p = { {-6.0, 0.5}, {8.0, 2.0}, {10.0, 4.0} };
-
explicit TPolygon2D(const TPolygon3D &p)
Constructor from a 3D object.
-
bool contains(const TPoint2D &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<TSegment2D> &v) const
Gets as set of segments, instead of points.
-
void generate3DObject(TPolygon3D &p) const
Projects into 3D space, zeroing the z.
-
bool isConvex() const
Checks whether is convex.
-
void removeRepeatedVertices()
Erase repeated vertices.
See also
-
void removeRedundantVertices()
Erase every redundant vertex from the polygon, saving space.
See also
-
void getPlotData(std::vector<double> &x, std::vector<double> &y) const
Gets plot data, ready to use on a 2D plot.
See also
-
inline std::tuple<std::vector<double>, std::vector<double>> getPlotData() const
-
mrpt::containers::yaml asYAML() const
Returns a YAML representation of the polygon as a sequence (vertices) of sequences (
[x y]coordinates).See also
Note
User must include
#include <mrpt/containers/yaml.h>if using this method, only a forward declaration is defined here to speed up compilationNote
(New in MRPT 2.4.1)
Public Static Functions
-
static TPolygon2D FromYAML(const mrpt::containers::yaml &c)
Builds a polygon from a YAML sequence (vertices) of sequences (
[x y]coordinates).See also
Note
User must include
#include <mrpt/containers/yaml.h>if using this method, only a forward declaration is defined here to speed up compilationNote
(New in MRPT 2.4.1)
-
static void createRegularPolygon(size_t numEdges, double radius, TPolygon2D &poly)
Static method to create a regular polygon, given its size and radius.
- Throws:
std::logic_error – if radius is near zero or the number of edges is less than three.
-
static void createRegularPolygon(size_t numEdges, double radius, TPolygon2D &poly, const mrpt::math::TPose2D &pose)
Static method to create a regular polygon from its size and radius. The center will correspond to the given pose.
- Throws:
std::logic_error – if radius is near zero or the number of edges is less than three.
-
inline TPolygon2D()