Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes
mrpt::math::TPolygon2D Class Reference

Detailed Description

2D polygon, inheriting from std::vector<TPoint2D>.

See also
TPolygon3D,TSegment2D,TLine2D,TPoint2D, CPolygon

Definition at line 1451 of file lightweight_geom_data.h.

#include <mrpt/math/lightweight_geom_data.h>

Inheritance diagram for mrpt::math::TPolygon2D:
Inheritance graph

Public Member Functions

double distance (const TPoint2D &point) const
 Distance to a point (always >=0) More...
 
bool contains (const TPoint2D &point) const
 Check whether a point is inside (or within geometryEpsilon of a polygon edge). More...
 
void getAsSegmentList (std::vector< TSegment2D > &v) const
 Gets as set of segments, instead of points. More...
 
void generate3DObject (TPolygon3D &p) const
 Projects into 3D space, zeroing the z. More...
 
void getCenter (TPoint2D &p) const
 Polygon's central point. More...
 
bool isConvex () const
 Checks whether is convex. More...
 
void removeRepeatedVertices ()
 Erase repeated vertices. More...
 
void removeRedundantVertices ()
 Erase every redundant vertex from the polygon, saving space. More...
 
void getPlotData (std::vector< double > &x, std::vector< double > &y) const
 Gets plot data, ready to use on a 2D plot. More...
 
void getBoundingBox (TPoint2D &min_coords, TPoint2D &max_coords) const
 Get polygon bounding box. More...
 
 TPolygon2D ()
 Default constructor. More...
 
 TPolygon2D (size_t N)
 Constructor for a given number of vertices, intializing them as garbage. More...
 
 TPolygon2D (const std::vector< TPoint2D > &v)
 Implicit constructor from a vector of 2D points. More...
 
 TPolygon2D (const TPolygon3D &p)
 Constructor from a 3D object. More...
 

Static Public Member Functions

static void createRegularPolygon (size_t numEdges, double radius, TPolygon2D &poly)
 Static method to create a regular polygon, given its size and radius. More...
 
static void createRegularPolygon (size_t numEdges, double radius, TPolygon2D &poly, const mrpt::poses::CPose2D &pose)
 Static method to create a regular polygon from its size and radius. More...
 

Public Attributes

elements
 STL member. More...
 

Constructor & Destructor Documentation

◆ TPolygon2D() [1/4]

mrpt::math::TPolygon2D::TPolygon2D ( )
inline

Default constructor.

Definition at line 1478 of file lightweight_geom_data.h.

◆ TPolygon2D() [2/4]

mrpt::math::TPolygon2D::TPolygon2D ( size_t  N)
inlineexplicit

Constructor for a given number of vertices, intializing them as garbage.

Definition at line 1481 of file lightweight_geom_data.h.

◆ TPolygon2D() [3/4]

mrpt::math::TPolygon2D::TPolygon2D ( const std::vector< TPoint2D > &  v)
inline

Implicit constructor from a vector of 2D points.

Definition at line 1483 of file lightweight_geom_data.h.

◆ TPolygon2D() [4/4]

mrpt::math::TPolygon2D::TPolygon2D ( const TPolygon3D p)
explicit

Constructor from a 3D object.

Definition at line 1044 of file lightweight_geom_data.cpp.

References mrpt::math::TPoint2D::size().

Here is the call graph for this function:

Member Function Documentation

◆ contains()

bool mrpt::math::TPolygon2D::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.

Definition at line 938 of file lightweight_geom_data.cpp.

References mrpt::math::isLeft(), mrpt::math::size(), and mrpt::math::TPoint2D::y.

Referenced by mrpt::math::TPolygon3D::contains(), distance(), mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), mrpt::math::intersect(), intersect(), mrpt::nav::CPTG_RobotShape_Polygonal::isPointInsideRobotShape(), myTestPolygonContainsPoint(), and mrpt::math::CPolygon::PointIntoPolygon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createRegularPolygon() [1/2]

void mrpt::math::TPolygon2D::createRegularPolygon ( size_t  numEdges,
double  radius,
TPolygon2D poly 
)
static

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

