Main MRPT website > C++ reference for MRPT 1.9.9
CPose3DRotVec.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/poses/CPose3D.h>
13 #include <mrpt/poses/CPoint2D.h>
14 #include <mrpt/poses/CPose3DQuat.h>
16 #include <mrpt/poses/CPoint3D.h>
17 #include <mrpt/math/geometry.h> // skew_symmetric3()
18 #include <mrpt/utils/CStream.h>
19 #include <iomanip>
20 #include <limits>
21 
22 using namespace mrpt;
23 using namespace mrpt::math;
24 using namespace mrpt::utils;
25 using namespace mrpt::poses;
26 
28 
29 MRPT_TODO("Complete missing methods")
30 
31 /*---------------------------------------------------------------
32  Constructors
33  ---------------------------------------------------------------*/
35 {
36  m_coords[0] = m(0, 3);
37  m_coords[1] = m(1, 3);
38  m_coords[2] = m(2, 3);
39 
40  m_rotvec = rotVecFromRotMat(m);
41 }
42 
44 {
45  m_coords[0] = m.x();
46  m_coords[1] = m.y();
47  m_coords[2] = m.z();
50  m_rotvec = rotVecFromRotMat(R);
51 }
52 
53 /** Constructor from a quaternion (which only represents the 3D rotation part)
54  * and a 3D displacement. */
56  const mrpt::math::CQuaternionDouble& q, const double _x, const double _y,
57  const double _z)
58 {
59  m_coords[0] = _x;
60  m_coords[1] = _y;
61  m_coords[2] = _z;
62  const double a = sqrt(q.x() * q.x() + q.y() * q.y() + q.z() * q.z());
63  const double TH = 0.001;
64  const double k = a < TH ? 2 : 2 * acos(q.r()) / sqrt(1 - q.r() * q.r());
65  m_rotvec[0] = k * q.x();
66  m_rotvec[1] = k * q.y();
67  m_rotvec[2] = k * q.z();
68 }
69 
70 /*---------------------------------------------------------------
71  Implements the writing to a CStream capability of
72  CSerializable objects
73  ---------------------------------------------------------------*/
74 void CPose3DRotVec::writeToStream(mrpt::utils::CStream& out, int* version) const
75 {
76  if (version)
77  *version = 0;
78  else
79  {
80  out << m_coords[0] << m_coords[1] << m_coords[2] << m_rotvec[0]
81  << m_rotvec[1] << m_rotvec[2];
82  }
83 }
84 
85 /*---------------------------------------------------------------
86  Implements the reading from a CStream capability of
87  CSerializable objects
88  ---------------------------------------------------------------*/
90 {
91  switch (version)
92  {
93  case 0:
94  {
95  in >> m_coords[0] >> m_coords[1] >> m_coords[2] >> m_rotvec[0] >>
96  m_rotvec[1] >> m_rotvec[2];
97  }
98  break;
99  default:
101  };
102 }
103 
105  const double x, const double y, const double z, const double yaw,
106  const double pitch, const double roll)
107 {
108  CPose3D aux(x, y, z, yaw, pitch, roll);
109  this->m_coords[0] = aux.m_coords[0];
110  this->m_coords[1] = aux.m_coords[1];
111  this->m_coords[2] = aux.m_coords[2];
112  this->m_rotvec = aux.ln_rotation();
113 }
114 
116 {
117  // go through cpose3d
118  CArrayDouble<3> out;
119  CPose3D aux(m);
120  out = aux.ln_rotation();
121  return out;
122 } // end-rotVecFromRotMat
123 
124 /** Textual output stream function.
125  */
126 std::ostream& mrpt::poses::operator<<(std::ostream& o, const CPose3DRotVec& p)
127 {
128  const std::streamsize old_pre = o.precision();
129  const std::ios_base::fmtflags old_flags = o.flags();
130  o << "(x,y,z,vx,vy,vz)=(" << std::fixed << std::setprecision(4)
131  << p.m_coords[0] << "," << p.m_coords[1] << "," << p.m_coords[2] << ","
132  << p.m_rotvec[0] << "," << p.m_rotvec[1] << "," << p.m_rotvec[2] << ")";
133  o.flags(old_flags);
134  o.precision(old_pre);
135  return o;
136 }
137 
138 /** Get the 3x3 rotation matrix \sa getHomogeneousMatrix */
140 {
141  // through cpose3D
142  ROT = CPose3D().exp_rotation(this->m_rotvec);
143  // cout << "CPOSE_3D: " << ROT;
144 }
145 
146 /*---------------------------------------------------------------
147  sphericalCoordinates
148 ---------------------------------------------------------------*/
150  const TPoint3D& point, double& out_range, double& out_yaw,
151  double& out_pitch) const
152 {
153  // Pass to coordinates as seen from this 6D pose:
154  TPoint3D local;
155  this->inverseComposePoint(
156  point.x, point.y, point.z, local.x, local.y, local.z);
157 
158  // Range:
159  out_range = local.norm();
160 
161  // Yaw:
162  if (local.y != 0 || local.x != 0)
163  out_yaw = atan2(local.y, local.x);
164  else
165  out_yaw = 0;
166 
167  // Pitch:
168  if (out_range != 0)
169  out_pitch = -asin(local.z / out_range);
170  else
171  out_pitch = 0;
172 }
173 
174 /*---------------------------------------------------------------
175  composePoint
176 ---------------------------------------------------------------*/
178  double lx, double ly, double lz, double& gx, double& gy, double& gz,
179  mrpt::math::CMatrixFixedNumeric<double, 3, 3>* out_jacobian_df_dpoint,
180  mrpt::math::CMatrixFixedNumeric<double, 3, 6>* out_jacobian_df_dpose) const
181 {
182  const double angle = this->m_rotvec.norm();
183  const double K1 = sin(angle) / angle;
184  const double K2 = (1 - cos(angle)) / (angle * angle);
185 
186  const double tx = this->m_coords[0];
187  const double ty = this->m_coords[1];
188  const double tz = this->m_coords[2];
189 
190  const double w1 = this->m_rotvec[0];
191  const double w2 = this->m_rotvec[1];
192  const double w3 = this->m_rotvec[2];
193 
194  const double w1_2 = w1 * w1;
195  const double w2_2 = w2 * w2;
196  const double w3_2 = w3 * w3;
197 
198  gx = lx * (1 - K2 * (w2_2 + w3_2)) + ly * (K2 * w1 * w2 - K1 * w3) +
199  lz * (K1 * w2 + K2 * w1 * w3) + tx;
200  gy = lx * (K1 * w3 + K2 * w1 * w2) + ly * (1 - K2 * (w1_2 + w3_2)) +
201  lz * (K2 * w2 * w3 - K1 * w1) + ty;
202  gz = lx * (K2 * w1 * w3 - K1 * w2) + ly * (K1 * w1 + K2 * w2 * w3) +
203  lz * (1 - K2 * (w1_2 + w2_2)) + tz;
204 
205  if (out_jacobian_df_dpoint || out_jacobian_df_dpose)
206  {
207  MRPT_TODO("Jacobians")
208  THROW_EXCEPTION("Jacobians not implemented yet")
209  }
210 }
211 
212 /*---------------------------------------------------------------
213  unary -
214 ---------------------------------------------------------------*/
216 {
218  b.getInverseHomogeneousMatrix(B_INV);
219  return CPose3DRotVec(B_INV);
220 }
221 
223 {
224  return (p1.m_coords == p2.m_coords) && (p1.m_rotvec == p2.m_rotvec);
225 }
226 
228 {
229  return (p1.m_coords != p2.m_coords) || (p1.m_rotvec != p2.m_rotvec);
230 }
231 
232 /*---------------------------------------------------------------
233  point3D = pose3D + point3D
234  ---------------------------------------------------------------*/
236 {
237  CPoint3D outPoint;
238 
239  this->composePoint(
240  b.m_coords[0], b.m_coords[1], b.m_coords[2], outPoint.m_coords[0],
241  outPoint.m_coords[1], outPoint.m_coords[2]);
242 
243  return outPoint;
244 }
245 
246 /*---------------------------------------------------------------
247  point3D = pose3D + point2D
248  ---------------------------------------------------------------*/
250 {
251  CPoint3D outPoint;
252 
253  this->composePoint(
254  b.m_coords[0], b.m_coords[1], 0, outPoint.m_coords[0],
255  outPoint.m_coords[1], outPoint.m_coords[2]);
256 
257  return outPoint;
258 }
259 
261 {
262  q.m_coords[0] = this->m_coords[0];
263  q.m_coords[1] = this->m_coords[1];
264  q.m_coords[2] = this->m_coords[2];
265 
266  const double a = sqrt(
267  this->m_rotvec[0] * this->m_rotvec[0] +
268  this->m_rotvec[1] * this->m_rotvec[1] +
269  this->m_rotvec[2] * this->m_rotvec[2]);
270  if (a < 0.001)
271  {
272  q.m_quat.r(1);
273  q.m_quat.x(0.5 * this->m_rotvec[0]);
274  q.m_quat.y(0.5 * this->m_rotvec[1]);
275  q.m_quat.z(0.5 * this->m_rotvec[2]);
276  // TO DO: output of the jacobian
277  // df_dr = 0.25*[-r';2*eye(3)];
278  }
279  else
280  {
281  q.m_quat.fromRodriguesVector(this->m_rotvec);
282 
283  // TO DO: output of the jacobian
284  // a2 = a*a;
285  // a3 = a2*a;
286  //
287  // r1 = r(1);
288  // r2 = r(2);
289  // r3 = r(3);
290  // s = sin(a/2);
291  // c = cos(a/2);
292  //
293  // A = a*c-2*s;
294  //
295  // df_dr = 1/a3*[-r1*a2*s -r2*a2*s -r3*a2*s; ...
296  // 2*a2*s+r1*r1*A r1*r2*A r1*r3*A; ...
297  // r1*r2*A 2*a2*s+r2*r2*A r2*r3*A; ...
298  // r1*r3*A r2*r3*A 2*a2*s+r3*r3*A]; % jacobian of
299  // transf.
300  //
301  }
302 }
303 
304 /*---------------------------------------------------------------
305  this = A + B
306  ---------------------------------------------------------------*/
308  const CPose3DRotVec& A, const CPose3DRotVec& B,
309  mrpt::math::CMatrixFixedNumeric<double, 6, 6>* out_jacobian_drvtC_drvtA,
310  mrpt::math::CMatrixFixedNumeric<double, 6, 6>* out_jacobian_drvtC_drvtB)
311 
312 {
313  const double a1 = A.m_rotvec.norm(); // angles
314  const double a2 = B.m_rotvec.norm();
315 
316  // if the angles are small, we can compute the approximate composition
317  // easily
318  if (a1 < 0.01 && a2 < 0.01)
319  {
320  const CMatrixDouble33 Ra = Eigen::MatrixXd::Identity(3, 3) +
322 
323  this->m_rotvec = A.m_rotvec + B.m_rotvec;
324  this->m_coords = A.m_coords + Ra * B.m_coords;
325 
326  if (out_jacobian_drvtC_drvtA || out_jacobian_drvtC_drvtB)
327  {
328  if (out_jacobian_drvtC_drvtA) // jacobian wrt A
329  {
330  out_jacobian_drvtC_drvtA->setIdentity(6, 6);
331  out_jacobian_drvtC_drvtA->insertMatrix(
333  }
334 
335  if (out_jacobian_drvtC_drvtB) // jacobian wrt B
336  {
337  out_jacobian_drvtC_drvtB->setIdentity(6, 6);
338  out_jacobian_drvtC_drvtB->insertMatrix(
340  (*out_jacobian_drvtC_drvtB)(3, 3) = (*out_jacobian_drvtC_drvtB)(
341  4, 4) = (*out_jacobian_drvtC_drvtB)(5, 5) = 1;
342  }
343  }
344  return;
345  }
346 
347  CMatrixDouble33 RA, RB;
348  A.getRotationMatrix(RA);
349  B.getRotationMatrix(RB);
350 
351  // Translation part
353  this->m_coords[0] = coords[0];
354  this->m_coords[1] = coords[1];
355  this->m_coords[2] = coords[2];
356 
357 // Rotation part:
358 #if 0
359  else if (A_is_small) this->m_rotvec = B.m_rotvec;
360  else if (B_is_small) this->m_rotvec = A.m_rotvec;
361  else
362  {
363  const double a1_inv = 1/a1;
364  const double a2_inv = 1/a2;
365 
366  const double sin_a1_2 = sin(0.5*a1);
367  const double cos_a1_2 = cos(0.5*a1);
368  const double sin_a2_2 = sin(0.5*a2);
369  const double cos_a2_2 = cos(0.5*a2);
370 
371  const double KA = sin_a1_2*sin_a2_2;
372  const double KB = sin_a1_2*cos_a2_2;
373  const double KC = cos_a1_2*sin_a2_2;
374  const double KD = cos_a1_2*cos_a2_2;
375 
376  const double r11 = a1_inv*A.m_rotvec[0];
377  const double r12 = a1_inv*A.m_rotvec[1];
378  const double r13 = a1_inv*A.m_rotvec[2];
379 
380  const double r21 = a2_inv*B.m_rotvec[0];
381  const double r22 = a2_inv*B.m_rotvec[1];
382  const double r23 = a2_inv*B.m_rotvec[2];
383 
384  const double q3[] = {
385  KD - KA*(r11*r21+r12*r22+r13*r23),
386  KC*r21 + KB*r11 + KA*(r22*r13-r23*r12),
387  KC*r22 + KB*r12 + KA*(r23*r11-r21*r13),
388  KC*r23 + KB*r13 + KA*(r21*r12-r22*r11)
389  };
390 
391  const double param = 2*acos(q3[0])/sqrt(1-q3[0]*q3[0]);
392  this->m_rotvec[0] = param*q3[1];
393  this->m_rotvec[1] = param*q3[2];
394  this->m_rotvec[2] = param*q3[3];
395  }
396 #endif
397 
398  /* */
399 
400  // Rotation part
402  aux.setRotationMatrix(RA * RB);
403  this->m_rotvec = aux.ln_rotation();
404 
405  // cout << "WO Approx: " << *this << endl;
406 
407  /* */
408 
409  // Output Jacobians (if desired)
410  if (out_jacobian_drvtC_drvtA || out_jacobian_drvtC_drvtB)
411  {
412  CPose3DQuat qA, qB, qC;
413  this->toQuatXYZ(qC);
414 
415  const double& qCr = qC.m_quat[0];
416  const double& qCx = qC.m_quat[1];
417  const double& qCy = qC.m_quat[2];
418  const double& qCz = qC.m_quat[3];
419 
420  const double& r1 = this->m_rotvec[0];
421  const double& r2 = this->m_rotvec[1];
422  const double& r3 = this->m_rotvec[2];
423 
424  const double C = 1 / (1 - qCr * qCr);
425  const double D = acos(qCr) / sqrt(1 - qCr * qCr);
426 
427  alignas(16) const double aux_valsH[] = {
428  2 * C * qCx * (D * qCr - 1), 2 * D, 0, 0,
429  2 * C * qCy * (D * qCr - 1), 0, 2 * D, 0,
430  2 * C * qCz * (D * qCr - 1), 0, 0, 2 * D};
431 
433 
434  const double alpha = sqrt(r1 * r1 + r2 * r2 + r3 * r3);
435  const double alpha2 = alpha * alpha;
436  const double KA = alpha * cos(alpha / 2) - 2 * sin(alpha / 2);
437 
438  alignas(16) const double aux_valsG[] = {
439  -r1 * alpha2 * sin(alpha / 2),
440  -r2 * alpha2 * sin(alpha / 2),
441  -r3 * alpha2 * sin(alpha / 2),
442  2 * alpha2 * sin(alpha / 2) + r1 * r1 * KA,
443  r1 * r2 * KA,
444  r1 * r3 * KA,
445  r1 * r2 * KA,
446  2 * alpha2 * sin(alpha / 2) + r2 * r2 * KA,
447  r2 * r3 * KA,
448  r1 * r3 * KA,
449  r2 * r3 * KA,
450  2 * alpha2 * sin(alpha / 2) + r3 * r3 * KA};
451 
453 
454  if (out_jacobian_drvtC_drvtB)
455  {
456  A.toQuatXYZ(qA);
457 
458  const double& qAr = qA.m_quat[0];
459  const double& qAx = qA.m_quat[1];
460  const double& qAy = qA.m_quat[2];
461  const double& qAz = qA.m_quat[3];
462 
463  alignas(16) const double aux_valsQA[] = {
464  qAr, -qAx, -qAy, -qAz, qAx, qAr, qAz, -qAy,
465  qAy, -qAz, qAr, qAx, qAz, qAy, -qAx, qAr};
466  CMatrixDouble44 QA(aux_valsQA);
467 
468  CMatrixDouble33 jac_rot_B;
469  jac_rot_B.multiply_ABC(H, QA, G);
470 
471  out_jacobian_drvtC_drvtB->fill(0);
472  out_jacobian_drvtC_drvtB->insertMatrix(0, 0, jac_rot_B);
473  out_jacobian_drvtC_drvtB->insertMatrix(3, 3, RA);
474  }
475  if (out_jacobian_drvtC_drvtA)
476  {
477  B.toQuatXYZ(qB);
478 
479  const double& qBr = qB.m_quat[0];
480  const double& qBx = qB.m_quat[1];
481  const double& qBy = qB.m_quat[2];
482  const double& qBz = qB.m_quat[3];
483 
484  alignas(16) const double aux_valsQB[] = {
485  qBr, -qBx, -qBy, -qBz, qBx, qBr, -qBz, qBy,
486  qBy, qBz, qBr, -qBx, qBz, -qBy, qBx, qBr};
487  CMatrixDouble44 QB(aux_valsQB);
488 
489  CMatrixDouble33 jac_rot_A, id3;
490  jac_rot_A.multiply_ABC(H, QB, G);
491 
492  id3.eye();
493  out_jacobian_drvtC_drvtA->fill(0);
494  out_jacobian_drvtC_drvtA->insertMatrix(0, 0, jac_rot_A);
495  out_jacobian_drvtC_drvtB->insertMatrix(3, 3, id3);
496  }
497  }
498 } // end composeFrom
499 
500 /** Convert this pose into its inverse, saving the result in itself. */
502 {
504  this->getInverseHomogeneousMatrix(B_INV);
505  this->setFromTransformationMatrix(B_INV);
506 }
507 
508 /** Compute the inverse of this pose and return the result. */
510 {
513  this->getInverseHomogeneousMatrix(B_INV);
514  inv_rvt.setFromTransformationMatrix(B_INV);
515 
516  return inv_rvt;
517 }
518 
519 /** Makes \f$ this = A \ominus B \f$ this method is slightly more efficient
520  * than "this= A - B;" since it avoids the temporary object.
521  * \note A or B can be "this" without problems.
522  * \sa composeFrom, composePoint
523  */
525  const CPose3DRotVec& A, const CPose3DRotVec& B)
526 {
527  // this = A (-) B
528  // HM_this = inv(HM_B) * HM_A
529  //
530  // [ R_b | t_b ] -1 [ R_a | t_a ] [ R_b^t * Ra | .. ]
531  // [ ------+-----] * [ ------+-----] = [ ---------- +----------]
532  // [ 0 0 0 | 1 ] [ 0 0 0 | 1 ] [ 0 0 0 | 1 ]
533  //
535  HM_C(UNINITIALIZED_MATRIX);
536 
537  A.getHomogeneousMatrix(HM_A);
538  B.getInverseHomogeneousMatrix(HM_B_inv);
539 
540  HM_C.multiply_AB(HM_B_inv, HM_A);
541 
542  this->m_rotvec = this->rotVecFromRotMat(HM_C);
543 
544  this->m_coords[0] = HM_C(0, 3);
545  this->m_coords[1] = HM_C(1, 3);
546  this->m_coords[2] = HM_C(2, 3);
547 }
548 
549 /** Computes the 3D point L such as \f$ L = G \ominus this \f$.
550  * \sa composePoint, composeFrom
551  */
553  const double gx, const double gy, const double gz, double& lx, double& ly,
554  double& lz,
555  mrpt::math::CMatrixFixedNumeric<double, 3, 3>* out_jacobian_df_dpoint,
556  mrpt::math::CMatrixFixedNumeric<double, 3, 6>* out_jacobian_df_dpose) const
557 {
558  MRPT_UNUSED_PARAM(out_jacobian_df_dpoint);
559  MRPT_UNUSED_PARAM(out_jacobian_df_dpose);
560  CPose3DRotVec rvt = this->getInverse();
561  rvt.composePoint(gx, gy, gz, lx, ly, lz);
562  MRPT_TODO("Jacobians");
563 }
564 
565 /** Exponentiate a Vector in the SE3 Lie Algebra to generate a new
566  * CPose3DRotVec.
567  */
569 {
570  return CPose3DRotVec(mu);
571 }
572 
573 /** Take the logarithm of the 3x3 rotation matrix, generating the corresponding
574  * vector in the Lie Algebra.
575  */
576 CArrayDouble<3> CPose3DRotVec::ln_rotation() const { return m_rotvec; }
577 /** Take the logarithm of the 3x4 matrix defined by this pose, generating the
578  * corresponding vector in the SE3 Lie Algebra.
579  */
581 {
582  result.head<3>() = m_coords;
583  result.tail<3>() = m_rotvec;
584 }
585 
587 {
588  for (int i = 0; i < 3; i++)
589  {
590  m_coords[i] = std::numeric_limits<double>::quiet_NaN();
591  m_rotvec[i] = std::numeric_limits<double>::quiet_NaN();
592  }
593 }
static CPose3DRotVec exp(const mrpt::math::CArrayDouble< 6 > &vect)
Exponentiate a Vector in the SE(3) Lie Algebra to generate a new CPose3DRotVec (static method)...
#define local
Definition: zutil.h:47
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:135
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3525
CPose3DRotVec operator+(const CPose3DRotVec &b) const
The operator is the pose compounding operator.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
const GLshort * coords
Definition: glext.h:7386
GLdouble GLdouble z
Definition: glext.h:3872
static mrpt::math::CMatrixDouble33 exp_rotation(const mrpt::math::CArrayNumeric< double, 3 > &vect)
Exponentiate a vector in the Lie algebra to generate a new SO(3) (a 3x3 rotation matrix).
Definition: CPose3D.cpp:865
void inverse()
Convert this pose into its inverse, saving the result in itself.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
void skew_symmetric3(const VECTOR &v, MATRIX &M)
Computes the 3x3 skew symmetric matrix from a 3-vector or 3-array: .
Definition: geometry.h:853
void setFromXYZAndAngles(const double x, const double y, const double z, const double yaw=0, const double pitch=0, const double roll=0)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
CPose3DRotVec getInverse() const
Compute the inverse of this pose and return the result.
mrpt::math::CArrayDouble< 3 > m_coords
[x,y,z]
Definition: CPoint3D.h:38
#define THROW_EXCEPTION(msg)
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
mrpt::math::CArrayDouble< 3 > ln_rotation() const
Take the logarithm of the 3x3 rotation matrix, generating the corresponding vector in the Lie Algebra...
Definition: CPose3D.cpp:859
void setToNaN() override
Set all data fields to quiet NaN.
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
void setFromTransformationMatrix(const mrpt::math::CMatrixDouble44 &m)
void inverseComposePoint(const double gx, const double gy, const double gz, double &lx, double &ly, double &lz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point L such as .
void setRotationMatrix(const mrpt::math::CMatrixDouble33 &ROT)
Sets the 3x3 rotation matrix.
Definition: CPose3D.h:249
const mrpt::math::CMatrixDouble33 getRotationMatrix() const
#define MRPT_TODO(x)
void ln(mrpt::math::CArrayDouble< 6 > &out_ln) const
Take the logarithm of the 3x4 matrix defined by this pose, generating the corresponding vector in the...
void skew_symmetric3_neg(const VECTOR &v, MATRIX &M)
Computes the negative version of a 3x3 skew symmetric matrix from a 3-vector or 3-array: ...
Definition: geometry.h:887
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z] access directly or with x(), y(), z() setter/getter methods...
Definition: CPose3D.h:98
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void sphericalCoordinates(const mrpt::math::TPoint3D &point, double &out_range, double &out_yaw, double &out_pitch) const
Computes the spherical coordinates of a 3D point as seen from the 6D pose specified by this object...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
Definition: CPoint.h:171
void getInverseHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 inverse homogeneous transformation matrix for this point or pose...
Definition: CPoseOrPoint.h:287
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) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
GLbyte ty
Definition: glext.h:6092
CPose2D operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
Definition: CPose2D.cpp:328
mrpt::math::CArrayDouble< 3 > rotVecFromRotMat(const math::CMatrixDouble44 &m)
Create a vector with 3 components according to the input transformation matrix (only the rotation wil...
GLubyte GLubyte b
Definition: glext.h:6279
double x
X,Y,Z coordinates.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:48
A class used to store a 2D point.
Definition: CPoint2D.h:36
A class used to store a 3D point.
Definition: CPoint3D.h:32
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
Definition: glext.h:5566
mrpt::math::CArrayDouble< 3 > ln_rotation() const
Take the logarithm of the 3x3 rotation matrix part of this pose, generating the corresponding vector ...
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
Definition: CPoint.h:163
const float R
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::math::CArrayDouble< 3 > m_rotvec
The rotation vector [vx,vy,vz].
Definition: CPose3DRotVec.h:53
void toQuatXYZ(CPose3DQuat &q) const
Convert this RVT into a quaternion + XYZ.
GLuint in
Definition: glext.h:7274
void inverseComposeFrom(const CPose3DRotVec &A, const CPose3DRotVec &B)
Makes this method is slightly more efficient than "this= A - B;" since it avoids the temporary objec...
GLbyte GLbyte tz
Definition: glext.h:6092
GLenum GLint GLint y
Definition: glext.h:3538
void composeFrom(const CPose3DRotVec &A, const CPose3DRotVec &B, mrpt::math::CMatrixFixedNumeric< double, 6, 6 > *out_jacobian_drvtC_drvtA=nullptr, mrpt::math::CMatrixFixedNumeric< double, 6, 6 > *out_jacobian_drvtC_drvtB=nullptr)
Makes "this = A (+) B"; this method is slightly more efficient than "this= A + B;" since it avoids th...
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
mrpt::math::CQuaternionDouble m_quat
The quaternion.
Definition: CPose3DQuat.h:56
A 3D pose, with a 3D translation and a rotation in 3D parameterized in rotation-vector form (equivale...
Definition: CPose3DRotVec.h:44
GLenum GLint x
Definition: glext.h:3538
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
Definition: CQuaternion.h:46
Lightweight 3D point.
GLfloat param
Definition: glext.h:3831
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
GLfloat GLfloat p
Definition: glext.h:6305
CPose3DRotVec()
Default constructor, with all the coordinates set to zero.
Definition: CPose3DRotVec.h:59
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
Definition: CPose3D.h:221
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z].
Definition: CPoint.h:137
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1
Definition: glext.h:5566
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z].
Definition: CPose3DRotVec.h:51



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019