25 namespace mrpt {
namespace math {
47 if (
x<
p.x)
return true;
48 else if (
x>
p.x)
return false;
54 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
56 x = m.get_unsafe(0,0);
57 y = m.get_unsafe(0,1);
70 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
72 x = m.get_unsafe(0,0);
73 y = m.get_unsafe(0,1);
78 const double A_cosphi = cos(this->phi), A_sinphi = sin(this->phi);
80 const double new_x = this->
x +
b.x * A_cosphi -
b.y * A_sinphi;
81 const double new_y = this->
y +
b.x * A_cosphi +
b.y * A_sinphi;
89 const double B_cosphi = cos(
b.phi), B_sinphi = sin(
b.phi);
91 const double new_x = (this->
x -
b.x) * B_cosphi + (this->
y -
b.y) * B_sinphi;
92 const double new_y = -(this->
x -
b.x) * B_sinphi + (this->
y -
b.y) * B_cosphi;
105 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
107 vx = m.get_unsafe(0,0);
108 vy = m.get_unsafe(0,1);
114 const double nvx =
vx * cos(ang) -
vy * sin(ang);
115 const double nvy =
vx * sin(ang) +
vy * cos(ang);
138 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
140 for (
int i=0;i<3;i++) (*
this)[i] = m.get_unsafe(0,i);
141 for (
int i=0;i<3;i++) (*
this)[3+i] =
DEG2RAD(m.get_unsafe(0,3+i));
149 vx=
R(0,0)*
t.vx+
R(0,1)*
t.vy+
R(0,2)*
t.vz;
150 vy=
R(1,0)*
t.vx+
R(1,1)*
t.vy+
R(1,2)*
t.vz;
151 vz=
R(2,0)*
t.vx+
R(2,1)*
t.vy+
R(2,2)*
t.vz;
153 wx=
R(0,0)*
t.wx+
R(0,1)*
t.wy+
R(0,2)*
t.wz;
154 wy=
R(1,0)*
t.wx+
R(1,1)*
t.wy+
R(1,2)*
t.wz;
155 wz=
R(2,0)*
t.wx+
R(2,1)*
t.wy+
R(2,2)*
t.wz;
162 return !(*
this == o);
171 if (
x<
p.x)
return true;
172 else if (
x>
p.x)
return false;
173 else if (
y<
p.y)
return true;
174 else if (
y>
p.y)
return false;
180 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
182 x = m.get_unsafe(0,0);
183 y = m.get_unsafe(0,1);
184 z = m.get_unsafe(0,2);
197 const double cy = cos(
yaw*0.5), sy = sin(
yaw*0.5);
198 const double cp = cos(
pitch*0.5),sp = sin(
pitch*0.5);
199 const double cr = cos(
roll*0.5), sr = sin(
roll*0.5);
201 const double ccc = cr*cp*cy;
202 const double ccs = cr*cp*sy;
203 const double css = cr*sp*sy;
204 const double sss = sr*sp*sy;
205 const double scc = sr*cp*cy;
206 const double ssc = sr*sp*cy;
207 const double csc = cr*sp*cy;
208 const double scs = sr*cp*sy;
221 -0.5*
q[3], 0.5*(-csc + scs), -0.5*
q[1],
222 -0.5*
q[2], 0.5*(-ssc - ccs), 0.5*
q[0],
223 0.5*
q[1], 0.5*(ccc - sss), 0.5*
q[3],
224 0.5*
q[0], 0.5*(-css - scc), -0.5*
q[2]
232 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
248 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
250 for (
size_t i=0;i<m.getColCount();i++)
251 (*
this)[i] = m.get_unsafe(0,i);
288 const double d3 =
length();
289 const double ds1 =
square(d1);
290 const double ds2 =
square(d2);
291 const double ds3 =
square(d3);
292 if ( ds1 > (ds2 + ds3) || ds2 > (ds1 + ds3) )
306 if (
point1==
point2)
throw std::logic_error(
"Segment is normal to projection plane");
310 if (
point1<
s.point1)
return true;
311 else if (
s.point1<
point1)
return false;
322 Eigen::Vector3d u,
v,
w;
334 double D =
a*
c -
b*
b;
335 double sc, sN, sD = D;
336 double tc, tN, tD = D;
339 if (D < 0.00000001) {
377 else if ((-d +
b) >
a)
385 sc = (fabs(sN) < 0.00000001 ? 0.0 : sN / sD);
386 tc = (fabs(tN) < 0.00000001 ? 0.0 : tN / tD);
399 if (
point1<
s.point1)
return true;
400 else if (
s.point1<
point1)
return false;
422 for (
size_t i=0;i<3;i++)
coefs[i]/=
s;
444 if (!
contains(origin))
throw std::logic_error(
"Base point is not contained in the line");
450 if (p1==p2)
throw logic_error(
"Both points are the same");
456 coefs[0]=
s.point2.y-
s.point1.y;
457 coefs[1]=
s.point1.x-
s.point2.x;
458 coefs[2]=
s.point2.x*
s.point1.y-
s.point2.y*
s.point1.x;
483 double dv=0,d2=0,
v2=0;
484 for (
size_t i=0;i<3;i++) {
489 return sqrt(d2-(dv*dv)/
v2);
492 double s=sqrt(squareNorm<3,double>(
director));
524 return dotProduct<3,double>(
coefs,point)+
coefs[3];
546 double s=sqrt(squareNorm<3,double>(
coefs));
547 for (
size_t i=0;i<4;i++)
coefs[i]/=
s;
563 if (!
contains(newOrigin))
throw std::logic_error(
"Base point is not in the plane.");
568 for (
size_t i=0;i<3;i++) AXIS.set_unsafe(i,3,newOrigin[i]);
572 double dx1=p2.
x-p1.
x;
573 double dy1=p2.
y-p1.
y;
574 double dz1=p2.
z-p1.
z;
575 double dx2=p3.
x-p1.
x;
576 double dy2=p3.
y-p1.
y;
577 double dz2=p3.
z-p1.
z;
578 coefs[0]=dy1*dz2-dy2*dz1;
579 coefs[1]=dz1*dx2-dz2*dx1;
580 coefs[2]=dx1*dy2-dx2*dy1;
599 if (r1.
contains(r2.
pBase))
throw std::logic_error(
"Lines are the same");
602 for (
size_t i=0;i<3;i++) d[i]=r1.
pBase[i]-r2.
pBase[i];
610 size_t N=poly.size();
612 std::vector<size_t> unused;
618 for (
size_t i=0;i<unused.size()-1;i++) {
619 size_t last=unused[i+1];
620 for (
size_t j=unused[i]+1-diff;j<last-diff;j++) poly[j]=poly[j+diff];
622 poly.resize(N+1-unused.size());
626 size_t N=poly.size();
628 std::vector<size_t> rep;
633 for (
size_t i=0;i<rep.size()-1;i++) {
634 size_t last=rep[i+1];
635 for (
size_t j=rep[i]+1-diff;j<last-diff;j++) poly[j]=poly[j+diff];
637 poly.resize(N+1-rep.size());
643 std::vector<TSegment2D> sgs;
649 double distance = std::numeric_limits<double>::max();
653 double d = (*it).distance(point);
662 ASSERTMSG_(!this->
empty(),
"getBoundingBox() called on an empty polygon!");
663 min_coords.
x = min_coords.
y = std::numeric_limits<double>::max();
664 max_coords.
x = max_coords.
y = -std::numeric_limits<double>::max();
665 for (
size_t i=0;i<
size();i++)
682 return ( (P1.
x - P0.
x) * (P2.
y - P0.
y) - (P2.
x - P0.
x) * (P1.
y - P0.
y) );
690 const size_t n = this->
size();
691 for (
size_t i=0; i<
n; i++)
693 if ((*
this)[i].
y <= P.
y)
696 if ((*
this)[(i+1) %
n].
y > P.
y)
697 if (
isLeft( (*
this)[i], (*
this)[(i+1)%
n], P) > 0)
703 if ((*
this)[(i+1)%
n].
y <= P.
y)
704 if (
isLeft( (*
this)[i], (*
this)[(i+1)%
n], P) < 0)
715 for (
size_t i=0;i<N-1;i++)
v[i]=
TSegment2D(
operator[](i),
operator[](i+1));
723 template<
class T,
int N>
728 for (
size_t i=0;i<N;i++)
object[i]=0.0;
731 for (
size_t i=0;i<N;i++)
object[i]+=o[i];
742 if (N<=3)
return true;
743 vector<TSegment2D> sgms;
745 for (
size_t i=0;i<N;i++) {
748 for (
size_t j=0;j<N;j++) {
751 else if (!
s)
s=(d>0)?1:-1;
752 else if (
s!=((d>0)?1:-1))
return false;
768 for (
size_t i=0;i<N;i++) {
778 for (
size_t i=0;i<N;i++)
operator[](i)=
TPoint2D(
p[i]);
781 if (numEdges<3||abs(radius)<
geometryEpsilon)
throw std::logic_error(
"Invalid arguments for regular polygon creations");
782 poly.resize(numEdges);
783 for (
size_t i=0;i<numEdges;i++) {
784 double angle=i*
M_PI*2/numEdges;
785 poly[i]=
TPoint2D(radius*cos(angle),radius*sin(angle));
790 for (
size_t i=0;i<numEdges;i++) poly[i]=pose+poly[i];
795 if (!
getPlane(pl))
throw std::logic_error(
"Polygon does not conform a plane");
803 return sqrt(newPoint.
z*newPoint.
z+distance2D*distance2D);
810 if (!
getPlane(plane))
throw std::logic_error(
"Polygon does not conform a plane");
825 for (
size_t i=0;i<N-1;i++)
v[i]=
TSegment3D(
operator[](i),
operator[](i+1));
854 for (
size_t i=0;i<N;i++)
operator[](i)=
p[i];
857 if (numEdges<3||abs(radius)<
geometryEpsilon)
throw std::logic_error(
"Invalid arguments for regular polygon creations");
858 poly.resize(numEdges);
859 for (
size_t i=0;i<numEdges;i++) {
860 double angle=i*2*
M_PI/numEdges;
861 poly[i]=
TPoint3D(radius*cos(angle),radius*sin(angle),0);
866 for (
size_t i=0;i<numEdges;i++) pose.
composePoint(poly[i][0],poly[i][1],poly[i][2],poly[i][0],poly[i][1],poly[i][2]);
900 void TObject2D::getPoints(
const std::vector<TObject2D> &objs,std::vector<TPoint2D> &pnts,std::vector<TObject2D> &remainder) {
902 else remainder.push_back(*it);
904 void TObject2D::getSegments(
const std::vector<TObject2D> &objs,std::vector<TSegment2D> &sgms,std::vector<TObject2D> &remainder) {
906 else remainder.push_back(*it);
908 void TObject2D::getLines(
const std::vector<TObject2D> &objs,std::vector<TLine2D> &lins,std::vector<TObject2D> &remainder) {
910 else remainder.push_back(*it);
912 void TObject2D::getPolygons(
const std::vector<TObject2D> &objs,std::vector<TPolygon2D> &polys,vector<TObject2D> &remainder) {
914 else remainder.push_back(*it);
931 void TObject3D::getPoints(
const std::vector<TObject3D> &objs,std::vector<TPoint3D> &pnts,std::vector<TObject3D> &remainder) {
933 else remainder.push_back(*it);
935 void TObject3D::getSegments(
const std::vector<TObject3D> &objs,std::vector<TSegment3D> &sgms,std::vector<TObject3D> &remainder) {
937 else remainder.push_back(*it);
939 void TObject3D::getLines(
const std::vector<TObject3D> &objs,std::vector<TLine3D> &lins,std::vector<TObject3D> &remainder) {
941 else remainder.push_back(*it);
943 void TObject3D::getPlanes(
const std::vector<TObject3D> &objs,std::vector<TPlane> &plns,std::vector<TObject3D> &remainder) {
945 else remainder.push_back(*it);
947 void TObject3D::getPolygons(
const std::vector<TObject3D> &objs,std::vector<TPolygon3D> &polys,vector<TObject3D> &remainder) {
949 else remainder.push_back(*it);
965 in >> o.
x >> o.
y >> o.
z;
970 out << o.
x << o.
y << o.
z;
981 out << o.
x << o.
y << o.
phi;
987 for (
unsigned int i=0;i<o.
size();i++)
in >> o[i];
992 for (
unsigned int i=0;i<o.
size();i++) out << o[i];
998 for (
unsigned int i=0;i<o.
size();i++)
in >> o[i];
1003 for (
unsigned int i=0;i<o.
size();i++) out << o[i];
1028 switch (
static_cast<unsigned char>(
type)) {
1053 throw std::logic_error(
"Unknown TObject2D type found while reading stream");
1058 out<<static_cast<uint16_t>(o.
getType());
1087 switch (
static_cast<unsigned char>(
type)) {
1117 throw std::logic_error(
"Unknown TObject3D type found while reading stream");
1122 out<<static_cast<uint16_t>(o.
getType());
void loadFromArray(const T *vals)
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ,...
void operator()(const T &o)
2D polygon, inheriting from std::vector<TPoint2D>.
TPolygon2D()
Default constructor
double distance(const TPoint2D &point) const
Distance to a point (always >=0)
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)
Static method to create a regular polygon, given 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.
void removeRepeatedVertices()
Erase repeated vertices.
bool contains(const TPoint2D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge). This works for concave...
void getPlotData(std::vector< double > &x, std::vector< double > &y) const
Gets plot data, ready to use on a 2D plot.
void getBoundingBox(TPoint2D &min_coords, TPoint2D &max_coords) const
Get polygon bounding box.
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. Returns true if there doesn't exist a plane in which the polygon c...
bool contains(const TPoint3D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge). This works for concave...
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D &poly)
Static method to create a regular polygon, given its size and radius.
void removeRedundantVertices()
Erase every redundant vertex, thus saving space.
double distance(const TPoint3D &point) const
Distance to point (always >=0)
void removeRepeatedVertices()
Remove polygon's repeated vertices.
bool getPlane(TPlane &p) const
Gets a plane which contains the polygon. Returns false if the polygon is skew and cannot be fit insid...
void getCenter(TPoint3D &p) const
Get polygon's central point.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
A class used to store a 2D point.
A class used to store a 3D point.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
const double & phi() const
Get the phi angle of the 2D pose (in radians)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=NULL, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
double x() const
Common members of all points & poses classes.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
EIGEN_STRONG_INLINE bool empty() const
const Scalar * const_iterator
EIGEN_STRONG_INLINE iterator begin()
GLsizei GLsizei GLuint * obj
GLubyte GLubyte GLubyte GLubyte w
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLuint GLuint GLsizei GLenum type
GLfloat GLfloat GLfloat v2
GLdouble GLdouble GLdouble r
GLubyte GLubyte GLubyte a
GLsizei const GLchar ** string
GLdouble GLdouble GLdouble GLdouble q
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
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.
double BASE_IMPEXP geometryEpsilon
Global epsilon to overcome small precision errors (Default=1e-5)
struct BASE_IMPEXP TSegment3D
struct BASE_IMPEXP TObject3D
double BASE_IMPEXP distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
const unsigned char GEOMETRIC_TYPE_UNDEFINED
Object type identifier for empty TObject2D or TObject3D.
void project3D(const TPoint3D &point, const mrpt::poses::CPose3D &newXYpose, TPoint3D &newPoint)
Uses the given pose 3D to project a point into a new base.
std::ostream BASE_IMPEXP & operator<<(std::ostream &o, const TPoint2D &p)
const unsigned char GEOMETRIC_TYPE_POLYGON
Object type identifier for TPolygon2D or TPolygon3D.
void BASE_IMPEXP getPrismBounds(const std::vector< TPoint3D > &poly, TPoint3D &pMin, TPoint3D &pMax)
Gets the prism bounds of a 3D polygon or set of 3D points.
const unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
struct BASE_IMPEXP TLine3D
class BASE_IMPEXP TPolygon3D
bool BASE_IMPEXP conformAPlane(const std::vector< TPoint3D > &points)
Checks whether this polygon or set of points acceptably fits a plane.
void BASE_IMPEXP generateAxisBaseFromDirectionAndAxis(const double(&vec)[3], char coord, CMatrixDouble &matrix)
Creates a homogeneus matrix (4x4) such that the coordinate given (0 for x, 1 for y,...
void crossProduct3D(const T &v0, const U &v1, V &vOut)
Computes the cross product of two 3D vectors, returning a vector normal to both.
double BASE_IMPEXP getRegressionPlane(const std::vector< TPoint3D > &points, TPlane &plane)
Using eigenvalues, gets the best fitting plane for a set of 3D points.
double BASE_IMPEXP getAngle(const TPlane &p1, const TPlane &p2)
Computes the angle between two planes.
const unsigned char GEOMETRIC_TYPE_PLANE
Object type identifier for TPlane.
#define THROW_EXCEPTION(msg)
#define ASSERTMSG_(f, __ERROR_MSG)
TPoint2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint2D &p)
Convert a pose into a light-weight structure (functional form, needed for forward declarations)
size_t size(const MATRIXLIKE &m, const int dim)
void removeRepVertices(T &poly)
void removeUnusedVertices(T &poly)
BASE_IMPEXP ::mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, CMatrixPtr &pObj)
double isLeft(const mrpt::math::TPoint2D &P0, const mrpt::math::TPoint2D &P1, const mrpt::math::TPoint2D &P2)
T square(const T x)
Inline function for the square of a number.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value.
double RAD2DEG(const double x)
Radians to degrees.
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn't exist already.
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value.
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.
This file implements several operations that operate element-wise on individual or pairs of container...
unsigned __int16 uint16_t
2D line without bounds, represented by its equation .
TLine2D()
Fast default constructor.
double evaluatePoint(const TPoint2D &point) const
Evaluate point in the line's equation.
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.
double signedDistance(const TPoint2D &point) const
Distance with sign from a given point (sign indicates side).
double coefs[3]
Line coefficients, stored as an array: .
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.
3D line, represented by a base point and a director vector.
TLine3D()
Fast default constructor.
double distance(const TPoint3D &point) const
Distance between the line and a point.
double director[3]
Director vector.
void unitarize()
Unitarize director vector.
bool contains(const TPoint3D &point) const
Check whether a point is inside the line.
TPoint3D pBase
Base point.
Standard type for storing any lightweight 2D type.
void generate3DObject(TObject3D &obj) const
Project into 3D space.
static void getLines(const std::vector< TObject2D > &objs, std::vector< TLine2D > &lins)
Static method to retrieve all the lines in a vector of 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.
unsigned char getType() const
Gets content type.
bool getSegment(TSegment2D &s) const
Gets the content as a segment, returning false if the type is inadequate.
bool getPolygon(TPolygon2D &p) const
Gets the content as a polygon, returning false if the type is inadequate.
bool getPoint(TPoint2D &p) const
Gets the content as a point, returning false if the type is inadequate.
static void getSegments(const std::vector< TObject2D > &objs, std::vector< TSegment2D > &sgms)
Static method to retrieve all the segments in a vector of TObject2D.
static void getPolygons(const std::vector< TObject2D > &objs, std::vector< TPolygon2D > &polys)
Static method to retrieve all the polygons in a vector of TObject2D.
Standard object for storing any 3D lightweight 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 getPlane(TPlane &p) const
Gets the content as a plane, returning false if the type is not adequate.
unsigned char getType() const
Gets object type.
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 getSegment(TSegment3D &s) const
Gets the content as a segment, returning false if the type is not adequate.
bool getLine(TLine3D &r) const
Gets the content as a line, returning false if the type is not adequate.
static void getLines(const std::vector< TObject3D > &objs, std::vector< TLine3D > &lins)
Static method to retrieve every line included in a vector of objects.
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 getPoint(TPoint3D &p) const
Gets the content as a point, returning false if the type is not adequate.
static void getPlanes(const std::vector< TObject3D > &objs, std::vector< TPlane > &plns)
Static method to retrieve every plane included in a vector of objects.
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()
Fast default constructor.
double distance(const TPoint3D &point) const
Distance to 3D point.
double evaluatePoint(const TPoint3D &point) const
Evaluate a point in the plane's equation.
void getNormalVector(double(&vec)[3]) const
Get plane's normal vector.
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.
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.
double coefs[4]
Plane coefficients, stored as an array: .
void unitarize()
Unitarize normal vector.
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()
Default fast constructor.
double z
X,Y,Z coordinates.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
TPoint3D()
Default fast constructor.
void getAsVector(VECTORLIKE &v) const
Transformation into vector.
bool operator<(const TPoint3D &p) const
double phi
Orientation (rads)
mrpt::math::TPose2D operator+(const mrpt::math::TPose2D &b) const
Operator "oplus" pose composition: "ret=this \oplus b".
std::string asString() const
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.
mrpt::math::TPose2D operator-(const mrpt::math::TPose2D &b) const
Operator "ominus" pose composition: "ret=this \ominus b".
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
void getAsQuaternion(mrpt::math::CQuaternion< double > &q, mrpt::math::CMatrixFixedNumeric< double, 4, 3 > *out_dq_dr=NULL) const
Returns the quaternion associated to the rotation of this object (NOTE: XYZ translation is ignored)
double roll
Roll coordinate (rotation angle over X coordinate).
std::string asString() const
TPose3D()
Default fast constructor.
double pitch
Pitch coordinate (rotation angle over Y axis).
double yaw
Yaw coordinate (rotation angle over Z axis).
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
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.
double signedDistance(const TPoint2D &point) const
Distance with sign to point (sign indicates which side the point is).
bool operator<(const TSegment2D &s) const
TSegment2D()
Fast default constructor.
TPoint2D point1
Origin 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.
double distance(const TPoint3D &point) const
Distance to point.
TPoint3D point1
Origin point.
double length() const
Segment length.
TPoint3D point2
Destiny point.
bool operator<(const TSegment3D &s) const
bool contains(const TPoint3D &point) const
Check whether a point is inside the segment.
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
std::string asString() const
void rotate(const double ang)
Transform the (vx,vy) components for a counterclockwise rotation of ang radians.
bool operator!=(const TTwist2D &o) const
mrpt::math::TPose2D operator*(const double dt) const
Returns the pose increment of multiplying each twist component times "dt" seconds.
double vy
Velocity components: X,Y (m/s)
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -45....
bool operator==(const TTwist2D &o) const
double omega
Angular velocity (rad/s)
3D twist: 3D velocity vector (vx,vy,vz) + angular velocity (wx,wy,wz)
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[vx vy vz wx wy wz]" )
std::string asString() const
double vz
Velocity components: X,Y (m/s)
bool operator!=(const TTwist3D &o) const
void rotate(const mrpt::poses::CPose3D &rot)
Transform all 6 components for a change of reference frame from "A" to another frame "B" whose rotati...
bool operator==(const TTwist3D &o) const
double wz
Angular velocity (rad/s)