Exceptions
std::logic_errorif radius is near zero or the number of edges is less than three.

Definition at line 1050 of file lightweight_geom_data.cpp.

References mrpt::math::getEpsilon(), and M_PI.

Referenced by createRegularPolygon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createRegularPolygon() [2/2]

void mrpt::math::TPolygon2D::createRegularPolygon ( size_t  numEdges,
double  radius,
TPolygon2D poly,
const mrpt::poses::CPose2D pose 
)
inlinestatic

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

The center will correspond to the given pose.

Exceptions
std::logic_errorif radius is near zero or the number of edges is less than three.

Definition at line 1063 of file lightweight_geom_data.cpp.

References createRegularPolygon().

Here is the call graph for this function:

◆ distance()

double mrpt::math::TPolygon2D::distance ( const TPoint2D point) const

Distance to a point (always >=0)

Definition at line 890 of file lightweight_geom_data.cpp.

References contains(), getAsSegmentList(), and THROW_EXCEPTION.

Referenced by mrpt::math::TPolygon3D::distance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate3DObject()

void mrpt::math::TPolygon2D::generate3DObject ( TPolygon3D p) const

Projects into 3D space, zeroing the z.

Definition at line 975 of file lightweight_geom_data.cpp.

◆ getAsSegmentList()

void mrpt::math::TPolygon2D::getAsSegmentList ( std::vector< TSegment2D > &  v) const

Gets as set of segments, instead of points.

Definition at line 966 of file lightweight_geom_data.cpp.

References mrpt::math::size().

Referenced by distance(), and isConvex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBoundingBox()

void mrpt::math::TPolygon2D::getBoundingBox ( TPoint2D min_coords,
TPoint2D max_coords 
) const

Get polygon bounding box.

Exceptions
Onempty polygon

Definition at line 910 of file lightweight_geom_data.cpp.

References ASSERTMSG_, empty(), mrpt::mrpt::utils::keep_max(), mrpt::mrpt::utils::keep_min(), mrpt::math::size(), mrpt::math::TPoint2D::x, and mrpt::math::TPoint2D::y.

Here is the call graph for this function:

◆ getCenter()

void mrpt::math::TPolygon2D::getCenter ( TPoint2D p) const

Polygon's central point.

Definition at line 994 of file lightweight_geom_data.cpp.

References begin(), and mrpt::math::size().

Here is the call graph for this function:

◆ getPlotData()

void mrpt::math::TPolygon2D::getPlotData ( std::vector< double > &  x,
std::vector< double > &  y 
) const

Gets plot data, ready to use on a 2D plot.

See also
mrpt::gui::CDisplayWindowPlots

Definition at line 1030 of file lightweight_geom_data.cpp.

References mrpt::utils::operator[](), and mrpt::math::size().

Referenced by mrpt::nav::PlannerTPS_VirtualBase::internal_initialize_PTG().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isConvex()

bool mrpt::math::TPolygon2D::isConvex ( ) const

Checks whether is convex.

Definition at line 1001 of file lightweight_geom_data.cpp.

References mrpt::math::TLine2D::evaluatePoint(), getAsSegmentList(), mrpt::math::getEpsilon(), and mrpt::math::size().

Referenced by myTestPolygonContainsPoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeRedundantVertices()

void mrpt::math::TPolygon2D::removeRedundantVertices ( )

Erase every redundant vertex from the polygon, saving space.

See also
removeRepeatedVertices

Definition at line 1025 of file lightweight_geom_data.cpp.

References removeRepeatedVertices(), and mrpt::math::removeUnusedVertices().

Referenced by mrpt::math::splitInConvexComponents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeRepeatedVertices()

void mrpt::math::TPolygon2D::removeRepeatedVertices ( )

Erase repeated vertices.

See also
removeRedundantVertices

Definition at line 1024 of file lightweight_geom_data.cpp.

References mrpt::math::removeRepVertices().

Referenced by removeRedundantVertices().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ elements

T std::vector< T >::elements
inherited

STL member.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019