33 throw std::logic_error(
"Polygon does not conform a plane");
41 return sqrt(newPoint.
z * newPoint.
z + distance2D * distance2D);
53 throw std::logic_error(
"Polygon does not conform a plane");
72 for (
size_t i = 0; i < N - 1; i++)
73 v[i] =
TSegment3D(
operator[](i),
operator[](i + 1));
74 v[N - 1] =
TSegment3D(
operator[](N - 1),
operator[](0));
100 for (
size_t i = 0; i < N; i++)
operator[](i) = p[i];
103 size_t numEdges,
double radius,
TPolygon3D& poly)
105 if (numEdges < 3 || std::abs(radius) <
getEpsilon())
106 throw std::logic_error(
107 "Invalid arguments for regular polygon creations");
108 poly.resize(numEdges);
109 for (
size_t i = 0; i < numEdges; i++)
111 double angle = i * 2 *
M_PI / numEdges;
112 poly[i] =
TPoint3D(radius * cos(angle), radius * sin(angle), 0);
119 for (
size_t i = 0; i < numEdges; i++) pose.
composePoint(poly[i], poly[i]);
void project3D(const TPoint3D &point, const mrpt::math::TPose3D &newXYpose, TPoint3D &newPoint)
Uses the given pose 3D to project a point into a new base.
A compile-time fixed-size numeric matrix container.
Auxiliary functor class to compute polygon's center.
TPoint2D_< double > TPoint2D
Lightweight 2D point.
void getCenter(TPoint3D &p) const
Get polygon's central point.
size_t size(const MATRIXLIKE &m, const int dim)
TPolygon3D()
Default constructor.
void fromHomogeneousMatrix(const mrpt::math::CMatrixDouble44 &HG)
void removeRepVertices(T &poly)
bool contains(const TPoint2D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
bool conformAPlane(const std::vector< TPoint3D > &points)
Checks whether this polygon or set of points acceptably fits a plane.
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D &poly)
Static method to create a regular polygon, given its size and radius.
void getAsPose3D(mrpt::math::TPose3D &outPose) const
This base provides a set of functions for maths stuff.
3D segment, consisting of two points.
void removeRedundantVertices()
Erase every redundant vertex, thus saving space.
void getAsSegmentList(std::vector< TSegment3D > &v) const
Gets as set of segments, instead of set of points.
void getAsPose3DForcingOrigin(const TPoint3D ¢er, TPose3D &pose) const
double distance(const TPoint2D &point) const
Distance to a point (always >=0)
3D Plane, represented by its equation
void composePoint(const TPoint3D &l, TPoint3D &g) const
double getRegressionPlane(const std::vector< TPoint3D > &points, TPlane &plane)
Using eigenvalues, gets the best fitting plane for a set of 3D points.
TPoint3D_< double > TPoint3D
Lightweight 3D point.
void getBestFittingPlane(TPlane &p) const
Gets the best fitting plane, disregarding whether the polygon actually fits inside or not...
void removeUnusedVertices(T &poly)
const_iterator end() const
const_iterator begin() const
double getEpsilon()
Gets the value of the geometric epsilon (default = 1e-5)
void getPrismBounds(const std::vector< TPoint3D > &poly, TPoint3D &pMin, TPoint3D &pMax)
Gets the prism bounds of a 3D polygon or set of 3D points.
void getInverseHomogeneousMatrix(mrpt::math::CMatrixDouble44 &HG) const
void removeRepeatedVertices()
Remove polygon's repeated vertices.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
void generate2DObject(TPolygon2D &p) const
Projects into a 2D space, discarding the z.
bool isSkew() const
Check whether the polygon is skew.
bool getPlane(TPlane &p) const
Gets a plane which contains the polygon.
bool contains(const TPoint3D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
2D polygon, inheriting from std::vector<TPoint2D>.
3D polygon, inheriting from std::vector<TPoint3D>
double distance(const TPoint3D &point) const
Distance to point (always >=0)