MRPT
1.9.9
|
2D polygon, inheriting from std::vector<TPoint2D>.
Definition at line 21 of file TPolygon2D.h.
#include <mrpt/math/TPolygon2D.h>
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::math::TPose2D &pose) |
Static method to create a regular polygon from its size and radius. More... | |
Public Attributes | |
T | elements |
STL member. More... | |
|
inline |
Default constructor.
Definition at line 48 of file TPolygon2D.h.
|
inlineexplicit |
Constructor for a given number of vertices, intializing them as garbage.
Definition at line 51 of file TPolygon2D.h.
|
inline |
Implicit constructor from a vector of 2D points.
Definition at line 53 of file TPolygon2D.h.
|
explicit |
Constructor from a 3D object.
Definition at line 160 of file TPolygon2D.cpp.
References resize().
bool 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 69 of file TPolygon2D.cpp.
References isLeft(), mrpt::math::size(), and mrpt::math::TPoint2D_data< T >::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(), mrpt::math::CPolygon::PointIntoPolygon(), and TEST().
|
static |
Static method to create a regular polygon, given its size and radius.
std::logic_error | if radius is near zero or the number of edges is less than three. |
Definition at line 166 of file TPolygon2D.cpp.
References mrpt::math::getEpsilon(), and M_PI.
Referenced by createRegularPolygon().
|
inlinestatic |
Static method to create a regular polygon from its size and radius.
The center will correspond to the given pose.
std::logic_error | if radius is near zero or the number of edges is less than three. |
Definition at line 180 of file TPolygon2D.cpp.
References mrpt::math::TPose2D::composePoint(), and createRegularPolygon().
double TPolygon2D::distance | ( | const TPoint2D & | point | ) | const |
Distance to a point (always >=0)
Definition at line 22 of file TPolygon2D.cpp.
References contains(), getAsSegmentList(), and THROW_EXCEPTION.
Referenced by mrpt::math::TPolygon3D::distance().
void TPolygon2D::generate3DObject | ( | TPolygon3D & | p | ) | const |
Projects into 3D space, zeroing the z.
Definition at line 106 of file TPolygon2D.cpp.
void TPolygon2D::getAsSegmentList | ( | std::vector< TSegment2D > & | v | ) | const |
Gets as set of segments, instead of points.
Definition at line 97 of file TPolygon2D.cpp.
References mrpt::math::size().
Referenced by distance(), and isConvex().
Get polygon bounding box.
On | empty polygon |
Definition at line 41 of file TPolygon2D.cpp.
References ASSERTMSG_, mrpt::containers::empty(), mrpt::keep_max(), mrpt::keep_min(), mrpt::math::size(), mrpt::math::TPoint2D_data< T >::x, and mrpt::math::TPoint2D_data< T >::y.
void TPolygon2D::getCenter | ( | TPoint2D & | p | ) | const |
Polygon's central point.
Definition at line 110 of file TPolygon2D.cpp.
References mrpt::containers::begin(), mrpt::containers::end(), mrpt::math::size(), mrpt::math::TPoint2D_data< T >::x, and mrpt::math::TPoint2D_data< T >::y.
void TPolygon2D::getPlotData | ( | std::vector< double > & | x, |
std::vector< double > & | y | ||
) | const |
Gets plot data, ready to use on a 2D plot.
Definition at line 146 of file TPolygon2D.cpp.
References mrpt::containers::operator[](), and mrpt::math::size().
Referenced by mrpt::nav::PlannerTPS_VirtualBase::internal_initialize_PTG().
bool TPolygon2D::isConvex | ( | ) | const |
Checks whether is convex.
Definition at line 117 of file TPolygon2D.cpp.
References getAsSegmentList(), mrpt::math::getEpsilon(), and mrpt::math::size().
Referenced by myTestPolygonContainsPoint().
void TPolygon2D::removeRedundantVertices | ( | ) |
Erase every redundant vertex from the polygon, saving space.
Definition at line 141 of file TPolygon2D.cpp.
References removeRepeatedVertices(), and mrpt::math::removeUnusedVertices().
Referenced by mrpt::math::splitInConvexComponents().
void TPolygon2D::removeRepeatedVertices | ( | ) |
Erase repeated vertices.
Definition at line 140 of file TPolygon2D.cpp.
References mrpt::math::removeRepVertices().
Referenced by removeRedundantVertices().
|
inherited |
STL member.
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020 |