Main MRPT website > C++ reference for MRPT 1.4.0
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes

Detailed Description

A wrapper of a TPolygon2D class, implementing CSerializable.

Definition at line 25 of file CPolygon.h.

#include <mrpt/math/CPolygon.h>

Inheritance diagram for mrpt::math::CPolygon:
Inheritance graph

Public Member Functions

 CPolygon ()
 Constructor cx and cy are the "central" point coordinates (laser sensor location if applicable) This parameters are NOT used in PointIntoPolygon, so they can be ignored. More...
 
void AddVertex (double x, double y)
 Add a new vertex to polygon: More...
 
double GetVertex_x (size_t i) const
 Methods for accessing the vertexs: More...
 
double GetVertex_y (size_t i) const
 
size_t verticesCount () const
 Returns the vertices count in the polygon: More...
 
void setAllVertices (const std::vector< double > &x, const std::vector< double > &y)
 Set all vertices at once. More...
 
void setAllVertices (size_t nVertices, const double *xs, const double *ys)
 Set all vertices at once. More...
 
void setAllVertices (size_t nVertices, const float *xs, const float *ys)
 Set all vertices at once. More...
 
void getAllVertices (std::vector< double > &x, std::vector< double > &y) const
 Get all vertices at once. More...
 
void Clear ()
 Clear the polygon, erasing all vertexs. More...
 
bool PointIntoPolygon (double x, double y) const
 Check if a point is inside the polygon: More...
 
double distance (const TPoint2D &point) const
 Distance to a point. More...
 
bool contains (const TPoint2D &point) const
 Check whether a point is inside the polygon. 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...
 

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...
 

Protected Member Functions

CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const MRPT_OVERRIDE
 
void readFromStream (mrpt::utils::CStream &in, int version) MRPT_OVERRIDE
 

RTTI stuff <br>

typedef CPolygonPtr SmartPtr
 
static mrpt::utils::CLASSINIT _init_CPolygon
 
static mrpt::utils::TRuntimeClassId classCPolygon
 
static const mrpt::utils::TRuntimeClassIdclassinfo
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const MRPT_OVERRIDE
 
virtual mrpt::utils::CObjectduplicate () const MRPT_OVERRIDE
 
static mrpt::utils::CObjectCreateObject ()
 
static CPolygonPtr Create ()
 

Member Typedef Documentation

◆ SmartPtr

A typedef for the associated smart pointer

Definition at line 28 of file CPolygon.h.

Constructor & Destructor Documentation

◆ CPolygon()

mrpt::math::CPolygon::CPolygon ( )
inline

Constructor cx and cy are the "central" point coordinates (laser sensor location if applicable) This parameters are NOT used in PointIntoPolygon, so they can be ignored.

See also
PointIntoPolygon

Definition at line 36 of file CPolygon.h.

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::utils::TRuntimeClassId * mrpt::math::CPolygon::_GetBaseClass ( )
staticprotected

◆ AddVertex()

void mrpt::math::CPolygon::AddVertex ( double  x,
double  y 
)
inline

Add a new vertex to polygon:

Definition at line 41 of file CPolygon.h.

◆ Clear()

void mrpt::math::CPolygon::Clear ( )
inline

Clear the polygon, erasing all vertexs.

Definition at line 65 of file CPolygon.h.

◆ contains()

bool mrpt::math::TPolygon2D::contains ( const TPoint2D point) const
inherited

Check whether a point is inside the polygon.

Referenced by PointIntoPolygon().

◆ Create()

static CPolygonPtr mrpt::math::CPolygon::Create ( )
static

◆ CreateObject()

static mrpt::utils::CObject * mrpt::math::CPolygon::CreateObject ( )
static

◆ createRegularPolygon() [1/2]

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

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.

◆ createRegularPolygon() [2/2]

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

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.

◆ distance()

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

Distance to a point.

◆ duplicate()

virtual mrpt::utils::CObject * mrpt::math::CPolygon::duplicate ( ) const
virtual

◆ generate3DObject()

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

Projects into 3D space, zeroing the z.

◆ getAllVertices()

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

Get all vertices at once.

◆ getAsSegmentList()

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

Gets as set of segments, instead of points.

◆ getCenter()

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

Polygon's central point.

◆ getPlotData()

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

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

See also
mrpt::gui::CDisplayWindowPlots

◆ GetRuntimeClass()

virtual const mrpt::utils::TRuntimeClassId * mrpt::math::CPolygon::GetRuntimeClass ( ) const
virtual

◆ GetVertex_x()

double mrpt::math::CPolygon::GetVertex_x ( size_t  i) const
inline

Methods for accessing the vertexs:

See also
verticesCount

Definition at line 48 of file CPolygon.h.

References ASSERT_.

◆ GetVertex_y()

double mrpt::math::CPolygon::GetVertex_y ( size_t  i) const
inline

Definition at line 49 of file CPolygon.h.

References ASSERT_.

◆ isConvex()

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

Checks whether is convex.

◆ PointIntoPolygon()

bool mrpt::math::CPolygon::PointIntoPolygon ( double  x,
double  y 
) const
inline

Check if a point is inside the polygon:

Definition at line 69 of file CPolygon.h.

References mrpt::math::TPolygon2D::contains().

◆ readFromStream()

void mrpt::math::CPolygon::readFromStream ( mrpt::utils::CStream in,
int  version 
)
protected

◆ removeRedundantVertices()

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

Erase every redundant vertex from the polygon, saving space.

See also
removeRepeatedVertices

◆ removeRepeatedVertices()

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

Erase repeated vertices.

See also
removeRedundantVertices

◆ setAllVertices() [1/3]

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

Set all vertices at once.

◆ setAllVertices() [2/3]

void mrpt::math::CPolygon::setAllVertices ( size_t  nVertices,
const double *  xs,
const double *  ys 
)

Set all vertices at once.

Please use the std::vector version whenever possible unless efficiency is really an issue

◆ setAllVertices() [3/3]

void mrpt::math::CPolygon::setAllVertices ( size_t  nVertices,
const float *  xs,
const float *  ys 
)

Set all vertices at once.

Please use the std::vector version whenever possible unless efficiency is really an issue

◆ verticesCount()

size_t mrpt::math::CPolygon::verticesCount ( ) const
inline

Returns the vertices count in the polygon:

Definition at line 52 of file CPolygon.h.

◆ writeToStream()

void mrpt::math::CPolygon::writeToStream ( mrpt::utils::CStream out,
int *  getVersion 
) const
protected

Member Data Documentation

◆ _init_CPolygon

mrpt::utils::CLASSINIT mrpt::math::CPolygon::_init_CPolygon
staticprotected

Definition at line 28 of file CPolygon.h.

◆ classCPolygon

mrpt::utils::TRuntimeClassId mrpt::math::CPolygon::classCPolygon
static

Definition at line 28 of file CPolygon.h.

◆ classinfo

const mrpt::utils::TRuntimeClassId* mrpt::math::CPolygon::classinfo
static

Definition at line 28 of file CPolygon.h.

◆ elements

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

STL member.




Page generated by Doxygen 1.9.5 for MRPT 1.4.0 SVN: at Mon Dec 26 04:51:47 UTC 2022