63 if (!m.fromMatlabStringFormat(
s))
67 "Wrong size of vector in ::fromString");
68 x = m.get_unsafe(0, 0);
69 y = m.get_unsafe(0, 1);
76 :
x(
p.
x()),
y(
p.
y()), phi(
p.phi())
86 if (!m.fromMatlabStringFormat(
s))
90 "Wrong size of vector in ::fromString");
91 x = m.get_unsafe(0, 0);
92 y = m.get_unsafe(0, 1);
98 const double A_cosphi = cos(this->phi), A_sinphi = sin(this->phi);
100 const double new_x = this->
x +
b.x * A_cosphi -
b.y * A_sinphi;
101 const double new_y = this->
y +
b.x * A_cosphi +
b.y * A_sinphi;
110 const double B_cosphi = cos(
b.phi), B_sinphi = sin(
b.phi);
113 (this->
x -
b.x) * B_cosphi + (this->
y -
b.y) * B_sinphi;
115 -(this->
x -
b.x) * B_sinphi + (this->
y -
b.y) * B_cosphi;
129 if (!m.fromMatlabStringFormat(
s))
133 "Wrong size of vector in ::fromString");
134 vx = m.get_unsafe(0, 0);
135 vy = m.get_unsafe(0, 1);
142 const double nvx =
vx * cos(ang) -
vy * sin(ang);
143 const double nvy =
vx * sin(ang) +
vy * cos(ang);
167 if (!m.fromMatlabStringFormat(
s))
171 "Wrong size of vector in ::fromString");
172 for (
int i = 0; i < 3; i++) (*
this)[i] = m.get_unsafe(0, i);
173 for (
int i = 0; i < 3; i++)
174 (*
this)[3 + i] =
DEG2RAD(m.get_unsafe(0, 3 + i));
183 vx =
R(0, 0) *
t.vx +
R(0, 1) *
t.vy +
R(0, 2) *
t.vz;
184 vy =
R(1, 0) *
t.vx +
R(1, 1) *
t.vy +
R(1, 2) *
t.vz;
185 vz =
R(2, 0) *
t.vx +
R(2, 1) *
t.vy +
R(2, 2) *
t.vz;
187 wx =
R(0, 0) *
t.wx +
R(0, 1) *
t.wy +
R(0, 2) *
t.wz;
188 wy =
R(1, 0) *
t.wx +
R(1, 1) *
t.wy +
R(1, 2) *
t.wz;
189 wz =
R(2, 0) *
t.wx +
R(2, 1) *
t.wy +
R(2, 2) *
t.wz;
223 if (!m.fromMatlabStringFormat(
s))
227 "Wrong size of vector in ::fromString");
228 x = m.get_unsafe(0, 0);
229 y = m.get_unsafe(0, 1);
230 z = m.get_unsafe(0, 2);
266 const double cy = cos(
yaw * 0.5), sy = sin(
yaw * 0.5);
267 const double cp = cos(
pitch * 0.5), sp = sin(
pitch * 0.5);
268 const double cr = cos(
roll * 0.5), sr = sin(
roll * 0.5);
270 const double ccc = cr * cp * cy;
271 const double ccs = cr * cp * sy;
272 const double css = cr * sp * sy;
273 const double sss = sr * sp * sy;
274 const double scc = sr * cp * cy;
275 const double ssc = sr * sp * cy;
276 const double csc = cr * sp * cy;
277 const double scs = sr * cp * sy;
290 alignas(16)
const double nums[4 * 3] = {
291 -0.5 *
q[3], 0.5 * (-csc + scs), -0.5 *
q[1],
292 -0.5 *
q[2], 0.5 * (-ssc - ccs), 0.5 *
q[0],
293 0.5 *
q[1], 0.5 * (ccc - sss), 0.5 *
q[3],
294 0.5 *
q[0], 0.5 * (-css - scc), -0.5 *
q[2]};
301 if (!m.fromMatlabStringFormat(
s))
305 "Wrong size of vector in ::fromString");
306 x = m.get_unsafe(0, 0);
307 y = m.get_unsafe(0, 1);
308 z = m.get_unsafe(0, 2);
327 if (!m.fromMatlabStringFormat(
s))
331 "Wrong size of vector in ::fromString");
332 for (
size_t i = 0; i < m.getColCount(); i++)
333 (*
this)[i] = m.get_unsafe(0, i);
360 return in >>
s.point1 >>
s.point2;
364 return out <<
s.point1 <<
s.point2;
378 return in >>
s.point1 >>
s.point2;
383 return out <<
s.point1 <<
s.point2;
398 return in >>
p.coefs[0] >>
p.coefs[1] >>
p.coefs[2] >>
p.coefs[3];
403 return out <<
p.coefs[0] <<
p.coefs[1] <<
p.coefs[2] <<
p.coefs[3];
422 const double d3 =
length();
423 const double ds1 =
square(d1);
424 const double ds2 =
square(d2);
425 const double ds3 =
square(d3);
426 if (ds1 > (ds2 + ds3) || ds2 > (ds1 + ds3))
447 throw std::logic_error(
"Segment is normal to projection plane");
469 Eigen::Vector3d u,
v,
w;
481 double D =
a *
c -
b *
b;
482 double sc, sN, sD = D;
483 double tc, tN, tD = D;
495 sN = (
b * e -
c * d);
496 tN = (
a * e -
b * d);
531 else if ((-d +
b) >
a)
540 sc = (fabs(sN) < 0.00000001 ? 0.0 : sN / sD);
541 tc = (fabs(tN) < 0.00000001 ? 0.0 : tN / tD);
585 vector[0] =
coefs[0];
586 vector[1] =
coefs[1];
591 for (
size_t i = 0; i < 3; i++)
coefs[i] /=
s;
595 vector[0] = -
coefs[1];
596 vector[1] =
coefs[0];
620 throw std::logic_error(
"Base point is not contained in the line");
627 if (p1 == p2)
throw logic_error(
"Both points are the same");
634 coefs[0] =
s.point2.y -
s.point1.y;
635 coefs[1] =
s.point1.x -
s.point2.x;
636 coefs[2] =
s.point2.x *
s.point1.y -
s.point2.y *
s.point1.x;
643 throw std::logic_error(
"Line is normal to projection plane");
671 double dv = 0, d2 = 0,
v2 = 0;
672 for (
size_t i = 0; i < 3; i++)
678 return sqrt(d2 - (dv * dv) /
v2);
682 double s = sqrt(squareNorm<3, double>(
director));
683 for (
size_t i = 0; i < 3; i++)
director[i] /=
s;
688 throw logic_error(
"Both points are the same");
723 return dotProduct<3, double>(
coefs, point) +
coefs[3];
748 vector[0] =
coefs[0];
749 vector[1] =
coefs[1];
750 vector[2] =
coefs[2];
754 double s = sqrt(squareNorm<3, double>(
coefs));
755 for (
size_t i = 0; i < 4; i++)
coefs[i] /=
s;
765 for (
size_t i = 0; i < 3; i++)
777 throw std::logic_error(
"Base point is not in the plane.");
782 for (
size_t i = 0; i < 3; i++) AXIS.set_unsafe(i, 3, newOrigin[i]);
787 double dx1 = p2.
x - p1.
x;
788 double dy1 = p2.
y - p1.
y;
789 double dz1 = p2.
z - p1.
z;
790 double dx2 = p3.
x - p1.
x;
791 double dy2 = p3.
y - p1.
y;
792 double dz2 = p3.
z - p1.
z;
793 coefs[0] = dy1 * dz2 - dy2 * dz1;
794 coefs[1] = dz1 * dx2 - dz2 * dx1;
795 coefs[2] = dx1 * dy2 - dx2 * dy1;
798 throw logic_error(
"Points are linearly dependent");
803 double dx1 = p1.
x - r2.
pBase.
x;
804 double dy1 = p1.
y - r2.
pBase.
y;
805 double dz1 = p1.
z - r2.
pBase.
z;
811 throw logic_error(
"Point is contained in the line");
823 if (r1.
contains(r2.
pBase))
throw std::logic_error(
"Lines are the same");
827 for (
size_t i = 0; i < 3; i++) d[i] = r1.
pBase[i] - r2.
pBase[i];
833 throw logic_error(
"Lines do not intersect");
839 size_t N = poly.size();
841 std::vector<size_t> unused;
847 for (
size_t i = 1; i < N - 1; i++)
857 unused.push_back(N - 1);
860 for (
size_t i = 0; i < unused.size() - 1; i++)
862 size_t last = unused[i + 1];
863 for (
size_t j = unused[i] + 1 - diff; j < last - diff; j++)
864 poly[j] = poly[j + diff];
866 poly.resize(N + 1 - unused.size());
871 size_t N = poly.size();
873 std::vector<size_t> rep;
874 for (
size_t i = 0; i < N - 1; i++)
878 rep.push_back(N - 1);
881 for (
size_t i = 0; i < rep.size() - 1; i++)
883 size_t last = rep[i + 1];
884 for (
size_t j = rep[i] + 1 - diff; j < last - diff; j++)
885 poly[j] = poly[j + diff];
887 poly.resize(N + 1 - rep.size());
893 std::vector<TSegment2D> sgs;
899 double distance = std::numeric_limits<double>::max();
904 double d = (*it).distance(point);
913 ASSERTMSG_(!this->
empty(),
"getBoundingBox() called on an empty polygon!");
914 min_coords.
x = min_coords.
y = std::numeric_limits<double>::max();
915 max_coords.
x = max_coords.
y = -std::numeric_limits<double>::max();
916 for (
size_t i = 0; i <
size(); i++)
935 return ((P1.
x - P0.
x) * (P2.
y - P0.
y) - (P2.
x - P0.
x) * (P1.
y - P0.
y));
943 const size_t n = this->
size();
944 for (
size_t i = 0; i <
n; i++)
946 if ((*
this)[i].
y <= P.
y)
949 if ((*
this)[(i + 1) %
n].
y > P.
y)
950 if (
isLeft((*
this)[i], (*
this)[(i + 1) %
n], P) >
957 if ((*
this)[(i + 1) %
n].
y <= P.
y)
958 if (
isLeft((*
this)[i], (*
this)[(i + 1) %
n], P) <
970 for (
size_t i = 0; i < N - 1; i++)
971 v[i] =
TSegment2D(
operator[](i),
operator[](i + 1));
972 v[N - 1] =
TSegment2D(
operator[](N - 1),
operator[](0));
980 template <
class T,
int N>
987 for (
size_t i = 0; i < N; i++)
object[i] = 0.0;
991 for (
size_t i = 0; i < N; i++)
object[i] += o[i];
1004 if (N <= 3)
return true;
1005 vector<TSegment2D> sgms;
1007 for (
size_t i = 0; i < N; i++)
1011 for (
size_t j = 0; j < N; j++)
1017 s = (d > 0) ? 1 : -1;
1018 else if (
s != ((d > 0) ? 1 : -1))
1031 std::vector<double>&
x, std::vector<double>&
y)
const
1036 for (
size_t i = 0; i < N; i++)
1046 size_t N =
p.
size();
1048 for (
size_t i = 0; i < N; i++)
operator[](i) =
TPoint2D(
p[i]);
1051 size_t numEdges,
double radius,
TPolygon2D& poly)
1053 if (numEdges < 3 || abs(radius) <
getEpsilon())
1054 throw std::logic_error(
1055 "Invalid arguments for regular polygon creations");
1056 poly.resize(numEdges);
1057 for (
size_t i = 0; i < numEdges; i++)
1059 double angle = i *
M_PI * 2 / numEdges;
1060 poly[i] =
TPoint2D(radius * cos(angle), radius * sin(angle));
1064 size_t numEdges,
double radius,
TPolygon2D& poly,
1068 for (
size_t i = 0; i < numEdges; i++) poly[i] = pose + poly[i];
1075 throw std::logic_error(
"Polygon does not conform a plane");
1083 return sqrt(newPoint.
z * newPoint.
z + distance2D * distance2D);
1098 throw std::logic_error(
"Polygon does not conform a plane");
1115 for (
size_t i = 0; i < N - 1; i++)
1116 v[i] =
TSegment3D(
operator[](i),
operator[](i + 1));
1117 v[N - 1] =
TSegment3D(
operator[](N - 1),
operator[](0));
1141 size_t N =
p.
size();
1143 for (
size_t i = 0; i < N; i++)
operator[](i) =
p[i];
1146 size_t numEdges,
double radius,
TPolygon3D& poly)
1148 if (numEdges < 3 || abs(radius) <
getEpsilon())
1149 throw std::logic_error(
1150 "Invalid arguments for regular polygon creations");
1151 poly.resize(numEdges);
1152 for (
size_t i = 0; i < numEdges; i++)
1154 double angle = i * 2 *
M_PI / numEdges;
1155 poly[i] =
TPoint3D(radius * cos(angle), radius * sin(angle), 0);
1159 size_t numEdges,
double radius,
TPolygon3D& poly,
1163 for (
size_t i = 0; i < numEdges; i++)
1165 poly[i][0], poly[i][1], poly[i][2], poly[i][0], poly[i][1],
1191 const std::vector<TObject2D>& objs, std::vector<TPoint2D>& pnts)
1195 if (it->isPoint()) pnts.push_back(it->data.point);
1198 const std::vector<TObject2D>& objs, std::vector<TSegment2D>& sgms)
1202 if (it->isSegment()) sgms.push_back(it->data.segment);
1205 const std::vector<TObject2D>& objs, std::vector<TLine2D>& lins)
1209 if (it->isLine()) lins.push_back(it->data.line);
1212 const std::vector<TObject2D>& objs, std::vector<TPolygon2D>& polys)
1216 if (it->isPolygon()) polys.push_back(*(it->data.polygon));
1219 const std::vector<TObject2D>& objs, std::vector<TPoint2D>& pnts,
1220 std::vector<TObject2D>& remainder)
1225 pnts.push_back(it->data.point);
1227 remainder.push_back(*it);
1230 const std::vector<TObject2D>& objs, std::vector<TSegment2D>& sgms,
1231 std::vector<TObject2D>& remainder)
1235 if (it->isSegment())
1236 sgms.push_back(it->data.segment);
1238 remainder.push_back(*it);
1241 const std::vector<TObject2D>& objs, std::vector<TLine2D>& lins,
1242 std::vector<TObject2D>& remainder)
1247 lins.push_back(it->data.line);
1249 remainder.push_back(*it);
1252 const std::vector<TObject2D>& objs, std::vector<TPolygon2D>& polys,
1253 vector<TObject2D>& remainder)
1257 if (it->isPolygon())
1258 polys.push_back(*(it->data.polygon));
1260 remainder.push_back(*it);
1263 const std::vector<TObject3D>& objs, std::vector<TPoint3D>& pnts)
1267 if (it->isPoint()) pnts.push_back(it->data.point);
1270 const std::vector<TObject3D>& objs, std::vector<TSegment3D>& sgms)
1274 if (it->isSegment()) sgms.push_back(it->data.segment);
1277 const std::vector<TObject3D>& objs, std::vector<TLine3D>& lins)
1281 if (it->isLine()) lins.push_back(it->data.line);
1284 const std::vector<TObject3D>& objs, std::vector<TPlane>& plns)
1288 if (it->isPlane()) plns.push_back(it->data.plane);
1291 const std::vector<TObject3D>& objs, std::vector<TPolygon3D>& polys)
1295 if (it->isPolygon()) polys.push_back(*(it->data.polygon));
1298 const std::vector<TObject3D>& objs, std::vector<TPoint3D>& pnts,
1299 std::vector<TObject3D>& remainder)
1304 pnts.push_back(it->data.point);
1306 remainder.push_back(*it);
1309 const std::vector<TObject3D>& objs, std::vector<TSegment3D>& sgms,
1310 std::vector<TObject3D>& remainder)
1314 if (it->isSegment())
1315 sgms.push_back(it->data.segment);
1317 remainder.push_back(*it);
1320 const std::vector<TObject3D>& objs, std::vector<TLine3D>& lins,
1321 std::vector<TObject3D>& remainder)
1326 lins.push_back(it->data.line);
1328 remainder.push_back(*it);
1331 const std::vector<TObject3D>& objs, std::vector<TPlane>& plns,
1332 std::vector<TObject3D>& remainder)
1337 plns.push_back(it->data.plane);
1339 remainder.push_back(*it);
1342 const std::vector<TObject3D>& objs, std::vector<TPolygon3D>& polys,
1343 vector<TObject3D>& remainder)
1347 if (it->isPolygon())
1348 polys.push_back(*(it->data.polygon));
1350 remainder.push_back(*it);
1369 in >> o.
x >> o.
y >> o.
z;
1375 out << o.
x << o.
y << o.
z;
1388 out << o.
x << o.
y << o.
phi;
1395 for (
unsigned int i = 0; i < o.
size(); i++)
in >> o[i];
1401 for (
unsigned int i = 0; i < o.
size(); i++) out << o[i];
1408 for (
unsigned int i = 0; i < o.
size(); i++)
in >> o[i];
1414 for (
unsigned int i = 0; i < o.
size(); i++) out << o[i];
1446 switch (
static_cast<unsigned char>(
type))
1482 throw std::logic_error(
1483 "Unknown TObject2D type found while reading stream");
1490 out << static_cast<uint16_t>(o.
getType());
1526 switch (
static_cast<unsigned char>(
type))
1569 throw std::logic_error(
1570 "Unknown TObject3D type found while reading stream");
1577 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).
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.
bool contains(const TPoint3D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
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.
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=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, 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 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 & operator<<(std::ostream &o, const TPoint2D &p)
const unsigned char GEOMETRIC_TYPE_POLYGON
Object type identifier for TPolygon2D or TPolygon3D.
void 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.
double getEpsilon()
Gets the value of the geometric epsilon (default = 1e-5)
bool conformAPlane(const std::vector< TPoint3D > &points)
Checks whether this polygon or set of points acceptably fits a plane.
void 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 getRegressionPlane(const std::vector< TPoint3D > &points, TPlane &plane)
Using eigenvalues, gets the best fitting plane for a set of 3D points.
double 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 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)
mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, CMatrix::Ptr &pObj)
void removeUnusedVertices(T &poly)
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 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 x
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.
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 vx
Velocity components: X,Y (m/s)
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
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...
double vx
Velocity components: X,Y (m/s)
bool operator==(const TTwist3D &o) const
double wx
Angular velocity (rad/s)