MRPT logo

mrpt::math::CPolygon Class Reference

A simple 2D polygon class, mainly for checking points falling inside it. More...

#include <mrpt/math/CPolygon.h>

Inheritance diagram for mrpt::math::CPolygon:

mrpt::utils::CSerializable

List of all members.

Public Member Functions

 CPolygon (double cx=0, double cy=0)
 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.
void AddVertex (double x, double y)
 Add a new vertex to polygon:.
double GetVertex_x (size_t i) const
 Methods for accessing the vertexs:.
double GetVertex_y (size_t i) const
size_t verticesCount ()
 Returns the vertices count in the polygon:.
void setAllVertices (const std::vector< double > &x, const std::vector< double > &y)
 Set all vertices at once.
void setAllVertices (size_t nVertices, const double *xs, const double *ys)
 Set all vertices at once, not to be used normally.
void setAllVertices (size_t nVertices, const float *xs, const float *ys)
 Set all vertices at once, not to be used normally.
void Clear ()
 Clear the polygon, erasing all vertexs.
bool PointIntoPolygon (double x, double y) const
 Check if a point is inside the polygon:.
double ComputeTangentAngNearPoint (double x, double y, double view_phi, double min_dist)
 Computed the angle between the viewing angle and the closest edge in the polygon to the given point.

Private Member Functions

bool isLeft (double P0x, double P0y, double P1x, double P1y, double Px, double Py) const

Private Attributes

std::vector< double > vx
 The placeholders for vertexs.
std::vector< double > vy
double cx
 The "central" point coordinates (laser sensor location if applicable).
double cy
double min_x
 Automatically maintained max/min coordinates of polygon.
double max_x
double min_y
double max_y


Detailed Description

A simple 2D polygon class, mainly for checking points falling inside it.

Definition at line 43 of file CPolygon.h.


Constructor & Destructor Documentation

mrpt::math::CPolygon::CPolygon ( double  cx = 0,
double  cy = 0 
)

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


Member Function Documentation

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

Add a new vertex to polygon:.

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

Clear the polygon, erasing all vertexs.

Definition at line 101 of file CPolygon.h.

double mrpt::math::CPolygon::ComputeTangentAngNearPoint ( double  x,
double  y,
double  view_phi,
double  min_dist 
)

Computed the angle between the viewing angle and the closest edge in the polygon to the given point.

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

Methods for accessing the vertexs:.

See also:
verticesCount

Definition at line 80 of file CPolygon.h.

References ASSERT_.

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

Definition at line 81 of file CPolygon.h.

References ASSERT_.

bool mrpt::math::CPolygon::isLeft ( double  P0x,
double  P0y,
double  P1x,
double  P1y,
double  Px,
double  Py 
) const [private]

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

Check if a point is inside the polygon:.

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

Set all vertices at once, not to be used normally.

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

Set all vertices at once, not to be used normally.

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

Set all vertices at once.

size_t mrpt::math::CPolygon::verticesCount (  )  [inline]

Returns the vertices count in the polygon:.

Definition at line 85 of file CPolygon.h.


Member Data Documentation

double mrpt::math::CPolygon::cx [private]

The "central" point coordinates (laser sensor location if applicable).

Definition at line 55 of file CPolygon.h.

double mrpt::math::CPolygon::cy [private]

Definition at line 55 of file CPolygon.h.

double mrpt::math::CPolygon::max_x [private]

Definition at line 59 of file CPolygon.h.

double mrpt::math::CPolygon::max_y [private]

Definition at line 59 of file CPolygon.h.

double mrpt::math::CPolygon::min_x [private]

Automatically maintained max/min coordinates of polygon.

Definition at line 59 of file CPolygon.h.

double mrpt::math::CPolygon::min_y [private]

Definition at line 59 of file CPolygon.h.

std::vector<double> mrpt::math::CPolygon::vx [private]

The placeholders for vertexs.

Definition at line 51 of file CPolygon.h.

std::vector<double> mrpt::math::CPolygon::vy [private]

Definition at line 51 of file CPolygon.h.




Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN: at Sun Aug 9 21:47:23 CEST 2009