45 if (!m.fromMatlabStringFormat(
s))
48 m.rows() == 1 && m.cols() == 2,
"Wrong size of vector in ::fromString");
49 x = m.get_unsafe(0, 0);
50 y = m.get_unsafe(0, 1);
63 if (!m.fromMatlabStringFormat(
s))
66 m.rows() == 1 && m.cols() == 3,
"Wrong size of vector in ::fromString");
67 x = m.get_unsafe(0, 0);
68 y = m.get_unsafe(0, 1);
74 const double A_cosphi = cos(this->phi), A_sinphi = sin(this->phi);
76 const double new_x = this->
x +
b.x * A_cosphi -
b.y * A_sinphi;
77 const double new_y = this->
y +
b.x * A_sinphi +
b.y * A_cosphi;
86 const double B_cosphi = cos(
b.phi), B_sinphi = sin(
b.phi);
89 (this->
x -
b.x) * B_cosphi + (this->
y -
b.y) * B_sinphi;
91 -(this->
x -
b.x) * B_sinphi + (this->
y -
b.y) * B_cosphi;
105 if (!m.fromMatlabStringFormat(
s))
108 m.rows() == 1 && m.cols() == 3,
"Wrong size of vector in ::fromString");
109 vx = m.get_unsafe(0, 0);
110 vy = m.get_unsafe(0, 1);
117 const double nvx =
vx * cos(ang) -
vy * sin(ang);
118 const double nvy =
vx * sin(ang) +
vy * cos(ang);
142 if (!m.fromMatlabStringFormat(
s))
145 m.rows() == 1 && m.cols() == 6,
"Wrong size of vector in ::fromString");
146 for (
int i = 0; i < 3; i++) (*
this)[i] = m.get_unsafe(0, i);
147 for (
int i = 0; i < 3; i++)
148 (*
this)[3 + i] =
DEG2RAD(m.get_unsafe(0, 3 + i));
158 vx =
R(0, 0) *
t.vx +
R(0, 1) *
t.vy +
R(0, 2) *
t.vz;
159 vy =
R(1, 0) *
t.vx +
R(1, 1) *
t.vy +
R(1, 2) *
t.vz;
160 vz =
R(2, 0) *
t.vx +
R(2, 1) *
t.vy +
R(2, 2) *
t.vz;
162 wx =
R(0, 0) *
t.wx +
R(0, 1) *
t.wy +
R(0, 2) *
t.wz;
163 wy =
R(1, 0) *
t.wx +
R(1, 1) *
t.wy +
R(1, 2) *
t.wz;
164 wz =
R(2, 0) *
t.wx +
R(2, 1) *
t.wy +
R(2, 2) *
t.wz;
191 if (!m.fromMatlabStringFormat(
s))
194 m.rows() == 1 && m.cols() == 3,
"Wrong size of vector in ::fromString");
195 x = m.get_unsafe(0, 0);
196 y = m.get_unsafe(0, 1);
197 z = m.get_unsafe(0, 2);
224 const double cy = cos(
yaw * 0.5), sy = sin(
yaw * 0.5);
225 const double cp = cos(
pitch * 0.5), sp = sin(
pitch * 0.5);
226 const double cr = cos(
roll * 0.5), sr = sin(
roll * 0.5);
228 const double ccc = cr * cp * cy;
229 const double ccs = cr * cp * sy;
230 const double css = cr * sp * sy;
231 const double sss = sr * sp * sy;
232 const double scc = sr * cp * cy;
233 const double ssc = sr * sp * cy;
234 const double csc = cr * sp * cy;
235 const double scs = sr * cp * sy;
249 -0.5 *
q[3], 0.5 * (-csc + scs), -0.5 *
q[1],
250 -0.5 *
q[2], 0.5 * (-ssc - ccs), 0.5 *
q[0],
251 0.5 *
q[1], 0.5 * (ccc - sss), 0.5 *
q[3],
252 0.5 *
q[0], 0.5 * (-css - scc), -0.5 *
q[2]};
261 res.x =
R(0, 0) * l.
x +
R(0, 1) * l.
y +
R(0, 2) * l.
z + this->
x;
262 res.
y =
R(1, 0) * l.
x +
R(1, 1) * l.
y +
R(1, 2) * l.
z + this->
y;
263 res.
z =
R(2, 0) * l.
x +
R(2, 1) * l.
y +
R(2, 2) * l.
z + this->
z;
272 res.x = H(0, 0) *
g.x + H(0, 1) *
g.y + H(0, 2) *
g.z + H(0, 3);
273 res.y = H(1, 0) *
g.x + H(1, 1) *
g.y + H(1, 2) *
g.z + H(1, 3);
274 res.z = H(2, 0) *
g.x + H(2, 1) *
g.y + H(2, 2) *
g.z + H(2, 3);
280 const double cy = cos(
yaw);
281 const double sy = sin(
yaw);
282 const double cp = cos(
pitch);
283 const double sp = sin(
pitch);
284 const double cr = cos(
roll);
285 const double sr = sin(
roll);
288 cy * sp * sr - sy * cr,
289 cy * sp * cr + sy * sr,
291 sy * sp * sr + cy * cr,
292 sy * sp * cr - cy * sr,
296 R.loadFromArray(rot_vals);
306 "Homogeneous matrix is not orthogonal & normalized!: " +
312 "Homogeneous matrix is not orthogonal & normalized!: " +
318 "Homogeneous matrix is not orthogonal & normalized!: " +
322 pitch = atan2(-
R(2, 0), hypot(
R(0, 0),
R(1, 0)));
325 if ((fabs(
R(2, 1)) + fabs(
R(2, 2))) <
326 10 * std::numeric_limits<double>::epsilon())
350 yaw = atan2(
R(1, 2),
R(0, 2));
352 yaw = atan2(-
R(1, 2), -
R(0, 2));
356 roll = atan2(
R(2, 1),
R(2, 2));
358 yaw = atan2(
R(1, 0),
R(0, 0));
380 HG.block<3, 3>(0, 0) =
R;
384 HG(3, 0) = HG(3, 1) = HG(3, 2) = 0.;
396 if (!m.fromMatlabStringFormat(
s))
399 m.rows() == 1 && m.cols() == 6,
"Wrong size of vector in ::fromString");
400 x = m.get_unsafe(0, 0);
401 y = m.get_unsafe(0, 1);
402 z = m.get_unsafe(0, 2);
411 if (!m.fromMatlabStringFormat(
s))
414 m.rows() == 1 && m.cols() == 7,
"Wrong size of vector in ::fromString");
415 for (
int i = 0; i < m.cols(); i++) (*
this)[i] = m.get_unsafe(0, i);
420 p.getInverseHomogeneousMatrix(H);
429 a.getInverseHomogeneousMatrix(Hainv);
430 b.getHomogeneousMatrix(Hb);
439 return (o <<
p.asString());
443 return (o <<
p.asString());
447 return (o <<
p.asString());
451 return (o <<
p.asString());
455 return (o <<
p.asString());
460 return in >>
s.point1 >>
s.point2;
464 return out <<
s.point1 <<
s.point2;
477 return in >>
s.point1 >>
s.point2;
481 return out <<
s.point1 <<
s.point2;
493 return in >>
p.coefs[0] >>
p.coefs[1] >>
p.coefs[2] >>
p.coefs[3];
497 return out <<
p.coefs[0] <<
p.coefs[1] <<
p.coefs[2] <<
p.coefs[3];
516 const double d3 =
length();
517 const double ds1 =
square(d1);
518 const double ds2 =
square(d2);
519 const double ds3 =
square(d3);
520 if (ds1 > (ds2 + ds3) || ds2 > (ds1 + ds3))
541 throw std::logic_error(
"Segment is normal to projection plane");
563 Eigen::Vector3d u,
v,
w;
575 double D =
a *
c -
b *
b;
576 double sc, sN, sD = D;
577 double tc, tN, tD = D;
589 sN = (
b * e -
c * d);
590 tN = (
a * e -
b * d);
625 else if ((-d +
b) >
a)
634 sc = (fabs(sN) < 0.00000001 ? 0.0 : sN / sD);
635 tc = (fabs(tN) < 0.00000001 ? 0.0 : tN / tD);
679 vector[0] =
coefs[0];
680 vector[1] =
coefs[1];
685 for (
size_t i = 0; i < 3; i++)
coefs[i] /=
s;
689 vector[0] = -
coefs[1];
690 vector[1] =
coefs[0];
714 throw std::logic_error(
"Base point is not contained in the line");
721 if (p1 == p2)
throw logic_error(
"Both points are the same");
728 coefs[0] =
s.point2.y -
s.point1.y;
729 coefs[1] =
s.point1.x -
s.point2.x;
730 coefs[2] =
s.point2.x *
s.point1.y -
s.point2.y *
s.point1.x;
737 throw std::logic_error(
"Line is normal to projection plane");
765 double dv = 0, d2 = 0,
v2 = 0;
766 for (
size_t i = 0; i < 3; i++)
772 return sqrt(d2 - (dv * dv) /
v2);
776 double s = sqrt(squareNorm<3, double>(
director));
777 for (
size_t i = 0; i < 3; i++)
director[i] /=
s;
782 throw logic_error(
"Both points are the same");
817 return dotProduct<3, double>(
coefs, point) +
coefs[3];
842 vector[0] =
coefs[0];
843 vector[1] =
coefs[1];
844 vector[2] =
coefs[2];
848 double s = sqrt(squareNorm<3, double>(
coefs));
849 for (
size_t i = 0; i < 4; i++)
coefs[i] /=
s;
859 for (
size_t i = 0; i < 3; i++)
870 throw std::logic_error(
"Base point is not in the plane.");
875 for (
size_t i = 0; i < 3; i++) AXIS.set_unsafe(i, 3, newOrigin[i]);
880 double dx1 = p2.
x - p1.
x;
881 double dy1 = p2.
y - p1.
y;
882 double dz1 = p2.
z - p1.
z;
883 double dx2 = p3.
x - p1.
x;
884 double dy2 = p3.
y - p1.
y;
885 double dz2 = p3.
z - p1.
z;
886 coefs[0] = dy1 * dz2 - dy2 * dz1;
887 coefs[1] = dz1 * dx2 - dz2 * dx1;
888 coefs[2] = dx1 * dy2 - dx2 * dy1;
891 throw logic_error(
"Points are linearly dependent");
896 double dx1 = p1.
x - r2.
pBase.
x;
897 double dy1 = p1.
y - r2.
pBase.
y;
898 double dz1 = p1.
z - r2.
pBase.
z;
904 throw logic_error(
"Point is contained in the line");
916 if (r1.
contains(r2.
pBase))
throw std::logic_error(
"Lines are the same");
920 for (
size_t i = 0; i < 3; i++) d[i] = r1.
pBase[i] - r2.
pBase[i];
926 throw logic_error(
"Lines do not intersect");
932 size_t N = poly.size();
934 std::vector<size_t> unused;
940 for (
size_t i = 1; i < N - 1; i++)
950 unused.push_back(N - 1);
953 for (
size_t i = 0; i < unused.size() - 1; i++)
955 size_t last = unused[i + 1];
956 for (
size_t j = unused[i] + 1 - diff; j < last - diff; j++)
957 poly[j] = poly[j + diff];
959 poly.resize(N + 1 - unused.size());
964 size_t N = poly.size();
966 std::vector<size_t> rep;
967 for (
size_t i = 0; i < N - 1; i++)
971 rep.push_back(N - 1);
974 for (
size_t i = 0; i < rep.size() - 1; i++)
976 size_t last = rep[i + 1];
977 for (
size_t j = rep[i] + 1 - diff; j < last - diff; j++)
978 poly[j] = poly[j + diff];
980 poly.resize(N + 1 - rep.size());
986 std::vector<TSegment2D> sgs;
992 double distance = std::numeric_limits<double>::max();
997 double d = (*it).distance(point);
1006 ASSERTMSG_(!this->
empty(),
"getBoundingBox() called on an empty polygon!");
1007 min_coords.
x = min_coords.
y = std::numeric_limits<double>::max();
1008 max_coords.
x = max_coords.
y = -std::numeric_limits<double>::max();
1009 for (
size_t i = 0; i <
size(); i++)
1028 return ((P1.
x - P0.
x) * (P2.
y - P0.
y) - (P2.
x - P0.
x) * (P1.
y - P0.
y));
1036 const size_t n = this->
size();
1037 for (
size_t i = 0; i <
n; i++)
1039 if ((*
this)[i].
y <= P.
y)
1042 if ((*
this)[(i + 1) %
n].
y > P.
y)
1043 if (
isLeft((*
this)[i], (*
this)[(i + 1) %
n], P) >
1050 if ((*
this)[(i + 1) %
n].
y <= P.
y)
1051 if (
isLeft((*
this)[i], (*
this)[(i + 1) %
n], P) <
1063 for (
size_t i = 0; i < N - 1; i++)
1064 v[i] =
TSegment2D(
operator[](i),
operator[](i + 1));
1065 v[N - 1] =
TSegment2D(
operator[](N - 1),
operator[](0));
1073 template <
class T,
int N>
1080 for (
size_t i = 0; i < N; i++)
object[i] = 0.0;
1084 for (
size_t i = 0; i < N; i++)
object[i] += o[i];
1097 if (N <= 3)
return true;
1098 vector<TSegment2D> sgms;
1100 for (
size_t i = 0; i < N; i++)
1104 for (
size_t j = 0; j < N; j++)
1110 s = (d > 0) ? 1 : -1;
1111 else if (
s != ((d > 0) ? 1 : -1))
1124 std::vector<double>&
x, std::vector<double>&
y)
const 1129 for (
size_t i = 0; i < N; i++)
1139 size_t N =
p.
size();
1141 for (
size_t i = 0; i < N; i++)
operator[](i) =
TPoint2D(
p[i]);
1144 size_t numEdges,
double radius,
TPolygon2D& poly)
1146 if (numEdges < 3 || abs(radius) <
getEpsilon())
1147 throw std::logic_error(
1148 "Invalid arguments for regular polygon creations");
1149 poly.resize(numEdges);
1150 for (
size_t i = 0; i < numEdges; i++)
1152 double angle = i *
M_PI * 2 / numEdges;
1153 poly[i] =
TPoint2D(radius * cos(angle), radius * sin(angle));
1160 for (
size_t i = 0; i < numEdges; i++) poly[i] = pose.
composePoint(poly[i]);
1167 throw std::logic_error(
"Polygon does not conform a plane");
1175 return sqrt(newPoint.
z * newPoint.
z + distance2D * distance2D);
1187 throw std::logic_error(
"Polygon does not conform a plane");
1206 for (
size_t i = 0; i < N - 1; i++)
1207 v[i] =
TSegment3D(
operator[](i),
operator[](i + 1));
1208 v[N - 1] =
TSegment3D(
operator[](N - 1),
operator[](0));
1232 size_t N =
p.
size();
1234 for (
size_t i = 0; i < N; i++)
operator[](i) =
p[i];
1237 size_t numEdges,
double radius,
TPolygon3D& poly)
1239 if (numEdges < 3 || abs(radius) <
getEpsilon())
1240 throw std::logic_error(
1241 "Invalid arguments for regular polygon creations");
1242 poly.resize(numEdges);
1243 for (
size_t i = 0; i < numEdges; i++)
1245 double angle = i * 2 *
M_PI / numEdges;
1246 poly[i] =
TPoint3D(radius * cos(angle), radius * sin(angle), 0);
1253 for (
size_t i = 0; i < numEdges; i++) pose.
composePoint(poly[i], poly[i]);
1278 const std::vector<TObject2D>& objs, std::vector<TPoint2D>& pnts)
1282 if (it->isPoint()) pnts.push_back(it->data.point);
1285 const std::vector<TObject2D>& objs, std::vector<TSegment2D>& sgms)
1289 if (it->isSegment()) sgms.push_back(it->data.segment);
1292 const std::vector<TObject2D>& objs, std::vector<TLine2D>& lins)
1296 if (it->isLine()) lins.push_back(it->data.line);
1299 const std::vector<TObject2D>& objs, std::vector<TPolygon2D>& polys)
1303 if (it->isPolygon()) polys.push_back(*(it->data.polygon));
1306 const std::vector<TObject2D>& objs, std::vector<TPoint2D>& pnts,
1307 std::vector<TObject2D>& remainder)
1312 pnts.push_back(it->data.point);
1314 remainder.push_back(*it);
1317 const std::vector<TObject2D>& objs, std::vector<TSegment2D>& sgms,
1318 std::vector<TObject2D>& remainder)
1322 if (it->isSegment())
1323 sgms.push_back(it->data.segment);
1325 remainder.push_back(*it);
1328 const std::vector<TObject2D>& objs, std::vector<TLine2D>& lins,
1329 std::vector<TObject2D>& remainder)
1334 lins.push_back(it->data.line);
1336 remainder.push_back(*it);
1339 const std::vector<TObject2D>& objs, std::vector<TPolygon2D>& polys,
1340 vector<TObject2D>& remainder)
1344 if (it->isPolygon())
1345 polys.push_back(*(it->data.polygon));
1347 remainder.push_back(*it);
1350 const std::vector<TObject3D>& objs, std::vector<TPoint3D>& pnts)
1354 if (it->isPoint()) pnts.push_back(it->data.point);
1357 const std::vector<TObject3D>& objs, std::vector<TSegment3D>& sgms)
1361 if (it->isSegment()) sgms.push_back(it->data.segment);
1364 const std::vector<TObject3D>& objs, std::vector<TLine3D>& lins)
1368 if (it->isLine()) lins.push_back(it->data.line);
1371 const std::vector<TObject3D>& objs, std::vector<TPlane>& plns)
1375 if (it->isPlane()) plns.push_back(it->data.plane);
1378 const std::vector<TObject3D>& objs, std::vector<TPolygon3D>& polys)
1382 if (it->isPolygon()) polys.push_back(*(it->data.polygon));
1385 const std::vector<TObject3D>& objs, std::vector<TPoint3D>& pnts,
1386 std::vector<TObject3D>& remainder)
1391 pnts.push_back(it->data.point);
1393 remainder.push_back(*it);
1396 const std::vector<TObject3D>& objs, std::vector<TSegment3D>& sgms,
1397 std::vector<TObject3D>& remainder)
1401 if (it->isSegment())
1402 sgms.push_back(it->data.segment);
1404 remainder.push_back(*it);
1407 const std::vector<TObject3D>& objs, std::vector<TLine3D>& lins,
1408 std::vector<TObject3D>& remainder)
1413 lins.push_back(it->data.line);
1415 remainder.push_back(*it);
1418 const std::vector<TObject3D>& objs, std::vector<TPlane>& plns,
1419 std::vector<TObject3D>& remainder)
1424 plns.push_back(it->data.plane);
1426 remainder.push_back(*it);
1429 const std::vector<TObject3D>& objs, std::vector<TPolygon3D>& polys,
1430 vector<TObject3D>& remainder)
1434 if (it->isPolygon())
1435 polys.push_back(*(it->data.polygon));
1437 remainder.push_back(*it);
1442 for (
unsigned int i = 0; i < o.
size(); i++)
in >> o[i];
1447 for (
unsigned int i = 0; i < o.
size(); i++) out << o[i];
1453 for (
unsigned int i = 0; i < o.
size(); i++)
in >> o[i];
1458 for (
unsigned int i = 0; i < o.
size(); i++) out << o[i];
1466 switch (static_cast<unsigned char>(
type))
1502 throw std::logic_error(
1503 "Unknown TObject2D type found while reading stream");
1509 out << static_cast<uint16_t>(o.
getType());
1544 switch (static_cast<unsigned char>(
type))
1587 throw std::logic_error(
1588 "Unknown TObject3D type found while reading stream");
1594 out << static_cast<uint16_t>(o.
getType());
void project3D(const TPoint3D &point, const mrpt::math::TPose3D &newXYpose, TPoint3D &newPoint)
Uses the given pose 3D to project a point into a new base.
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.
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]" ) ...
static constexpr unsigned char GEOMETRIC_TYPE_POINT
Object type identifier for TPoint2D or TPoint3D.
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
#define MRPT_MAX_ALIGN_BYTES
static void SO3_to_yaw_pitch_roll(const mrpt::math::CMatrixDouble33 &R, double &yaw, double &pitch, double &roll)
unsigned __int16 uint16_t
double RAD2DEG(const double x)
Radians to degrees.
unsigned char getType() const
Gets content type.
bool operator==(const TTwist3D &o) const
void getRotationMatrix(mrpt::math::CMatrixDouble33 &R) const
#define THROW_EXCEPTION(msg)
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).
void getAsPose3D(mrpt::math::TPose3D &outPose)
static void getPolygons(const std::vector< TObject2D > &objs, std::vector< TPolygon2D > &polys)
Static method to retrieve all the polygons in a vector of TObject2D.
double DEG2RAD(const double x)
Degrees to radians.
TPolygon3D()
Default constructor.
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...
mrpt::math::TPoint2D composePoint(const TPoint2D l) const
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 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).
void getInverseHomogeneousMatrix(mrpt::math::CMatrixDouble44 &HG) const
void generate3DObject(TLine3D &l) const
Project into 3D space, setting the z to 0.
void removeRepVertices(T &poly)
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...
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -45...
void getAsPose2D(TPose2D &outPose) const
double distance(const TPoint3D &point) const
Distance to 3D point.
double yaw
Yaw coordinate (rotation angle over Z axis).
void composePoint(const TPoint3D l, TPoint3D &g) const
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]" ) ...
static constexpr size_t size()
bool operator<(const TSegment3D &s) const
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn't exist already.
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.
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.
static constexpr unsigned char GEOMETRIC_TYPE_LINE
Object type identifier for TLine2D or TLine3D.
TPose3D()
Default fast constructor.
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
T square(const T x)
Inline function for the square of a number.
void generateAxisBaseFromDirectionAndAxis(const double(&vec)[3], char coord, CMatrixDouble44 &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.
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)
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.
This base provides a set of functions for maths stuff.
static constexpr unsigned char GEOMETRIC_TYPE_UNDEFINED
Object type identifier for empty TObject2D or TObject3D.
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...
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...
3D segment, consisting of two points.
double length() const
Segment length.
void fromHomogeneousMatrix(const mrpt::math::CMatrixDouble44 &HG)
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".
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.
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.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
void removeRedundantVertices()
Erase every redundant vertex, thus saving space.
TPoint2D point2
Destiny point.
void inverseComposePoint(const TPoint3D g, TPoint3D &l) const
void getCenter(TPoint2D &p) const
Polygon's central point.
void rotate(const mrpt::math::TPose3D &rot)
Transform all 6 components for a change of reference frame from "A" to another frame "B" whose rotati...
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.
void unitarize()
Unitarize director vector.
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.
static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &HG) const
#define ASSERTDEBMSG_(f, __ERROR_MSG)
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 getAsPose2DForcingOrigin(const TPoint2D &origin, TPose2D &outPose) const
TPlane()
Fast default constructor.
double wx
Angular velocity (rad/s)
Virtual base class for "archives": classes abstracting I/O streams.
double vx
Velocity components: X,Y (m/s)
void getAsPose3DForcingOrigin(const TPoint3D &newOrigin, TPose3D &pose)
void generate3DObject(TObject3D &obj) const
Project into 3D space.
void homogeneousMatrixInverse(const MATRIXLIKE1 &M, MATRIXLIKE2 &out_inverse_M)
Efficiently compute the inverse of a 4x4 homogeneous matrix by only transposing the rotation 3x3 part...
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.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
double coefs[4]
Plane coefficients, stored as an array: .
double getEpsilon()
Gets the value of the geometric epsilon (default = 1e-5)
TSegment2D()
Fast default constructor.
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
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.
TPose2D()
Default fast constructor.
GLfloat GLfloat GLfloat v2
unsigned char getType() const
Gets object type.
mrpt::math::TPose2D operator-(const mrpt::math::TPose2D &b) const
Operator "ominus" pose composition: "ret=this \ominus b".
static constexpr unsigned char GEOMETRIC_TYPE_POLYGON
Object type identifier for TPolygon2D or TPolygon3D.
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
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.
std::string asString() const
GLsizei GLsizei GLenum GLenum const GLvoid * data
std::string asString() const
GLubyte GLubyte GLubyte a
TPose3D operator-(const TPose3D &p)
Unary $$ operator: computes inverse SE(3) element.
static void getPlanes(const std::vector< TObject3D > &objs, std::vector< TPlane > &plns)
Static method to retrieve every plane included in a vector of objects.
const Scalar * const_iterator
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrix::Ptr &pObj)
double phi
Orientation (rads)
bool operator<(const TPoint2D &p) const
GLuint GLuint GLsizei GLenum type
static constexpr unsigned char GEOMETRIC_TYPE_PLANE
Object type identifier for TPlane.
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.
void composePose(const TPose3D other, TPose3D &result) const
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.