9#ifndef LIGHTWEIGHT_GEOM_DATA_H
10#define LIGHTWEIGHT_GEOM_DATA_H
13#include <mrpt/config.h>
54 template <
class DERIVEDCLASS>
65 inline TPoint2D(
double xx,
double yy):x(xx),y(yy) {}
71 inline double &
operator[](
size_t i) {
switch (i) {
case 0:
return x;
case 1:
return y;
default:
throw std::out_of_range(
"index out of range"); } }
73 inline const double &
operator[](
size_t i)
const {
switch (i) {
case 0:
return x;
case 1:
return y;
default:
throw std::out_of_range(
"index out of range"); } }
138 static size_t size() {
return 2; }
174 inline TPose2D(
double xx,
double yy,
double pphi):x(xx),y(yy),phi(pphi) {}
180 inline double &
operator[](
size_t i) {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return phi;
default:
throw std::out_of_range(
"index out of range"); } }
182 inline const double &
operator[](
size_t i)
const {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return phi;
default:
throw std::out_of_range(
"index out of range"); } }
188 v[0]=x; v[1]=y; v[2]=phi;
201 static size_t size() {
return 3; }
215 inline TPoint3Df(
const float xx,
const float yy,
const float zz) : x(xx), y(yy),z(zz) { }
219 inline float &
operator[](
size_t i) {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
throw std::out_of_range(
"index out of range"); } }
222 inline const float &
operator[](
size_t i)
const {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
throw std::out_of_range(
"index out of range"); } }
234 inline TPoint3D(
double xx,
double yy,
double zz):x(xx),y(yy),z(zz) {}
265 inline double &
operator[](
size_t i) {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
throw std::out_of_range(
"index out of range"); } }
267 inline const double &
operator[](
size_t i)
const {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
throw std::out_of_range(
"index out of range"); } }
296 template <
class VECTORLIKE>
299 v[0]=x; v[1]=y; v[2]=z;
353 static size_t size() {
return 3; }
361 inline TPointXYZIu8(
double x,
double y,
double z, uint8_t intensity_val) : pt(x,y,z),intensity(intensity_val) {}
368 inline TPointXYZRGBu8(
double x,
double y,
double z, uint8_t R_val, uint8_t G_val, uint8_t B_val) : pt(x,y,z),R(R_val),G(G_val),B(B_val) {}
375 inline TPointXYZfIu8(
float x,
float y,
float z, uint8_t intensity_val) : pt(x,y,z),intensity(intensity_val) {}
382 inline TPointXYZfRGBu8(
float x,
float y,
float z, uint8_t R_val, uint8_t G_val, uint8_t B_val) : pt(x,y,z),R(R_val),G(G_val),B(B_val) {}
417 TPose3D(
double _x,
double _y,
double _z,
double _yaw,
double _pitch,
double _roll):x(_x),y(_y),z(_z),yaw(_yaw),
pitch(_pitch),
roll(_roll) {}
423 inline double &
operator[](
size_t i) {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return yaw;
case 4:
return pitch;
case 5:
return roll;
default:
throw std::out_of_range(
"index out of range"); } }
425 inline const double &
operator[](
size_t i)
const {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return yaw;
case 4:
return pitch;
case 5:
return roll;
default:
throw std::out_of_range(
"index out of range"); } }
437 v[0]=x; v[1]=y; v[2]=z; v[3]=yaw; v[4]=
pitch; v[5]=
roll;
450 static size_t size() {
return 6; }
462 inline TPose3DQuat(
double _x,
double _y,
double _z,
double _qr,
double _qx,
double _qy,
double _qz):x(_x),y(_y),z(_z),qr(_qr),qx(_qx),qy(_qy),qz(_qz) { }
469 inline double &
operator[](
size_t i) {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return qr;
case 4:
return qx;
case 5:
return qy;
case 6:
return qz;
default:
throw std::out_of_range(
"index out of range"); } }
471 inline const double &
operator[](
size_t i)
const {
switch (i) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return qr;
case 4:
return qx;
case 5:
return qy;
case 6:
return qz;
default:
throw std::out_of_range(
"index out of range"); } }
479 for (
size_t i=0;i<7;i++) v[i]=(*
this)[i];
492 static size_t size() {
return 7; }
513 return (p1.
x==p2.
x)&&(p1.
y==p2.
y);
519 return (p1.
x!=p2.
x)||(p1.
y!=p2.
y);
525 return (p1.
x==p2.
x)&&(p1.
y==p2.
y)&&(p1.
z==p2.
z);
531 return (p1.
x!=p2.
x)||(p1.
y!=p2.
y)||(p1.
z!=p2.
z);
595 inline TPoint2D &
operator[](
size_t i) {
switch (i) {
case 0:
return point1;
case 1:
return point2;
default:
throw std::out_of_range(
"index out of range"); } }
597 inline const TPoint2D &
operator[](
size_t i)
const {
switch (i) {
case 0:
return point1;
case 1:
return point2;
default:
throw std::out_of_range(
"index out of range"); } }
606 p.
x=(point1.
x+point2.
x)/2;
607 p.
y=(point1.
y+point2.
y)/2;
655 inline TPoint3D &
operator[](
size_t i) {
switch (i) {
case 0:
return point1;
case 1:
return point2;
default:
throw std::out_of_range(
"index out of range"); } }
657 inline const TPoint3D &
operator[](
size_t i)
const {
switch (i) {
case 0:
return point1;
case 1:
return point2;
default:
throw std::out_of_range(
"index out of range"); } }
668 p.
x=(point1.
x+point2.
x)/2;
669 p.
y=(point1.
y+point2.
y)/2;
670 p.
z=(point1.
z+point2.
z)/2;
743 getNormalVector(vector);
754 getDirectorVector(vector);
829 for (
size_t i=0;i<3;i++) vector[i]=director[i];
836 getDirectorVector(vector);
886 return contains(segment.
point1)&&contains(segment.
point2);
913 getNormalVector(vec);
961 inline TPlane(
double A,
double B,
double C,
double D) {
971 for (
size_t i=0;i<4;i++) coefs[i]=vec[i];
1021 void getPlotData(std::vector<double> &x,std::vector<double> &y)
const;
1260 }
else return false;
1269 }
else return false;
1278 }
else return false;
1287 }
else return false;
1293 if (
this==&obj)
return *
this;
1295 switch (type=obj.
type) {
1356 static void getPoints(
const std::vector<TObject2D> &objs,std::vector<TPoint2D> &pnts);
1360 static void getSegments(
const std::vector<TObject2D> &objs,std::vector<TSegment2D> &sgms);
1364 static void getLines(
const std::vector<TObject2D> &objs,std::vector<TLine2D> &lins);
1368 static void getPolygons(
const std::vector<TObject2D> &objs,std::vector<TPolygon2D> &polys);
1372 static void getPoints(
const std::vector<TObject2D> &objs,std::vector<TPoint2D> &pnts,std::vector<TObject2D> &remainder);
1376 static void getSegments(
const std::vector<TObject2D> &objs,std::vector<TSegment2D> &sgms,std::vector<TObject2D> &remainder);
1380 static void getLines(
const std::vector<TObject2D> &objs,std::vector<TLine2D> &lins,std::vector<TObject2D> &remainder);
1384 static void getPolygons(
const std::vector<TObject2D> &objs,std::vector<TPolygon2D> &polys,std::vector<TObject2D> &remainder);
1499 }
else return false;
1508 }
else return false;
1517 }
else return false;
1526 }
else return false;
1535 }
else return false;
1541 if (
this==&obj)
return *
this;
1543 switch (type=obj.
type) {
1625 throw std::logic_error(
"Too many dimensions");
1640 static void getPoints(
const std::vector<TObject3D> &objs,std::vector<TPoint3D> &pnts);
1644 static void getSegments(
const std::vector<TObject3D> &objs,std::vector<TSegment3D> &sgms);
1648 static void getLines(
const std::vector<TObject3D> &objs,std::vector<TLine3D> &lins);
1652 static void getPlanes(
const std::vector<TObject3D> &objs,std::vector<TPlane> &plns);
1656 static void getPolygons(
const std::vector<TObject3D> &objs,std::vector<TPolygon3D> &polys);
1660 static void getPoints(
const std::vector<TObject3D> &objs,std::vector<TPoint3D> &pnts,std::vector<TObject3D> &remainder);
1664 static void getSegments(
const std::vector<TObject3D> &objs,std::vector<TSegment3D> &sgms,std::vector<TObject3D> &remainder);
1668 static void getLines(
const std::vector<TObject3D> &objs,std::vector<TLine3D> &lins,std::vector<TObject3D> &remainder);
1672 static void getPlanes(
const std::vector<TObject3D> &objs,std::vector<TPlane> &plns,std::vector<TObject3D> &remainder);
1676 static void getPolygons(
const std::vector<TObject3D> &objs,std::vector<TPolygon3D> &polys,std::vector<TObject3D> &remainder);
#define MRPT_DECLARE_TTYPENAME_NAMESPACE(_TYPE, __NS)
2D polygon, inheriting from std::vector<TPoint2D>.
TPolygon2D(const std::vector< TPoint2D > &v)
Implicit constructor from a vector of 2D points.
TPolygon2D()
Default constructor.
double distance(const TPoint2D &point) const
Distance to a point.
void getAsSegmentList(std::vector< TSegment2D > &v) const
Gets as set of segments, instead of points.
void getCenter(TPoint2D &p) const
Polygon's central point.
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.
void generate3DObject(TPolygon3D &p) const
Projects into 3D space, zeroing the z.
bool isConvex() const
Checks whether is convex.
void removeRedundantVertices()
Erase every redundant vertex from the polygon, saving space.
TPolygon2D(const TPolygon3D &p)
Constructor from a 3D object.
static void createRegularPolygon(size_t numEdges, double radius, TPolygon2D &poly)
Static method to create a regular polygon, given its size and radius.
void removeRepeatedVertices()
Erase repeated vertices.
TPolygon2D(size_t N)
Constructor for a given number of vertices, intializing them as garbage.
bool contains(const TPoint2D &point) const
Check whether a point is inside the polygon.
void getPlotData(std::vector< double > &x, std::vector< double > &y) const
Gets plot data, ready to use on a 2D plot.
3D polygon, inheriting from std::vector<TPoint3D>
TPolygon3D()
Default constructor.
void getBestFittingPlane(TPlane &p) const
Gets the best fitting plane, disregarding whether the polygon actually fits inside or not.
void getAsSegmentList(std::vector< TSegment3D > &v) const
Gets as set of segments, instead of set of points.
bool isSkew() const
Check whether the polygon is skew.
bool contains(const TPoint3D &point) const
Check whether a point is inside the polygon.
void generate2DObject(TPolygon2D &p) const
Projects into a 2D space, discarding the z.
void removeRedundantVertices()
Erase every redundant vertex, thus saving space.
TPolygon3D(const std::vector< TPoint3D > &v)
Implicit constructor from a 3D points vector.
double distance(const TPoint3D &point) const
Distance to point.
void removeRepeatedVertices()
Remove polygon's repeated vertices.
TPolygon3D(size_t N)
Constructor for a given size.
bool getPlane(TPlane &p) const
Gets a plane which contains the polygon.
void getCenter(TPoint3D &p) const
Get polygon's central point.
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D &poly, const mrpt::poses::CPose3D &pose)
Static method to create a regular polygon, given its size and radius.
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D &poly)
Static method to create a regular polygon, given its size and radius.
TPolygon3D(const TPolygon2D &p)
Constructor from a 2D object.
A class used to store a 2D point.
A class used to store a 3D point.
A class used to store a 2D pose.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
The base template class for 2D & 3D points and poses.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
std::vector< T1 > operator*(const std::vector< T1 > &a, const std::vector< T2 > &b)
a*b (element-wise multiplication)
T wrapTo2Pi(T a)
Modifies the given angle to translate it into the [0,2pi[ range.
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
const unsigned char GEOMETRIC_TYPE_POINT
Object type identifier for TPoint2D or TPoint3D.
const unsigned char GEOMETRIC_TYPE_LINE
Object type identifier for TLine2D or TLine3D.
TPoint3D operator-(const TPoint3D &p1)
Unary minus operator for 3D points.
struct BASE_IMPEXP TSegment3D
struct BASE_IMPEXP TObject3D
const unsigned char GEOMETRIC_TYPE_UNDEFINED
Object type identifier for empty TObject2D or TObject3D.
const unsigned char GEOMETRIC_TYPE_POLYGON
Object type identifier for TPolygon2D or TPolygon3D.
std::ostream BASE_IMPEXP & operator<<(std::ostream &o, const TPoint2D &p)
const unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
struct BASE_IMPEXP TLine3D
class BASE_IMPEXP TPolygon3D
const unsigned char GEOMETRIC_TYPE_PLANE
Object type identifier for TPlane.
#define THROW_EXCEPTION(msg)
This base provides a set of functions for maths stuff.
BASE_IMPEXP::mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, CMatrixPtr &pObj)
bool operator!=(const CArray< T, N > &x, const CArray< T, N > &y)
bool operator==(const CArray< T, N > &x, const CArray< T, N > &y)
T square(const T x)
Inline function for the square of a number.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
2D line without bounds, represented by its equation .
TLine2D(const TLine3D &l)
Construction from 3D object, discarding the Z.
TLine2D()
Fast default constructor.
double evaluatePoint(const TPoint2D &point) const
Evaluate point in the line's equation.
TLine2D(const TSegment2D &s)
Constructor from a segment.
void generate3DObject(TLine3D &l) const
Project into 3D space, setting the z to 0.
void getNormalVector(double(&vector)[2]) const
Get line's normal vector.
void getUnitaryDirectorVector(double(&vector)[2])
Unitarize line and then get director vector.
double signedDistance(const TPoint2D &point) const
Distance with sign from a given point (sign indicates side).
TLine2D(const TPoint2D &p1, const TPoint2D &p2)
Constructor from two points, through which the line will pass.
void unitarize()
Unitarize line's normal vector.
double distance(const TPoint2D &point) const
Distance from a given point.
void getDirectorVector(double(&vector)[2]) const
Get line's director vector.
void getAsPose2D(mrpt::poses::CPose2D &outPose) const
Get a pose2D whose X axis corresponds to the line.
bool contains(const TPoint2D &point) const
Check whether a point is inside the line.
void getAsPose2DForcingOrigin(const TPoint2D &origin, mrpt::poses::CPose2D &outPose) const
Get a pose2D whose X axis corresponds to the line, forcing the base point to one given.
TLine2D(double A, double B, double C)
Constructor from line's coefficients.
void getUnitaryNormalVector(double(&vector)[2])
Get line's normal vector after unitarizing line.
3D line, represented by a base point and a director vector.
TLine3D()
Fast default constructor.
void getDirectorVector(double(&vector)[3]) const
Get director vector.
double distance(const TPoint3D &point) const
Distance between the line and a point.
void unitarize()
Unitarize director vector.
bool contains(const TPoint3D &point) const
Check whether a point is inside the line.
void generate2DObject(TLine2D &l) const
Project into 2D space, discarding the Z coordinate.
TLine3D(const TPoint3D &p1, const TPoint3D &p2)
Constructor from two points, through which the line will pass.
void getUnitaryDirectorVector(double(&vector)[3])
Unitarize and then get director vector.
TPoint3D pBase
Base point.
TLine3D(const TSegment3D &s)
Constructor from 3D segment.
TLine3D(const TLine2D &l)
Implicit constructor from 2D object.
Union type storing pointers to every allowed type.
Standard type for storing any lightweight 2D type.
void generate3DObject(TObject3D &obj) const
Project into 3D space.
void operator=(const TPoint2D &p)
Assign a point to this object.
bool isPoint() const
Checks whether content is a point.
static void getSegments(const std::vector< TObject2D > &objs, std::vector< TSegment2D > &sgms, std::vector< TObject2D > &remainder)
Static method to retrieve all the segments in a vector of TObject2D, returning the remainder objects ...
static void getLines(const std::vector< TObject2D > &objs, std::vector< TLine2D > &lins)
Static method to retrieve all the lines in a vector of TObject2D.
bool isSegment() const
Checks whether content is a segment.
static void getPoints(const std::vector< TObject2D > &objs, std::vector< TPoint2D > &pnts, std::vector< TObject2D > &remainder)
Static method to retrieve all the points in a vector of TObject2D, returning the remainder objects in...
TObject2D(const TPoint2D &p)
Implicit constructor from point.
bool isPolygon() const
Checks whether content is a polygon.
TObject2D & operator=(const TObject2D &obj)
Assign another TObject2D.
static void getPoints(const std::vector< TObject2D > &objs, std::vector< TPoint2D > &pnts)
Static method to retrieve all the points in a vector of TObject2D.
bool getLine(TLine2D &r) const
Gets the content as a line, returning false if the type is inadequate.
~TObject2D()
Object destruction.
static void getSegments(const std::vector< TObject2D > &objs, std::vector< TSegment2D > &sgms)
Static method to retrieve all the segments in a vector of TObject2D.
unsigned char type
Object type identifier.
TObject2D(const TLine2D &r)
Implicit constructor from line.
unsigned char getType() const
Gets content type.
TObject2D(const TObject2D &obj)
Constructor from another TObject2D.
void operator=(const TPolygon2D &p)
Assign a polygon to this object.
bool getSegment(TSegment2D &s) const
Gets the content as a segment, returning false if the type is inadequate.
static void getPolygons(const std::vector< TObject2D > &objs, std::vector< TPolygon2D > &polys)
Static method to retrieve all the polygons in a vector of TObject2D.
bool getPolygon(TPolygon2D &p) const
Gets the content as a polygon, returning false if the type is inadequate.
void destroy()
Destroys the object, releasing the pointer to the content (if any).
void operator=(const TLine2D &l)
Assign a line to this object.
bool getPoint(TPoint2D &p) const
Gets the content as a point, returning false if the type is inadequate.
static void getLines(const std::vector< TObject2D > &objs, std::vector< TLine2D > &lins, std::vector< TObject2D > &remainder)
Static method to retrieve all the lines in a vector of TObject2D, returning the remainder objects in ...
TObject2D(const TPolygon2D &p)
Implicit constructor from polygon.
TObject2D(const TSegment2D &s)
Implicit constructor from segment.
bool isLine() const
Checks whether content is a line.
void operator=(const TSegment2D &s)
Assign a segment to this object.
TObject2D()
Implicit constructor from polygon.
struct mrpt::math::TObject2D::tobject2d_data_t data
static void getPolygons(const std::vector< TObject2D > &objs, std::vector< TPolygon2D > &polys, std::vector< TObject2D > &remainder)
Static method to retrieve all the polygons in a vector of TObject2D, returning the remainder objects ...
Union containing pointer to actual data.
Standard object for storing any 3D lightweight object.
void operator=(const TPolygon3D &p)
Assigns a polygon to this object.
static void getLines(const std::vector< TObject3D > &objs, std::vector< TLine3D > &lins, std::vector< TObject3D > &remainder)
Static method to retrieve every line included in a vector of objects, returning the remaining objects...
void operator=(const TPoint3D &p)
Assigns a point to this object.
static void getPoints(const std::vector< TObject3D > &objs, std::vector< TPoint3D > &pnts, std::vector< TObject3D > &remainder)
Static method to retrieve every point included in a vector of objects, returning the remaining object...
static void getSegments(const std::vector< TObject3D > &objs, std::vector< TSegment3D > &sgms)
Static method to retrieve every segment included in a vector of objects.
bool isPolygon() const
Checks whether content is a polygon.
TObject3D & operator=(const TObject3D &obj)
Assigns another object, creating a new pointer if needed.
void operator=(const TSegment3D &s)
Assigns a segment to this object.
bool getPlane(TPlane &p) const
Gets the content as a plane, returning false if the type is not adequate.
TObject3D(const TLine3D &r)
Constructor from line.
void destroy()
Destroys the object and releases the pointer, if any.
void operator=(const TPlane &p)
Assigns a plane to this object.
unsigned char getType() const
Gets object type.
TObject3D(const TPlane &p)
Constructor from plane.
bool isLine() const
Checks whether content is a line.
static void getPoints(const std::vector< TObject3D > &objs, std::vector< TPoint3D > &pnts)
Static method to retrieve every point included in a vector of objects.
bool isSegment() const
Checks whether content is a segment.
TObject3D(const TPoint3D &p)
Constructor from point.
static void getPolygons(const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys)
Static method to retrieve every polygon included in a vector of objects.
bool getSegment(TSegment3D &s) const
Gets the content as a segment, returning false if the type is not adequate.
struct mrpt::math::TObject3D::tobject3d_data_t data
bool getLine(TLine3D &r) const
Gets the content as a line, returning false if the type is not adequate.
void operator=(const TLine3D &l)
Assigns a line to this object.
static void getSegments(const std::vector< TObject3D > &objs, std::vector< TSegment3D > &sgms, std::vector< TObject3D > &remainder)
Static method to retrieve every segment included in a vector of objects, returning the remaining obje...
static void getPlanes(const std::vector< TObject3D > &objs, std::vector< TPlane > &plns)
Static method to retrieve every plane included in a vector of objects.
TObject3D(const TSegment3D &s)
Constructor from segment.
static void getLines(const std::vector< TObject3D > &objs, std::vector< TLine3D > &lins)
Static method to retrieve every line included in a vector of objects.
bool getPoint(TPoint3D &p) const
Gets the content as a point, returning false if the type is not adequate.
unsigned char type
Object type identifier.
TObject3D(const TPolygon3D &p)
Constructor from polygon.
bool isPlane() const
Checks whether content is a plane.
TObject3D()
Empty constructor.
static void getPlanes(const std::vector< TObject3D > &objs, std::vector< TPlane > &plns, std::vector< TObject3D > &remainder)
Static method to retrieve every plane included in a vector of objects, returning the remaining object...
bool isPoint() const
Checks whether content is a point.
TObject3D(const TObject3D &obj)
Constructs from another object.
void generate2DObject(TObject2D &obj) const
Projects into 2D space.
static void getPolygons(const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys, std::vector< TObject3D > &remainder)
Static method to retrieve every polygon included in a vector of objects, returning the remaining obje...
bool getPolygon(TPolygon3D &p) const
Gets the content as a polygon, returning false if the type is not adequate.
3D Plane, represented by its equation
TPlane(const TLine3D &r1, const TLine3D &r2)
Gets a plane which contains the two lines.
double distance(const TLine3D &line) const
Distance to 3D line.
TPlane()
Fast default constructor.
void getAsPose3D(mrpt::poses::CPose3D &outPose) const
Gets a pose whose XY plane corresponds to this plane.
double distance(const TPoint3D &point) const
Distance to 3D point.
double evaluatePoint(const TPoint3D &point) const
Evaluate a point in the plane's equation.
bool contains(const TSegment3D &segment) const
Check whether a segment is fully contained into the plane.
void getNormalVector(double(&vec)[3]) const
Get plane's normal vector.
bool contains(const TLine3D &line) const
Check whether a line is fully contained into the plane.
void getUnitaryNormalVector(double(&vec)[3])
Unitarize, then get normal vector.
void getAsPose3D(mrpt::poses::CPose3D &outPose)
Gets a pose whose XY plane corresponds to this plane.
TPlane(const TPoint3D &p1, const TPoint3D &p2, const TPoint3D &p3)
Gets a plane which contains these three points.
bool contains(const TPoint3D &point) const
Check whether a point is contained into the plane.
void getAsPose3DForcingOrigin(const TPoint3D &newOrigin, mrpt::poses::CPose3D &pose)
Gets a pose whose XY plane corresponds to this, forcing an exact point as its spatial coordinates.
TPlane(const double(&vec)[4])
Constructor from an array of coefficients.
void getAsPose3DForcingOrigin(const TPoint3D &newOrigin, mrpt::poses::CPose3D &pose) const
Gets a pose whose XY plane corresponds to this, forcing an exact point as its spatial coordinates.
TPlane(const TPoint3D &p1, const TLine3D &r2)
Gets a plane which contains this point and this line.
TPlane(double A, double B, double C, double D)
Constructor from plane coefficients.
void unitarize()
Unitarize normal vector.
double & operator[](size_t i)
Coordinate access using operator[].
TPoint2D operator*(double d) const
TPoint2D(const mrpt::utils::TPixelCoordf &p)
Implicit transformation constructor from TPixelCoordf.
const double & operator[](size_t i) const
Coordinate access using operator[].
TPoint2D(const mrpt::poses::CPoseOrPoint< DERIVEDCLASS > &p)
Constructor from CPoseOrPoint, perhaps losing 3D information.
TPoint2D(const TPose3D &p)
Constructor from TPose3D, discarding z and the angular coordinates.
TPoint2D(double xx, double yy)
Constructor from coordinates.
TPoint2D & operator*=(double d)
TPoint2D(const TPoint3D &p)
Constructor from TPoint3D, discarding z.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04]" )
bool operator<(const TPoint2D &p) const
TPoint2D & operator/=(double d)
TPoint2D operator+(const TPoint2D &p) const
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04]" )
void getAsVector(std::vector< double > &v) const
Transformation into vector.
TPoint2D(const TPose2D &p)
Constructor from TPose2D, discarding phi.
TPoint2D(const mrpt::poses::CPoint2D &p)
Implicit constructor from mrpt::poses::CPoint2D
std::string asString() const
TPoint2D operator-(const TPoint2D &p) const
TPoint2D & operator-=(const TPoint2D &p)
double norm() const
Point norm.
TPoint2D & operator+=(const TPoint2D &p)
TPoint2D operator/(double d) const
TPoint2D()
Default fast constructor.
TPoint3D & operator-=(const TPoint3D &p)
Difference between points.
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04 -0....
double distanceTo(const TPoint3D &p) const
Point-to-point distance.
TPoint3D(const TPoint2D &p)
Implicit constructor from TPoint2D.
std::string asString() const
TPoint3D(double xx, double yy, double zz)
Constructor from coordinates.
TPoint3D operator+(const TPoint3D &p) const
Points addition.
double z
X,Y,Z coordinates.
TPoint3D & operator*=(const double f)
Point scale.
double & operator[](size_t i)
Coordinate access using operator[].
TPoint3D(const TPose2D &p)
Constructor from TPose2D, losing information.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
TPoint3D(const TPoint3Df &p)
Explicit constructor from coordinates.
TPoint3D(const mrpt::poses::CPose3D &p)
Constructor from heavyweight 3D pose.
TPoint3D operator/(double d) const
const double & operator[](size_t i) const
Coordinate access using operator[].
double norm() const
Point norm.
TPoint3D(const TPose3D &p)
Constructor from TPose3D, losing information.
TPoint3D operator*(double d) const
TPoint3D()
Default fast constructor.
void getAsVector(VECTORLIKE &v) const
Transformation into vector.
double sqrDistanceTo(const TPoint3D &p) const
Point-to-point distance, squared.
TPoint3D operator-(const TPoint3D &p) const
Points substraction.
TPoint3D & operator+=(const TPoint3D &p)
Translation.
TPoint3D(const mrpt::poses::CPoint3D &p)
Implicit constructor from heavyweight type.
bool operator<(const TPoint3D &p) const
Lightweight 3D point (float version).
const float & operator[](size_t i) const
Coordinate access using operator[].
float & operator[](size_t i)
Coordinate access using operator[].
TPoint3Df(const float xx, const float yy, const float zz)
XYZ point (double) + Intensity(u8)
TPointXYZIu8(double x, double y, double z, uint8_t intensity_val)
XYZ point (double) + RGB(u8)
TPointXYZRGBu8(double x, double y, double z, uint8_t R_val, uint8_t G_val, uint8_t B_val)
XYZ point (float) + Intensity(u8)
TPointXYZfIu8(float x, float y, float z, uint8_t intensity_val)
XYZ point (float) + RGB(u8)
TPointXYZfRGBu8(float x, float y, float z, uint8_t R_val, uint8_t G_val, uint8_t B_val)
TPose2D(const TPose3D &p)
Constructor from TPose3D, losing information.
double phi
Orientation (rads)
const double & operator[](size_t i) const
Coordinate access using operator[].
std::string asString() const
TPose2D(double xx, double yy, double pphi)
Constructor from coordinates.
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[x y yaw]", yaw in degrees)
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -45....
TPose2D()
Default fast constructor.
double & operator[](size_t i)
Coordinate access using operator[].
TPose2D(const TPoint3D &p)
Constructor from TPoint3D, losing information.
void getAsVector(std::vector< double > &v) const
Transformation into vector.
TPose2D(const mrpt::poses::CPose2D &p)
Implicit constructor from heavyweight type.
TPose2D(const TPoint2D &p)
Implicit constructor from TPoint2D.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
TPose3D(const TPose2D &p)
Implicit constructor from TPose2D.
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[x y z yaw pitch roll]",...
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
TPose3D(double _x, double _y, double _z, double _yaw, double _pitch, double _roll)
Constructor from coordinates.
TPose3D(const TPoint3D &p)
Implicit constructor from TPoint3D.
TPose3D(const mrpt::poses::CPose3D &p)
Implicit constructor from heavyweight type.
void getAsVector(std::vector< double > &v) const
Gets the pose as a vector of doubles.
double roll
Roll coordinate (rotation angle over X coordinate).
std::string asString() const
double norm() const
Pose's spatial coordinates norm.
TPose3D()
Default fast constructor.
double pitch
Pitch coordinate (rotation angle over Y axis).
const double & operator[](size_t i) const
Coordinate access using operator[].
double & operator[](size_t i)
Coordinate access using operator[].
double yaw
Yaw coordinate (rotation angle over Z axis).
TPose3D(const TPoint2D &p)
Implicit constructor from TPoint2D.
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
std::string asString() const
void getAsVector(std::vector< double > &v) const
Gets the pose as a vector of doubles.
double & operator[](size_t i)
Coordinate access using operator[].
TPose3DQuat(double _x, double _y, double _z, double _qr, double _qx, double _qy, double _qz)
Constructor from coordinates.
TPose3DQuat(const mrpt::poses::CPose3DQuat &p)
Constructor from a CPose3DQuat.
const double & operator[](size_t i) const
Coordinate access using operator[].
void asString(std::string &s) const
Returns a human-readable textual representation of the object as "[x y z qr qx qy qz]".
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
double norm() const
Pose's spatial coordinates norm.
TPose3DQuat()
Default fast constructor.
2D segment, consisting of two points.
bool contains(const TPoint2D &point) const
Check whether a point is inside a segment.
TPoint2D point2
Destiny point.
TSegment2D(const TPoint2D &p1, const TPoint2D &p2)
Constructor from both points.
double signedDistance(const TPoint2D &point) const
Distance with sign to point (sign indicates which side the point is).
const TPoint2D & operator[](size_t i) const
Access to points using operator[0-1].
bool operator<(const TSegment2D &s) const
TSegment2D()
Fast default constructor.
TSegment2D(const TSegment3D &s)
Explicit constructor from 3D object, discarding the z.
TPoint2D point1
Origin point.
TPoint2D & operator[](size_t i)
Access to points using operator[0-1].
void getCenter(TPoint2D &p) const
Segment's central point.
void generate3DObject(TSegment3D &s) const
Project into 3D space, setting the z to 0.
double length() const
Segment length.
double distance(const TPoint2D &point) const
Distance to point.
3D segment, consisting of two points.
TPoint3D & operator[](size_t i)
Access to points using operator[0-1].
const TPoint3D & operator[](size_t i) const
Access to points using operator[0-1].
double distance(const TPoint3D &point) const
Distance to point.
TPoint3D point1
Origin point.
void getCenter(TPoint3D &p) const
Segment's central point.
double length() const
Segment length.
TPoint3D point2
Destiny point.
double distance(const TSegment3D &segment) const
Distance to another segment.
bool operator<(const TSegment3D &s) const
TSegment3D()
Fast default constructor.
bool contains(const TPoint3D &point) const
Check whether a point is inside the segment.
TSegment3D(const TPoint3D &p1, const TPoint3D &p2)
Constructor from both points.
TSegment3D(const TSegment2D &s)
Constructor from 2D object.
void generate2DObject(TSegment2D &s) const
Projection into 2D space, discarding the z.
A pair (x,y) of pixel coordinates (subpixel resolution).