Go to the documentation of this file.
47 if (!m.fromMatlabStringFormat(
s))
50 m.rows() == 1 && m.cols() == 2,
"Wrong size of vector in ::fromString");
51 x = m.get_unsafe(0, 0);
52 y = m.get_unsafe(0, 1);
65 if (!m.fromMatlabStringFormat(
s))
68 m.rows() == 1 && m.cols() == 3,
"Wrong size of vector in ::fromString");
69 x = m.get_unsafe(0, 0);
70 y = m.get_unsafe(0, 1);
76 const double A_cosphi = cos(this->phi), A_sinphi = sin(this->phi);
78 const double new_x = this->
x +
b.x * A_cosphi -
b.y * A_sinphi;
79 const double new_y = this->
y +
b.x * A_sinphi +
b.y * A_cosphi;
88 const double B_cosphi = cos(
b.phi), B_sinphi = sin(
b.phi);
91 (this->
x -
b.x) * B_cosphi + (this->
y -
b.y) * B_sinphi;
93 -(this->
x -
b.x) * B_sinphi + (this->
y -
b.y) * B_cosphi;
107 if (!m.fromMatlabStringFormat(
s))
110 m.rows() == 1 && m.cols() == 3,
"Wrong size of vector in ::fromString");
111 vx = m.get_unsafe(0, 0);
112 vy = m.get_unsafe(0, 1);
119 const double nvx =
vx * cos(ang) -
vy * sin(ang);
120 const double nvy =
vx * sin(ang) +
vy * cos(ang);
144 if (!m.fromMatlabStringFormat(
s))
147 m.rows() == 1 && m.cols() == 6,
"Wrong size of vector in ::fromString");
148 for (
int i = 0; i < 3; i++) (*
this)[i] = m.get_unsafe(0, i);
149 for (
int i = 0; i < 3; i++)
150 (*
this)[3 + i] =
DEG2RAD(m.get_unsafe(0, 3 + i));
160 vx =
R(0, 0) *
t.vx +
R(0, 1) *
t.vy +
R(0, 2) *
t.vz;
161 vy =
R(1, 0) *
t.vx +
R(1, 1) *
t.vy +
R(1, 2) *
t.vz;
162 vz =
R(2, 0) *
t.vx +
R(2, 1) *
t.vy +
R(2, 2) *
t.vz;
164 wx =
R(0, 0) *
t.wx +
R(0, 1) *
t.wy +
R(0, 2) *
t.wz;
165 wy =
R(1, 0) *
t.wx +
R(1, 1) *
t.wy +
R(1, 2) *
t.wz;
166 wz =
R(2, 0) *
t.wx +
R(2, 1) *
t.wy +
R(2, 2) *
t.wz;
193 if (!m.fromMatlabStringFormat(
s))
196 m.rows() == 1 && m.cols() == 3,
"Wrong size of vector in ::fromString");
197 x = m.get_unsafe(0, 0);
198 y = m.get_unsafe(0, 1);
199 z = m.get_unsafe(0, 2);
226 const double cy = cos(
yaw * 0.5), sy = sin(
yaw * 0.5);
227 const double cp = cos(
pitch * 0.5), sp = sin(
pitch * 0.5);
228 const double cr = cos(
roll * 0.5), sr = sin(
roll * 0.5);
230 const double ccc = cr * cp * cy;
231 const double ccs = cr * cp * sy;
232 const double css = cr * sp * sy;
233 const double sss = sr * sp * sy;
234 const double scc = sr * cp * cy;
235 const double ssc = sr * sp * cy;
236 const double csc = cr * sp * cy;
237 const double scs = sr * cp * sy;
251 -0.5 *
q[3], 0.5 * (-csc + scs), -0.5 *
q[1],
252 -0.5 *
q[2], 0.5 * (-ssc - ccs), 0.5 *
q[0],
253 0.5 *
q[1], 0.5 * (ccc - sss), 0.5 *
q[3],
254 0.5 *
q[0], 0.5 * (-css - scc), -0.5 *
q[2]};
263 res.x =
R(0, 0) * l.
x +
R(0, 1) * l.
y +
R(0, 2) * l.
z + this->
x;
264 res.
y =
R(1, 0) * l.
x +
R(1, 1) * l.
y +
R(1, 2) * l.
z + this->
y;
265 res.
z =
R(2, 0) * l.
x +
R(2, 1) * l.
y +
R(2, 2) * l.
z + this->
z;
274 res.x = H(0, 0) *
g.x + H(0, 1) *
g.y + H(0, 2) *
g.z + H(0, 3);
275 res.y = H(1, 0) *
g.x + H(1, 1) *
g.y + H(1, 2) *
g.z + H(1, 3);
276 res.z = H(2, 0) *
g.x + H(2, 1) *
g.y + H(2, 2) *
g.z + H(2, 3);
282 const double cy = cos(
yaw);
283 const double sy = sin(
yaw);
284 const double cp = cos(
pitch);
285 const double sp = sin(
pitch);
286 const double cr = cos(
roll);
287 const double sr = sin(
roll);
290 cy * sp * sr - sy * cr,
291 cy * sp * cr + sy * sr,
293 sy * sp * sr + cy * cr,
294 sy * sp * cr - cy * sr,
298 R.loadFromArray(rot_vals);
308 "Homogeneous matrix is not orthogonal & normalized!: " +
314 "Homogeneous matrix is not orthogonal & normalized!: " +
320 "Homogeneous matrix is not orthogonal & normalized!: " +
324 pitch = atan2(-
R(2, 0), hypot(
R(0, 0),
R(1, 0)));
327 if ((fabs(
R(2, 1)) + fabs(
R(2, 2))) <
328 10 * std::numeric_limits<double>::epsilon())
352 yaw = atan2(
R(1, 2),
R(0, 2));
354 yaw = atan2(-
R(1, 2), -
R(0, 2));
358 roll = atan2(
R(2, 1),
R(2, 2));
360 yaw = atan2(
R(1, 0),
R(0, 0));
382 HG.block<3, 3>(0, 0) =
R;
386 HG(3, 0) = HG(3, 1) = HG(3, 2) = 0.;
398 if (!m.fromMatlabStringFormat(
s))
401 m.rows() == 1 && m.cols() == 6,
"Wrong size of vector in ::fromString");
402 x = m.get_unsafe(0, 0);
403 y = m.get_unsafe(0, 1);
404 z = m.get_unsafe(0, 2);
413 if (!m.fromMatlabStringFormat(
s))
416 m.rows() == 1 && m.cols() == 7,
"Wrong size of vector in ::fromString");
417 for (
int i = 0; i < m.cols(); i++) (*
this)[i] = m.get_unsafe(0, i);
422 p.getInverseHomogeneousMatrix(H);
431 a.getInverseHomogeneousMatrix(Hainv);
432 b.getHomogeneousMatrix(Hb);
441 return (o <<
p.asString());
445 return (o <<
p.asString());
449 return (o <<
p.asString());
453 return (o <<
p.asString());
457 return (o <<
p.asString());
462 return in >>
s.point1 >>
s.point2;
466 return out <<
s.point1 <<
s.point2;
479 return in >>
s.point1 >>
s.point2;
483 return out <<
s.point1 <<
s.point2;
495 return in >>
p.coefs[0] >>
p.coefs[1] >>
p.coefs[2] >>
p.coefs[3];
499 return out <<
p.coefs[0] <<
p.coefs[1] <<
p.coefs[2] <<
p.coefs[3];
518 const double d3 =
length();
519 const double ds1 =
square(d1);
520 const double ds2 =
square(d2);
521 const double ds3 =
square(d3);
522 if (ds1 > (ds2 + ds3) || ds2 > (ds1 + ds3))
543 throw std::logic_error(
"Segment is normal to projection plane");
565 Eigen::Vector3d u,
v,
w;
577 double D =
a *
c -
b *
b;
578 double sc, sN, sD = D;
579 double tc, tN, tD = D;
591 sN = (
b * e -
c * d);
592 tN = (
a * e -
b * d);
627 else if ((-d +
b) >
a)
636 sc = (fabs(sN) < 0.00000001 ? 0.0 : sN / sD);
637 tc = (fabs(tN) < 0.00000001 ? 0.0 : tN / tD);
681 vector[0] =
coefs[0];
682 vector[1] =
coefs[1];
687 for (
size_t i = 0; i < 3; i++)
coefs[i] /=
s;
691 vector[0] = -
coefs[1];
692 vector[1] =
coefs[0];
716 throw std::logic_error(
"Base point is not contained in the line");
723 if (p1 == p2)
throw logic_error(
"Both points are the same");
730 coefs[0] =
s.point2.y -
s.point1.y;
731 coefs[1] =
s.point1.x -
s.point2.x;
732 coefs[2] =
s.point2.x *
s.point1.y -
s.point2.y *
s.point1.x;
739 throw std::logic_error(
"Line is normal to projection plane");
767 double dv = 0, d2 = 0,
v2 = 0;
768 for (
size_t i = 0; i < 3; i++)
774 return sqrt(d2 - (dv * dv) /
v2);
778 double s = sqrt(squareNorm<3, double>(
director));
779 for (
size_t i = 0; i < 3; i++)
director[i] /=
s;
784 throw logic_error(
"Both points are the same");
819 return dotProduct<3, double>(
coefs, point) +
coefs[3];
844 vector[0] =
coefs[0];
845 vector[1] =
coefs[1];
846 vector[2] =
coefs[2];
850 double s = sqrt(squareNorm<3, double>(
coefs));
851 for (
size_t i = 0; i < 4; i++)
coefs[i] /=
s;
861 for (
size_t i = 0; i < 3; i++)
872 throw std::logic_error(
"Base point is not in the plane.");
877 for (
size_t i = 0; i < 3; i++) AXIS.set_unsafe(i, 3, newOrigin[i]);
882 double dx1 = p2.
x - p1.
x;
883 double dy1 = p2.
y - p1.
y;
884 double dz1 = p2.
z - p1.
z;
885 double dx2 = p3.
x - p1.
x;
886 double dy2 = p3.
y - p1.
y;
887 double dz2 = p3.
z - p1.
z;
888 coefs[0] = dy1 * dz2 - dy2 * dz1;
889 coefs[1] = dz1 * dx2 - dz2 * dx1;
890 coefs[2] = dx1 * dy2 - dx2 * dy1;
893 throw logic_error(
"Points are linearly dependent");
898 double dx1 = p1.
x - r2.
pBase.
x;
899 double dy1 = p1.
y - r2.
pBase.
y;
900 double dz1 = p1.
z - r2.
pBase.
z;
906 throw logic_error(
"Point is contained in the line");
918 if (r1.
contains(r2.
pBase))
throw std::logic_error(
"Lines are the same");
922 for (
size_t i = 0; i < 3; i++) d[i] = r1.
pBase[i] - r2.
pBase[i];
928 throw logic_error(
"Lines do not intersect");
934 size_t N = poly.size();
936 std::vector<size_t> unused;
942 for (
size_t i = 1; i < N - 1; i++)
952 unused.push_back(N - 1);
955 for (
size_t i = 0; i < unused.size() - 1; i++)
957 size_t last = unused[i + 1];
958 for (
size_t j = unused[i] + 1 - diff; j < last - diff; j++)
959 poly[j] = poly[j + diff];
961 poly.resize(N + 1 - unused.size());
966 size_t N = poly.size();
968 std::vector<size_t> rep;
969 for (
size_t i = 0; i < N - 1; i++)
973 rep.push_back(N - 1);
976 for (
size_t i = 0; i < rep.size() - 1; i++)
978 size_t last = rep[i + 1];
979 for (
size_t j = rep[i] + 1 - diff; j < last - diff; j++)
980 poly[j] = poly[j + diff];
982 poly.resize(N + 1 - rep.size());
988 std::vector<TSegment2D> sgs;
994 double distance = std::numeric_limits<double>::max();
999 double d = (*it).distance(point);
1008 ASSERTMSG_(!this->
empty(),
"getBoundingBox() called on an empty polygon!");
1009 min_coords.
x = min_coords.
y = std::numeric_limits<double>::max();
1010 max_coords.
x = max_coords.
y = -std::numeric_limits<double>::max();
1011 for (
size_t i = 0; i <
size(); i++)
1030 return ((P1.
x - P0.
x) * (P2.
y - P0.
y) - (P2.
x - P0.
x) * (P1.
y - P0.
y));
1038 const size_t n = this->
size();
1039 for (
size_t i = 0; i <
n; i++)
1041 if ((*
this)[i].
y <= P.
y)
1044 if ((*
this)[(i + 1) %
n].
y > P.
y)
1045 if (
isLeft((*
this)[i], (*
this)[(i + 1) %
n], P) >
1052 if ((*
this)[(i + 1) %
n].
y <= P.
y)
1053 if (
isLeft((*
this)[i], (*
this)[(i + 1) %
n], P) <
1065 for (
size_t i = 0; i < N - 1; i++)
1066 v[i] =
TSegment2D(
operator[](i),
operator[](i + 1));
1067 v[N - 1] =
TSegment2D(
operator[](N - 1),
operator[](0));
1075 template <
class T,
int N>
1082 for (
size_t i = 0; i < N; i++)
object[i] = 0.0;
1086 for (
size_t i = 0; i < N; i++)
object[i] += o[i];
1099 if (N <= 3)
return true;
1100 vector<TSegment2D> sgms;
1102 for (
size_t i = 0; i < N; i++)
1106 for (
size_t j = 0; j < N; j++)
1112 s = (d > 0) ? 1 : -1;
1113 else if (
s != ((d > 0) ? 1 : -1))
1126 std::vector<double>&
x, std::vector<double>&
y)
const
1131 for (
size_t i = 0; i < N; i++)
1141 size_t N =
p.
size();
1143 for (
size_t i = 0; i < N; i++)
operator[](i) =
TPoint2D(
p[i]);
1146 size_t numEdges,
double radius,
TPolygon2D& 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 *
M_PI * 2 / numEdges;
1155 poly[i] =
TPoint2D(radius * cos(angle), radius * sin(angle));
1162 for (
size_t i = 0; i < numEdges; i++) poly[i] = pose.
composePoint(poly[i]);
1169 throw std::logic_error(
"Polygon does not conform a plane");
1177 return sqrt(newPoint.
z * newPoint.
z + distance2D * distance2D);
1189 throw std::logic_error(
"Polygon does not conform a plane");
1208 for (
size_t i = 0; i < N - 1; i++)
1209 v[i] =
TSegment3D(
operator[](i),
operator[](i + 1));
1210 v[N - 1] =
TSegment3D(
operator[](N - 1),
operator[](0));
1234 size_t N =
p.
size();
1236 for (
size_t i = 0; i < N; i++)
operator[](i) =
p[i];
1239 size_t numEdges,
double radius,
TPolygon3D& poly)
1241 if (numEdges < 3 || abs(radius) <
getEpsilon())
1242 throw std::logic_error(
1243 "Invalid arguments for regular polygon creations");
1244 poly.resize(numEdges);
1245 for (
size_t i = 0; i < numEdges; i++)
1247 double angle = i * 2 *
M_PI / numEdges;
1248 poly[i] =
TPoint3D(radius * cos(angle), radius * sin(angle), 0);
1255 for (
size_t i = 0; i < numEdges; i++) pose.
composePoint(poly[i], poly[i]);
1280 const std::vector<TObject2D>& objs, std::vector<TPoint2D>& pnts)
1284 if (it->isPoint()) pnts.push_back(it->data.point);
1287 const std::vector<TObject2D>& objs, std::vector<TSegment2D>& sgms)
1291 if (it->isSegment()) sgms.push_back(it->data.segment);
1294 const std::vector<TObject2D>& objs, std::vector<TLine2D>& lins)
1298 if (it->isLine()) lins.push_back(it->data.line);
1301 const std::vector<TObject2D>& objs, std::vector<TPolygon2D>& polys)
1305 if (it->isPolygon()) polys.push_back(*(it->data.polygon));
1308 const std::vector<TObject2D>& objs, std::vector<TPoint2D>& pnts,
1309 std::vector<TObject2D>& remainder)
1314 pnts.push_back(it->data.point);
1316 remainder.push_back(*it);
1319 const std::vector<TObject2D>& objs, std::vector<TSegment2D>& sgms,
1320 std::vector<TObject2D>& remainder)
1324 if (it->isSegment())
1325 sgms.push_back(it->data.segment);
1327 remainder.push_back(*it);
1330 const std::vector<TObject2D>& objs, std::vector<TLine2D>& lins,
1331 std::vector<TObject2D>& remainder)
1336 lins.push_back(it->data.line);
1338 remainder.push_back(*it);
1341 const std::vector<TObject2D>& objs, std::vector<TPolygon2D>& polys,
1342 vector<TObject2D>& remainder)
1346 if (it->isPolygon())
1347 polys.push_back(*(it->data.polygon));
1349 remainder.push_back(*it);
1352 const std::vector<TObject3D>& objs, std::vector<TPoint3D>& pnts)
1356 if (it->isPoint()) pnts.push_back(it->data.point);
1359 const std::vector<TObject3D>& objs, std::vector<TSegment3D>& sgms)
1363 if (it->isSegment()) sgms.push_back(it->data.segment);
1366 const std::vector<TObject3D>& objs, std::vector<TLine3D>& lins)
1370 if (it->isLine()) lins.push_back(it->data.line);
1373 const std::vector<TObject3D>& objs, std::vector<TPlane>& plns)
1377 if (it->isPlane()) plns.push_back(it->data.plane);
1380 const std::vector<TObject3D>& objs, std::vector<TPolygon3D>& polys)
1384 if (it->isPolygon()) polys.push_back(*(it->data.polygon));
1387 const std::vector<TObject3D>& objs, std::vector<TPoint3D>& pnts,
1388 std::vector<TObject3D>& remainder)
1393 pnts.push_back(it->data.point);
1395 remainder.push_back(*it);
1398 const std::vector<TObject3D>& objs, std::vector<TSegment3D>& sgms,
1399 std::vector<TObject3D>& remainder)
1403 if (it->isSegment())
1404 sgms.push_back(it->data.segment);
1406 remainder.push_back(*it);
1409 const std::vector<TObject3D>& objs, std::vector<TLine3D>& lins,
1410 std::vector<TObject3D>& remainder)
1415 lins.push_back(it->data.line);
1417 remainder.push_back(*it);
1420 const std::vector<TObject3D>& objs, std::vector<TPlane>& plns,
1421 std::vector<TObject3D>& remainder)
1426 plns.push_back(it->data.plane);
1428 remainder.push_back(*it);
1431 const std::vector<TObject3D>& objs, std::vector<TPolygon3D>& polys,
1432 vector<TObject3D>& remainder)
1436 if (it->isPolygon())
1437 polys.push_back(*(it->data.polygon));
1439 remainder.push_back(*it);
1444 for (
unsigned int i = 0; i < o.
size(); i++)
in >> o[i];
1449 for (
unsigned int i = 0; i < o.
size(); i++) out << o[i];
1455 for (
unsigned int i = 0; i < o.
size(); i++)
in >> o[i];
1460 for (
unsigned int i = 0; i < o.
size(); i++) out << o[i];
1468 switch (
static_cast<unsigned char>(
type))
1504 throw std::logic_error(
1505 "Unknown TObject2D type found while reading stream");
1511 out << static_cast<uint16_t>(o.
getType());
1546 switch (
static_cast<unsigned char>(
type))
1589 throw std::logic_error(
1590 "Unknown TObject3D type found while reading stream");
1596 out << static_cast<uint16_t>(o.
getType());
static void createRegularPolygon(size_t numEdges, double radius, TPolygon2D &poly)
Static method to create a regular polygon, given its size and radius.
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.
double distance(const TPoint3D &point) const
Distance to 3D point.
double distance(const TPoint2D &point) const
Distance to a point (always >=0)
void fromHomogeneousMatrix(const mrpt::math::CMatrixDouble44 &HG)
void rotate(const double ang)
Transform the (vx,vy) components for a counterclockwise rotation of ang radians.
bool contains(const TPoint3D &point) const
Check whether a point is inside the segment.
static constexpr unsigned char GEOMETRIC_TYPE_UNDEFINED
Object type identifier for empty TObject2D or TObject3D.
double vx
Velocity components: X,Y (m/s)
TPolygon3D()
Default constructor.
void getDirectorVector(double(&vector)[2]) const
Get line's director vector.
EIGEN_STRONG_INLINE iterator begin()
static constexpr size_t size()
3D twist: 3D velocity vector (vx,vy,vz) + angular velocity (wx,wy,wz)
bool getSegment(TSegment3D &s) const
Gets the content as a segment, returning false if the type is not adequate.
const Scalar * const_iterator
static void getPlanes(const std::vector< TObject3D > &objs, std::vector< TPlane > &plns)
Static method to retrieve every plane included in a vector of objects.
std::ostream & operator<<(std::ostream &o, const TPoint2D &p)
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -45....
static void getPolygons(const std::vector< TObject2D > &objs, std::vector< TPolygon2D > &polys)
Static method to retrieve all the polygons in a vector of TObject2D.
void removeUnusedVertices(T &poly)
GLdouble GLdouble GLdouble GLdouble q
unsigned __int16 uint16_t
std::string asString() const
bool operator<(const TPoint3D &p) const
void composePoint(const TPoint3D l, TPoint3D &g) const
bool contains(const TPoint2D &point) const
Check whether a point is inside a segment.
TPlane()
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....
double phi
Orientation (rads)
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
TPoint3D pBase
Base point.
static void getPoints(const std::vector< TObject3D > &objs, std::vector< TPoint3D > &pnts)
Static method to retrieve every point included in a vector of objects.
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn't exist already.
std::string asString() const
TPose3D operator-(const TPose3D &p)
Unary $\ominus$ operator: computes inverse SE(3) element.
double distance(const TPoint2D &point) const
Distance to point.
double length() const
Segment length.
bool contains(const TPoint2D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
static constexpr unsigned char GEOMETRIC_TYPE_POLYGON
Object type identifier for TPolygon2D or TPolygon3D.
mrpt::math::TPose2D operator-(const mrpt::math::TPose2D &b) const
Operator "ominus" pose composition: "ret=this \ominus b".
bool getPolygon(TPolygon2D &p) const
Gets the content as a polygon, returning false if the type is inadequate.
void getPlotData(std::vector< double > &x, std::vector< double > &y) const
Gets plot data, ready to use on a 2D plot.
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...
GLsizei GLsizei GLuint * obj
double distance(const TPoint2D &point) const
Distance from a given point.
void getCenter(TPoint3D &p) const
Get polygon's central point.
double evaluatePoint(const TPoint2D &point) const
Evaluate point in the line's equation.
bool getPolygon(TPolygon3D &p) const
Gets the content as a polygon, returning false if the type is not adequate.
TPoint3D()
Default fast constructor.
unsigned char getType() const
Gets content type.
double getRegressionPlane(const std::vector< TPoint3D > &points, TPlane &plane)
Using eigenvalues, gets the best fitting plane for a set of 3D points.
bool getPlane(TPlane &p) const
Gets the content as a plane, returning false if the type is not adequate.
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.
Standard type for storing any lightweight 2D type.
bool getSegment(TSegment2D &s) const
Gets the content as a segment, returning false if the type is inadequate.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[vx vy vz wx wy wz]" )
double vx
Velocity components: X,Y (m/s)
Standard object for storing any 3D lightweight object.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04]" )
GLubyte GLubyte GLubyte GLubyte w
GLuint GLuint GLsizei GLenum type
#define THROW_EXCEPTION(msg)
bool isSkew() const
Check whether the polygon is skew.
T square(const T x)
Inline function for the square of a number.
double RAD2DEG(const double x)
Radians to degrees.
double distance(const TPoint3D &point) const
Distance between the line and a 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.
void getPrismBounds(const std::vector< TPoint3D > &poly, TPoint3D &pMin, TPoint3D &pMax)
Gets the prism bounds of a 3D polygon or set of 3D points.
TSegment2D()
Fast default constructor.
static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
void inverseComposePoint(const TPoint3D g, TPoint3D &l) const
bool getLine(TLine2D &r) const
Gets the content as a line, returning false if the type is inadequate.
Virtual base class for "archives": classes abstracting I/O streams.
TPoint3D point1
Origin point.
bool isConvex() const
Checks whether is convex.
void getNormalVector(double(&vector)[2]) const
Get line's normal vector.
static void getSegments(const std::vector< TObject3D > &objs, std::vector< TSegment3D > &sgms)
Static method to retrieve every segment included in a vector of objects.
double distance(const TPoint3D &point) const
Distance to point (always >=0)
void composePose(const TPose3D other, TPose3D &result) const
mrpt::math::TPoint2D composePoint(const TPoint2D l) const
bool contains(const TPoint3D &point) const
Check whether a point is contained into the plane.
bool contains(const TPoint2D &point) const
Check whether a point is inside the line.
double coefs[3]
Line coefficients, stored as an array: .
static void getLines(const std::vector< TObject3D > &objs, std::vector< TLine3D > &lins)
Static method to retrieve every line included in a vector of objects.
TLine3D()
Fast default constructor.
void generate3DObject(TLine3D &l) const
Project into 3D space, setting the z to 0.
void getCenter(TPoint2D &p) const
Polygon's central point.
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 distance(const TPoint3D &point) const
Distance to point.
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &HG) const
bool getPoint(TPoint3D &p) const
Gets the content as a point, returning false if the type is not adequate.
void getUnitaryNormalVector(double(&vec)[3])
Unitarize, then get normal vector.
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrix::Ptr &pObj)
void loadFromArray(const T *vals)
void removeRepeatedVertices()
Remove polygon's repeated vertices.
GLsizei GLsizei GLenum GLenum const GLvoid * data
bool operator!=(const TTwist3D &o) const
TPoint3D point2
Destiny point.
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
mrpt::math::TPose2D operator+(const mrpt::math::TPose2D &b) const
Operator "oplus" pose composition: "ret=this \oplus b".
mrpt::math::TPose2D operator*(const double dt) const
Returns the pose increment of multiplying each twist component times "dt" seconds.
TPolygon2D()
Default constructor
void removeRedundantVertices()
Erase every redundant vertex, thus saving space.
void getRotationMatrix(mrpt::math::CMatrixDouble33 &R) const
GLfloat GLfloat GLfloat v2
void generate3DObject(TObject3D &obj) const
Project into 3D space.
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...
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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 signedDistance(const TPoint2D &point) const
Distance with sign to point (sign indicates which side the point is).
double x
X,Y,Z coordinates.
void removeRedundantVertices()
Erase every redundant vertex from the polygon, saving space.
std::string asString() const
void operator()(const T &o)
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -45....
void getAsVector(VECTORLIKE &v) const
Transformation into vector.
static constexpr unsigned char GEOMETRIC_TYPE_PLANE
Object type identifier for TPlane.
size_t size(const MATRIXLIKE &m, const int dim)
void removeRepeatedVertices()
Erase repeated vertices.
void getAsPose3D(mrpt::math::TPose3D &outPose)
bool contains(const TPoint3D &point) const
Check whether a point is inside the line.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
bool conformAPlane(const std::vector< TPoint3D > &points)
Checks whether this polygon or set of points acceptably fits a plane.
2D polygon, inheriting from std::vector<TPoint2D>.
3D polygon, inheriting from std::vector<TPoint3D>
2D segment, consisting of two points.
3D segment, consisting of two points.
std::string asString() const
static void getPolygons(const std::vector< TObject3D > &objs, std::vector< TPolygon3D > &polys)
Static method to retrieve every polygon included in a vector of objects.
void getInverseHomogeneousMatrix(mrpt::math::CMatrixDouble44 &HG) const
TPoint2D()
Default fast constructor.
double pitch
Pitch coordinate (rotation angle over Y axis).
void generate3DObject(TPolygon3D &p) const
Projects into 3D space, zeroing the z.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
static constexpr unsigned char GEOMETRIC_TYPE_POINT
Object type identifier for TPoint2D or TPoint3D.
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 wx
Angular velocity (rad/s)
3D Plane, represented by its equation
static constexpr unsigned char GEOMETRIC_TYPE_LINE
Object type identifier for TLine2D or TLine3D.
bool operator<(const TSegment2D &s) const
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,...
bool getLine(TLine3D &r) const
Gets the content as a line, returning false if the type is not adequate.
void getNormalVector(double(&vec)[3]) const
Get plane's normal vector.
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ,...
void getBoundingBox(TPoint2D &min_coords, TPoint2D &max_coords) const
Get polygon bounding box.
void unitarize()
Unitarize director vector.
static void SO3_to_yaw_pitch_roll(const mrpt::math::CMatrixDouble33 &R, double &yaw, double &pitch, double &roll)
TPose3D()
Default fast constructor.
double yaw
Yaw coordinate (rotation angle over Z axis).
void getAsPose3DForcingOrigin(const TPoint3D &newOrigin, TPose3D &pose)
double roll
Roll coordinate (rotation angle over X coordinate).
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
void getAsSegmentList(std::vector< TSegment3D > &v) const
Gets as set of segments, instead of set of points.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
TLine2D()
Fast default constructor.
void getAsPose2D(TPose2D &outPose) const
TPose2D()
Default fast constructor.
void unitarize()
Unitarize line's normal vector.
void getBestFittingPlane(TPlane &p) const
Gets the best fitting plane, disregarding whether the polygon actually fits inside or not.
#define ASSERTDEBMSG_(f, __ERROR_MSG)
void unitarize()
Unitarize normal vector.
double getAngle(const TPlane &p1, const TPlane &p2)
Computes the angle between two planes.
bool operator!=(const TTwist2D &o) const
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D &poly)
Static method to create a regular polygon, given its size and radius.
void removeRepVertices(T &poly)
double evaluatePoint(const TPoint3D &point) const
Evaluate a point in the plane's equation.
2D line without bounds, represented by its equation .
double signedDistance(const TPoint2D &point) const
Distance with sign from a given point (sign indicates side).
double isLeft(const mrpt::math::TPoint2D &P0, const mrpt::math::TPoint2D &P1, const mrpt::math::TPoint2D &P2)
EIGEN_STRONG_INLINE bool empty() const
3D line, represented by a base point and a director vector.
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
GLsizei const GLchar ** string
void getAsPose2DForcingOrigin(const TPoint2D &origin, TPose2D &outPose) const
static void getPoints(const std::vector< TObject2D > &objs, std::vector< TPoint2D > &pnts)
Static method to retrieve all the points in a vector of TObject2D.
unsigned char getType() const
Gets object type.
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 getPlane(TPlane &p) const
Gets a plane which contains the polygon.
TPoint2D point1
Origin point.
bool operator<(const TPoint2D &p) const
TPoint2D point2
Destiny point.
bool operator<(const TSegment3D &s) const
bool operator==(const TTwist2D &o) const
double length() const
Segment length.
#define MRPT_MAX_ALIGN_BYTES
double omega
Angular velocity (rad/s)
double director[3]
Director vector.
double coefs[4]
Plane coefficients, stored as an array: .
void getAsSegmentList(std::vector< TSegment2D > &v) const
Gets as set of segments, instead of points.
bool contains(const TPoint3D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
double getEpsilon()
Gets the value of the geometric epsilon (default = 1e-5)
GLubyte GLubyte GLubyte a
bool getPoint(TPoint2D &p) const
Gets the content as a point, returning false if the type is inadequate.
bool operator==(const TTwist3D &o) const
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
void generate3DObject(TSegment3D &s) const
Project into 3D space, setting the z to 0.
double DEG2RAD(const double x)
Degrees to radians.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |