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());
const unsigned char GEOMETRIC_TYPE_PLANE
Object type identifier for TPlane.
static void getSegments(const std::vector< TObject2D > &objs, std::vector< TSegment2D > &sgms)
Static method to retrieve all the segments in a vector of TObject2D.
bool getPoint(TPoint2D &p) const
Gets the content as a point, returning false if the type is inadequate.
double x() const
Common members of all points & poses classes.
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D &poly)
Static method to create a regular polygon, given its size and radius.
static void createRegularPolygon(size_t numEdges, double radius, TPolygon2D &poly)
Static method to create a regular polygon, given its size and radius.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04]" ) ...
bool getPolygon(TPolygon2D &p) const
Gets the content as a polygon, returning false if the type is inadequate.
void rotate(const double ang)
Transform the (vx,vy) components for a counterclockwise rotation of ang radians.
EIGEN_STRONG_INLINE bool empty() const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
const unsigned char GEOMETRIC_TYPE_LINE
Object type identifier for TLine2D or TLine3D.
unsigned __int16 uint16_t
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, 2 for z) corresponds to the provided vector.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
unsigned char getType() const
Gets content type.
TPoint2D lightFromPose(const mrpt::poses::CPoint2D &p)
Convert a pose into a light-weight structure (functional form, needed for forward declarations) ...
const unsigned char GEOMETRIC_TYPE_POINT
Object type identifier for TPoint2D or TPoint3D.
bool operator==(const TTwist3D &o) const
double distance(const TPoint3D &point) const
Distance between the line and a point.
void getPlotData(std::vector< double > &x, std::vector< double > &y) const
Gets plot data, ready to use on a 2D plot.
size_t size(const MATRIXLIKE &m, const int dim)
bool isSkew() const
Check whether the polygon is skew.
TLine2D()
Fast default constructor.
bool getSegment(TSegment3D &s) const
Gets the content as a segment, returning false if the type is not adequate.
bool contains(const TPoint2D &point) const
Check whether a point is inside a segment.
double roll
Roll coordinate (rotation angle over X coordinate).
static void getPolygons(const std::vector< TObject2D > &objs, std::vector< TPolygon2D > &polys)
Static method to retrieve all the polygons in a vector of TObject2D.
TPolygon3D()
Default constructor.
#define THROW_EXCEPTION(msg)
GLdouble GLdouble GLdouble GLdouble q
double distance(const TPoint2D &point) const
Distance to point.
static void getLines(const std::vector< TObject2D > &objs, std::vector< TLine2D > &lins)
Static method to retrieve all the lines in a vector of TObject2D.
This file implements several operations that operate element-wise on individual or pairs of container...
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) ...
EIGEN_STRONG_INLINE iterator begin()
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
TPoint3D()
Default fast constructor.
double signedDistance(const TPoint2D &point) const
Distance with sign from a given point (sign indicates side).
Standard type for storing any lightweight 2D type.
TLine3D()
Fast default constructor.
bool getLine(TLine2D &r) const
Gets the content as a line, returning false if the type is inadequate.
void getAsPose3D(mrpt::poses::CPose3D &outPose)
Gets a pose whose XY plane corresponds to this plane.
void getAsSegmentList(std::vector< TSegment2D > &v) const
Gets as set of segments, instead of points.
bool getPlane(TPlane &p) const
Gets the content as a plane, returning false if the type is not adequate.
TPoint3D pBase
Base point.
Standard object for storing any 3D lightweight object.
bool getSegment(TSegment2D &s) const
Gets the content as a segment, returning false if the type is inadequate.
bool contains(const TPoint2D &point) const
Check whether a point is inside the line.
void removeRepeatedVertices()
Erase repeated vertices.
double signedDistance(const TPoint2D &point) const
Distance with sign to point (sign indicates which side the point is).
const Scalar * const_iterator
void generate3DObject(TLine3D &l) const
Project into 3D space, setting the z to 0.
void removeRepVertices(T &poly)
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -45...
double distance(const TPoint3D &point) const
Distance to 3D point.
double yaw
Yaw coordinate (rotation angle over Z axis).
GLsizei GLsizei GLuint * obj
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[vx vy vz wx wy wz]" ) ...
bool operator<(const TSegment3D &s) const
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...
GLubyte GLubyte GLubyte GLubyte w
3D twist: 3D velocity vector (vx,vy,vz) + angular velocity (wx,wy,wz)
void crossProduct3D(const T &v0, const U &v1, V &vOut)
Computes the cross product of two 3D vectors, returning a vector normal to both.
TPoint3D point1
Origin point.
T square(const T x)
Inline function for the square of a number.
bool conformAPlane(const std::vector< TPoint3D > &points)
Checks whether this polygon or set of points acceptably fits a plane.
static void getSegments(const std::vector< TObject3D > &objs, std::vector< TSegment3D > &sgms)
Static method to retrieve every segment included in a vector of objects.
TPose3D()
Default fast constructor.
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
void getNormalVector(double(&vector)[2]) const
Get line's normal vector.
void generate3DObject(TPolygon3D &p) const
Projects into 3D space, zeroing the z.
bool contains(const TPoint3D &point) const
Check whether a point is inside the line.
double isLeft(const mrpt::math::TPoint2D &P0, const mrpt::math::TPoint2D &P1, const mrpt::math::TPoint2D &P2)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
void unitarize()
Unitarize line's normal vector.
std::string asString() const
void getBoundingBox(TPoint2D &min_coords, TPoint2D &max_coords) const
Get polygon bounding box.
bool getPolygon(TPolygon3D &p) const
Gets the content as a polygon, returning false if the type is not adequate.
2D segment, consisting of two points.
double distance(const TPoint3D &point) const
Distance to point.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -45...
double RAD2DEG(const double x)
Radians to degrees.
3D segment, consisting of two points.
double length() const
Segment length.
TPoint3D point2
Destiny point.
bool operator<(const TSegment2D &s) const
std::ostream & operator<<(std::ostream &o, const TPoint2D &p)
double vx
Velocity components: X,Y (m/s)
mrpt::math::TPose2D operator+(const mrpt::math::TPose2D &b) const
Operator "oplus" pose composition: "ret=this \oplus b".
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...
static void getLines(const std::vector< TObject3D > &objs, std::vector< TLine3D > &lins)
Static method to retrieve every line included in a vector of objects.
void unitarize()
Unitarize normal vector.
mrpt::math::TPose2D operator*(const double dt) const
Returns the pose increment of multiplying each twist component times "dt" seconds.
const unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn't exist already.
static void getPolygons(const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys)
Static method to retrieve every polygon included in a vector of objects.
3D Plane, represented by its equation
bool getPlane(TPlane &p) const
Gets a plane which contains the polygon.
double coefs[3]
Line coefficients, stored as an array: .
double getRegressionPlane(const std::vector< TPoint3D > &points, TPlane &plane)
Using eigenvalues, gets the best fitting plane for a set of 3D points.
TPolygon2D()
Default constructor.
double x
X,Y,Z coordinates.
void removeRedundantVertices()
Erase every redundant vertex, thus saving space.
TPose3DQuat()
Default fast constructor.
TPoint2D point2
Destiny point.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
void getCenter(TPoint2D &p) const
Polygon's central point.
double getAngle(const TPlane &p1, const TPlane &p2)
Computes the angle between two planes.
GLsizei const GLchar ** string
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
A class used to store a 2D point.
A class used to store a 3D point.
void unitarize()
Unitarize director vector.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
bool contains(const TPoint3D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
bool getPoint(TPoint3D &p) const
Gets the content as a point, returning false if the type is not adequate.
double pitch
Pitch coordinate (rotation angle over Y axis).
void loadFromArray(const T *vals)
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
double distance(const TPoint3D &point) const
Distance to point (always >=0)
double director[3]
Director vector.
TPoint2D point1
Origin point.
bool isConvex() const
Checks whether is convex.
TPoint2D()
Default fast constructor.
mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, CMatrix::Ptr &pObj)
void generate3DObject(TSegment3D &s) const
Project into 3D space, setting the z to 0.
bool contains(const TPoint2D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
void removeUnusedVertices(T &poly)
double distance(const TPoint2D &point) const
Distance to a point (always >=0)
void getAsPose2D(mrpt::poses::CPose2D &outPose) const
Get a pose2D whose X axis corresponds to the line.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
TPlane()
Fast default constructor.
double wx
Angular velocity (rad/s)
GLdouble GLdouble GLdouble r
size_t size(const MATRIXLIKE &m, const int dim)
double vx
Velocity components: X,Y (m/s)
void generate3DObject(TObject3D &obj) const
Project into 3D space.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
static void getPoints(const std::vector< TObject2D > &objs, std::vector< TPoint2D > &pnts)
Static method to retrieve all the points in a vector of TObject2D.
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 getUnitaryNormalVector(double(&vec)[3])
Unitarize, then get normal vector.
double coefs[4]
Plane coefficients, stored as an array: .
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...
TSegment2D()
Fast default constructor.
const double & phi() const
Get the phi angle of the 2D pose (in radians)
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0...
bool operator!=(const TTwist3D &o) const
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.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
void removeRedundantVertices()
Erase every redundant vertex from the polygon, saving space.
void removeRepeatedVertices()
Remove polygon's repeated vertices.
bool contains(const TPoint3D &point) const
Check whether a point is inside the segment.
bool getLine(TLine3D &r) const
Gets the content as a line, returning false if the type is not adequate.
double evaluatePoint(const TPoint3D &point) const
Evaluate a point in the plane's equation.
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 -0...
bool operator<(const TPoint3D &p) const
double evaluatePoint(const TPoint2D &point) const
Evaluate point in the line's equation.
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.
TPose2D()
Default fast constructor.
GLfloat GLfloat GLfloat v2
unsigned char getType() const
Gets object type.
const unsigned char GEOMETRIC_TYPE_UNDEFINED
Object type identifier for empty TObject2D or TObject3D.
mrpt::math::TPose2D operator-(const mrpt::math::TPose2D &b) const
Operator "ominus" pose composition: "ret=this \ominus b".
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
double distance(const TPoint2D &point) const
Distance from a given point.
void getAsSegmentList(std::vector< TSegment3D > &v) const
Gets as set of segments, instead of set of points.
void getBestFittingPlane(TPlane &p) const
Gets the best fitting plane, disregarding whether the polygon actually fits inside or not...
void getDirectorVector(double(&vector)[2]) const
Get line's director vector.
double getEpsilon()
Gets the value of the geometric epsilon (default = 1e-5)
std::string asString() const
const unsigned char GEOMETRIC_TYPE_POLYGON
Object type identifier for TPolygon2D or TPolygon3D.
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...
#define ASSERTMSG_(f, __ERROR_MSG)
GLsizei GLsizei GLenum GLenum const GLvoid * data
std::string asString() const
GLubyte GLubyte GLubyte a
static void getPlanes(const std::vector< TObject3D > &objs, std::vector< TPlane > &plns)
Static method to retrieve every plane included in a vector of objects.
double phi
Orientation (rads)
bool operator<(const TPoint2D &p) const
GLuint GLuint GLsizei GLenum type
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...
void getAsVector(VECTORLIKE &v) const
Transformation into vector.
void operator()(const T &o)
2D polygon, inheriting from std::vector<TPoint2D>.
3D polygon, inheriting from std::vector<TPoint3D>
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
void getCenter(TPoint3D &p) const
Get polygon's central point.
double omega
Angular velocity (rad/s)
bool contains(const TPoint3D &point) const
Check whether a point is contained into the plane.
double length() const
Segment length.
bool operator!=(const TTwist2D &o) const
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0...
bool operator==(const TTwist2D &o) const
void getNormalVector(double(&vec)[3]) const
Get plane's normal vector.
3D line, represented by a base point and a director vector.
2D line without bounds, represented by its equation .
static void getPoints(const std::vector< TObject3D > &objs, std::vector< TPoint3D > &pnts)
Static method to retrieve every point included in a vector of objects.