Main MRPT website > C++ reference for MRPT 1.9.9
CPose3DQuat.h
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 #ifndef CPose3DQuat_H
10 #define CPose3DQuat_H
11 
12 #include <mrpt/poses/CPose.h>
14 #include <mrpt/math/CQuaternion.h>
15 #include <mrpt/poses/CPoint3D.h>
16 #include <mrpt/poses/poses_frwds.h>
18 
19 namespace mrpt
20 {
21 namespace poses
22 {
23 /** A class used to store a 3D pose as a translation (x,y,z) and a quaternion
24  * (qr,qx,qy,qz).
25  *
26  * For a complete description of Points/Poses, see mrpt::poses::CPoseOrPoint,
27  * or refer
28  * to the <a href="http://www.mrpt.org/2D_3D_Geometry"> 2D/3D Geometry
29  * tutorial</a> in the wiki.
30  *
31  * To access the translation use x(), y() and z(). To access the rotation, use
32  * CPose3DQuat::quat().
33  *
34  * This class also behaves like a STL container, since it has begin(), end(),
35  * iterators, and can be accessed with the [] operator
36  * with indices running from 0 to 6 to access the [x y z qr qx qy qz] as if
37  * they were a vector. Thus, a CPose3DQuat can be used
38  * as a 7-vector anywhere the MRPT math functions expect any kind of vector.
39  *
40  * This class and CPose3D are very similar, and they can be converted to the
41  * each other automatically via transformation constructors.
42  *
43  * \sa CPose3D (for a class based on a 4x4 matrix instead of a quaternion),
44  * mrpt::math::TPose3DQuat, mrpt::poses::CPose3DQuatPDF for a probabilistic
45  * version of this class, mrpt::math::CQuaternion, CPoseOrPoint
46  * \ingroup poses_grp
47  */
48 class CPose3DQuat : public CPose<CPose3DQuat>, public mrpt::utils::CSerializable
49 {
51 
52  public:
53  /** The translation vector [x,y,z] */
55  /** The quaternion. */
57 
58  public:
59  /** Read/Write access to the quaternion representing the 3D rotation. */
61  /** Read-only access to the quaternion representing the 3D rotation. */
62  inline const mrpt::math::CQuaternionDouble& quat() const { return m_quat; }
63  /** Read/Write access to the translation vector in R^3. */
65  /** Read-only access to the translation vector in R^3. */
66  inline const mrpt::math::CArrayDouble<3>& xyz() const { return m_coords; }
67  /** Default constructor, initialize translation to zeros and quaternion to
68  * no rotation. */
69  inline CPose3DQuat() : m_quat()
70  {
71  m_coords[0] = m_coords[1] = m_coords[2] = 0.;
72  }
73 
74  /** Constructor which left all the quaternion members un-initialized, for
75  * use when speed is critical; Use UNINITIALIZED_POSE as argument to this
76  * constructor. */
79  {
80  }
81  /** \overload */
84  {
85  }
86 
87  /** Constructor with initilization of the pose - the quaternion is
88  * normalized to make sure it's unitary */
89  inline CPose3DQuat(
90  const double x, const double y, const double z,
92  : m_quat(q)
93  {
94  m_coords[0] = x;
95  m_coords[1] = y;
96  m_coords[2] = z;
97  m_quat.normalize();
98  }
99 
100  /** Constructor from a CPose3D */
101  explicit CPose3DQuat(const CPose3D& p);
102 
103  /** Constructor from lightweight object. */
105  : m_quat(p.qr, p.qx, p.qy, p.qz)
106  {
107  x() = p.x;
108  y() = p.y;
109  z() = p.z;
110  }
111 
112  /** Constructor from a 4x4 homogeneous transformation matrix.
113  */
114  explicit CPose3DQuat(const mrpt::math::CMatrixDouble44& M);
115 
116  /** Returns the corresponding 4x4 homogeneous transformation matrix for the
117  * point(translation) or pose (translation+orientation).
118  * \sa getInverseHomogeneousMatrix
119  */
121 
122  /** Returns a 1x7 vector with [x y z qr qx qy qz] */
124  /// \overload
126  {
127  v[0] = m_coords[0];
128  v[1] = m_coords[1];
129  v[2] = m_coords[2];
130  v[3] = m_quat[0];
131  v[4] = m_quat[1];
132  v[5] = m_quat[2];
133  v[6] = m_quat[3];
134  }
135 
136  /** Makes \f$ this = A \oplus B \f$ this method is slightly more efficient
137  * than "this= A + B;" since it avoids the temporary object.
138  * \note A or B can be "this" without problems.
139  * \sa inverseComposeFrom, composePoint
140  */
141  void composeFrom(const CPose3DQuat& A, const CPose3DQuat& B);
142 
143  /** Makes \f$ this = A \ominus B \f$ this method is slightly more efficient
144  * than "this= A - B;" since it avoids the temporary object.
145  * \note A or B can be "this" without problems.
146  * \sa composeFrom, composePoint
147  */
148  void inverseComposeFrom(const CPose3DQuat& A, const CPose3DQuat& B);
149 
150  /** Computes the 3D point G such as \f$ G = this \oplus L \f$.
151  * \sa composeFrom, inverseComposePoint
152  */
153  void composePoint(
154  const double lx, const double ly, const double lz, double& gx,
155  double& gy, double& gz,
156  mrpt::math::CMatrixFixedNumeric<double, 3, 3>* out_jacobian_df_dpoint =
157  nullptr,
158  mrpt::math::CMatrixFixedNumeric<double, 3, 7>* out_jacobian_df_dpose =
159  nullptr) const;
160 
161  /** Computes the 3D point L such as \f$ L = G \ominus this \f$.
162  * \sa composePoint, composeFrom
163  */
164  void inverseComposePoint(
165  const double gx, const double gy, const double gz, double& lx,
166  double& ly, double& lz,
167  mrpt::math::CMatrixFixedNumeric<double, 3, 3>* out_jacobian_df_dpoint =
168  nullptr,
169  mrpt::math::CMatrixFixedNumeric<double, 3, 7>* out_jacobian_df_dpose =
170  nullptr) const;
171 
172  /** Computes the 3D point G such as \f$ G = this \oplus L \f$.
173  * POINT1 and POINT1 can be anything supporing [0],[1],[2].
174  * \sa composePoint */
175  template <class POINT1, class POINT2>
176  inline void composePoint(const POINT1& L, POINT2& G) const
177  {
178  composePoint(L[0], L[1], L[2], G[0], G[1], G[2]);
179  }
180 
181  /** Computes the 3D point L such as \f$ L = G \ominus this \f$. \sa
182  * inverseComposePoint */
183  template <class POINT1, class POINT2>
184  inline void inverseComposePoint(const POINT1& G, POINT2& L) const
185  {
186  inverseComposePoint(G[0], G[1], G[2], L[0], L[1], L[2]);
187  }
188 
189  /** Computes the 3D point G such as \f$ G = this \oplus L \f$. \sa
190  * composePoint */
191  inline CPoint3D operator+(const CPoint3D& L) const
192  {
193  CPoint3D G;
194  composePoint(L[0], L[1], L[2], G[0], G[1], G[2]);
195  return G;
196  }
197 
198  /** Computes the 3D point G such as \f$ G = this \oplus L \f$. \sa
199  * composePoint */
201  {
203  composePoint(L[0], L[1], L[2], G[0], G[1], G[2]);
204  return G;
205  }
206 
207  /** Scalar multiplication (all x y z qr qx qy qz elements are multiplied by
208  * the scalar). */
209  virtual void operator*=(const double s);
210 
211  /** Make \f$ this = this \oplus b \f$ */
213  {
214  composeFrom(*this, b);
215  return *this;
216  }
217 
218  /** Return the composed pose \f$ ret = this \oplus p \f$ */
219  inline CPose3DQuat operator+(const CPose3DQuat& p) const
220  {
221  CPose3DQuat ret;
222  ret.composeFrom(*this, p);
223  return ret;
224  }
225 
226  /** Make \f$ this = this \ominus b \f$ */
228  {
229  inverseComposeFrom(*this, b);
230  return *this;
231  }
232 
233  /** Return the composed pose \f$ ret = this \ominus p \f$ */
234  inline CPose3DQuat operator-(const CPose3DQuat& p) const
235  {
236  CPose3DQuat ret;
237  ret.inverseComposeFrom(*this, p);
238  return ret;
239  }
240 
241  /** Convert this pose into its inverse, saving the result in itself. \sa
242  * operator- */
243  void inverse();
244 
245  /** Returns a human-readable textual representation of the object (eg: "[x y
246  * z qr qx qy qz]", angles in degrees.)
247  * \sa fromString
248  */
249  void asString(std::string& s) const
250  {
251  s = mrpt::format(
252  "[%f %f %f %f %f %f %f]", m_coords[0], m_coords[1], m_coords[2],
253  m_quat[0], m_quat[1], m_quat[2], m_quat[3]);
254  }
255  inline std::string asString() const
256  {
257  std::string s;
258  asString(s);
259  return s;
260  }
261 
262  /** Set the current object value from a string generated by 'asString' (eg:
263  * "[0.02 1.04 -0.8 1 0 0 0]" )
264  * \sa asString
265  * \exception std::exception On invalid format
266  */
267  void fromString(const std::string& s)
268  {
270  if (!m.fromMatlabStringFormat(s))
271  THROW_EXCEPTION("Malformed expression in ::fromString");
272  ASSERTMSG_(
273  mrpt::math::size(m, 1) == 1 && mrpt::math::size(m, 2) == 7,
274  "Wrong size of vector in ::fromString");
275  m_coords[0] = m.get_unsafe(0, 0);
276  m_coords[1] = m.get_unsafe(0, 1);
277  m_coords[2] = m.get_unsafe(0, 2);
278  m_quat[0] = m.get_unsafe(0, 3);
279  m_quat[1] = m.get_unsafe(0, 4);
280  m_quat[2] = m.get_unsafe(0, 5);
281  m_quat[3] = m.get_unsafe(0, 6);
282  }
283  /** Same as fromString, but without requiring the square brackets in the
284  * string */
285  void fromStringRaw(const std::string& s);
286 
287  /** Read only [] operator */
288  inline const double& operator[](unsigned int i) const
289  {
290  switch (i)
291  {
292  case 0:
293  return m_coords[0];
294  case 1:
295  return m_coords[1];
296  case 2:
297  return m_coords[2];
298  case 3:
299  return m_quat[0];
300  case 4:
301  return m_quat[1];
302  case 5:
303  return m_quat[2];
304  case 6:
305  return m_quat[3];
306  default:
307  throw std::runtime_error(
308  "CPose3DQuat::operator[]: Index of bounds.");
309  }
310  }
311  /** Read/write [] operator */
312  inline double& operator[](unsigned int i)
313  {
314  switch (i)
315  {
316  case 0:
317  return m_coords[0];
318  case 1:
319  return m_coords[1];
320  case 2:
321  return m_coords[2];
322  case 3:
323  return m_quat[0];
324  case 4:
325  return m_quat[1];
326  case 5:
327  return m_quat[2];
328  case 6:
329  return m_quat[3];
330  default:
331  throw std::runtime_error(
332  "CPose3DQuat::operator[]: Index of bounds.");
333  }
334  }
335 
336  /** Computes the spherical coordinates of a 3D point as seen from the 6D
337  * pose specified by this object.
338  * For the coordinate system see the top of this page.
339  * If the matrix pointers are not nullptr, the Jacobians will be also
340  * computed for the range-yaw-pitch variables wrt the passed 3D point and
341  * this 7D pose.
342  */
344  const mrpt::math::TPoint3D& point, double& out_range, double& out_yaw,
345  double& out_pitch,
346  mrpt::math::CMatrixFixedNumeric<double, 3, 3>* out_jacob_dryp_dpoint =
347  nullptr,
348  mrpt::math::CMatrixFixedNumeric<double, 3, 7>* out_jacob_dryp_dpose =
349  nullptr) const;
350 
351  public:
352  /** Used to emulate CPosePDF types, for example, in
353  * mrpt::graphs::CNetworkOfPoses */
355  enum
356  {
358  };
359  static inline bool is_3D() { return is_3D_val != 0; }
360  enum
361  {
363  };
364  enum
365  {
367  };
368  static inline bool is_PDF() { return is_PDF_val != 0; }
369  inline const type_value& getPoseMean() const { return *this; }
370  inline type_value& getPoseMean() { return *this; }
371  /** @name STL-like methods and typedefs
372  @{ */
373  /** The type of the elements */
374  typedef double value_type;
375  typedef double& reference;
376  typedef const double& const_reference;
377  typedef std::size_t size_type;
379 
380  // size is constant
381  enum
382  {
384  };
385  static inline size_type size() { return static_size; }
386  static inline bool empty() { return false; }
387  static inline size_type max_size() { return static_size; }
388  static inline void resize(const size_t n)
389  {
390  if (n != static_size)
391  throw std::logic_error(
392  format(
393  "Try to change the size of CPose3DQuat to %u.",
394  static_cast<unsigned>(n)));
395  }
396 
397  inline void assign(const size_t N, const double val)
398  {
399  if (N != 7)
400  throw std::runtime_error(
401  "CPose3DQuat::assign: Try to resize to length!=7.");
402  m_coords.fill(val);
403  m_quat.fill(val);
404  }
405 
406  struct iterator
407  : public std::iterator<std::random_access_iterator_tag, value_type>
408  {
409  private:
410  typedef std::iterator<std::random_access_iterator_tag, value_type>
412  /** A reference to the source of this iterator */
414  /** The iterator points to this element. */
415  size_t m_cur_idx;
416  /** The type of the matrix elements */
417  typedef value_type T;
418 
419  inline void check_limits(bool allow_end = false) const
420  {
421 #ifdef _DEBUG
422  ASSERTMSG_(m_obj != nullptr, "non initialized iterator");
423  if (m_cur_idx > (allow_end ? 7u : 6u))
424  THROW_EXCEPTION("Index out of range in iterator.")
425 #else
426  MRPT_UNUSED_PARAM(allow_end);
427 #endif
428  }
429 
430  public:
431  inline bool operator<(const iterator& it2) const
432  {
433  return m_cur_idx < it2.m_cur_idx;
434  }
435  inline bool operator>(const iterator& it2) const
436  {
437  return m_cur_idx > it2.m_cur_idx;
438  }
439  inline iterator() : m_obj(nullptr), m_cur_idx(0) {}
440  inline iterator(CPose3DQuat& obj, size_t start_idx)
441  : m_obj(&obj), m_cur_idx(start_idx)
442  {
443  check_limits(true); /*Dont report as error an iterator to end()*/
444  }
446  {
447  check_limits();
448  return (*m_obj)[m_cur_idx];
449  }
451  {
452  check_limits();
453  ++m_cur_idx;
454  return *this;
455  }
456  inline iterator operator++(int)
457  {
458  iterator it = *this;
459  ++*this;
460  return it;
461  }
463  {
464  --m_cur_idx;
465  check_limits();
466  return *this;
467  }
468  inline iterator operator--(int)
469  {
470  iterator it = *this;
471  --*this;
472  return it;
473  }
474  inline iterator& operator+=(iterator_base::difference_type off)
475  {
476  m_cur_idx += off;
477  check_limits(true);
478  return *this;
479  }
480  inline iterator operator+(iterator_base::difference_type off) const
481  {
482  iterator it = *this;
483  it += off;
484  return it;
485  }
486  inline iterator& operator-=(iterator_base::difference_type off)
487  {
488  return (*this) += (-off);
489  }
490  inline iterator operator-(iterator_base::difference_type off) const
491  {
492  iterator it = *this;
493  it -= off;
494  return it;
495  }
496  inline iterator_base::difference_type operator-(
497  const iterator& it) const
498  {
499  return m_cur_idx - it.m_cur_idx;
500  }
502  iterator_base::difference_type off) const
503  {
504  return (*m_obj)[m_cur_idx + off];
505  }
506  inline bool operator==(const iterator& it) const
507  {
508  return m_obj == it.m_obj && m_cur_idx == it.m_cur_idx;
509  }
510  inline bool operator!=(const iterator& it) const
511  {
512  return !(operator==(it));
513  }
514  }; // end iterator
515 
517  : public std::iterator<std::random_access_iterator_tag, value_type>
518  {
519  private:
520  typedef std::iterator<std::random_access_iterator_tag, value_type>
522  /** A reference to the source of this iterator */
524  /** The iterator points to this element. */
525  size_t m_cur_idx;
526  /** The type of the matrix elements */
527  typedef value_type T;
528 
529  inline void check_limits(bool allow_end = false) const
530  {
531 #ifdef _DEBUG
532  ASSERTMSG_(m_obj != nullptr, "non initialized iterator");
533  if (m_cur_idx > (allow_end ? 7u : 6u))
534  THROW_EXCEPTION("Index out of range in iterator.")
535 #else
536  MRPT_UNUSED_PARAM(allow_end);
537 #endif
538  }
539 
540  public:
541  inline bool operator<(const const_iterator& it2) const
542  {
543  return m_cur_idx < it2.m_cur_idx;
544  }
545  inline bool operator>(const const_iterator& it2) const
546  {
547  return m_cur_idx > it2.m_cur_idx;
548  }
549  inline const_iterator() : m_obj(nullptr), m_cur_idx(0) {}
550  inline const_iterator(const CPose3DQuat& obj, size_t start_idx)
551  : m_obj(&obj), m_cur_idx(start_idx)
552  {
553  check_limits(true); /*Dont report as error an iterator to end()*/
554  }
556  {
557  check_limits();
558  return (*m_obj)[m_cur_idx];
559  }
561  {
562  check_limits();
563  ++m_cur_idx;
564  return *this;
565  }
567  {
568  const_iterator it = *this;
569  ++*this;
570  return it;
571  }
573  {
574  --m_cur_idx;
575  check_limits();
576  return *this;
577  }
579  {
580  const_iterator it = *this;
581  --*this;
582  return it;
583  }
584  inline const_iterator& operator+=(iterator_base::difference_type off)
585  {
586  m_cur_idx += off;
587  check_limits(true);
588  return *this;
589  }
591  iterator_base::difference_type off) const
592  {
593  const_iterator it = *this;
594  it += off;
595  return it;
596  }
597  inline const_iterator& operator-=(iterator_base::difference_type off)
598  {
599  return (*this) += (-off);
600  }
602  iterator_base::difference_type off) const
603  {
604  const_iterator it = *this;
605  it -= off;
606  return it;
607  }
608  inline iterator_base::difference_type operator-(
609  const const_iterator& it) const
610  {
611  return m_cur_idx - it.m_cur_idx;
612  }
614  iterator_base::difference_type off) const
615  {
616  return (*m_obj)[m_cur_idx + off];
617  }
618  inline bool operator==(const const_iterator& it) const
619  {
620  return m_obj == it.m_obj && m_cur_idx == it.m_cur_idx;
621  }
622  inline bool operator!=(const const_iterator& it) const
623  {
624  return !(operator==(it));
625  }
626  }; // end const_iterator
627 
628  typedef std::reverse_iterator<iterator> reverse_iterator;
629  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
630  inline iterator begin() { return iterator(*this, 0); }
631  inline iterator end() { return iterator(*this, static_size); }
632  inline const_iterator begin() const { return const_iterator(*this, 0); }
633  inline const_iterator end() const
634  {
635  return const_iterator(*this, static_size);
636  }
637  inline reverse_iterator rbegin() { return reverse_iterator(end()); }
639  {
640  return const_reverse_iterator(end());
641  }
642  inline reverse_iterator rend() { return reverse_iterator(begin()); }
644  {
645  return const_reverse_iterator(begin());
646  }
647 
648  void swap(CPose3DQuat& o)
649  {
650  std::swap(o.m_coords, m_coords);
651  o.m_quat.swap(m_quat);
652  }
653 
654  /** @} */
655  //! See ops_containers.h
657  // DECLARE_MRPT_CONTAINER_TYPES
658 
659  void setToNaN() override;
660 
661 }; // End of class def.
662 
663 std::ostream& operator<<(std::ostream& o, const CPose3DQuat& p);
664 
665 /** Unary - operator: return the inverse pose "-p" (Note that is NOT the same
666  * than a pose with all its arguments multiplied by "-1") */
668 /** Computes the 3D point L such as \f$ L = G \ominus this \f$. \sa
669  * inverseComposePoint */
670 CPoint3D operator-(const CPoint3D& G, const CPose3DQuat& p);
671 /** Computes the 3D point L such as \f$ L = G \ominus this \f$. \sa
672  * inverseComposePoint */
674  const mrpt::math::TPoint3D& G, const CPose3DQuat& p);
675 
676 bool operator==(const CPose3DQuat& p1, const CPose3DQuat& p2);
677 bool operator!=(const CPose3DQuat& p1, const CPose3DQuat& p2);
678 
679 } // End of namespace
680 } // End of namespace
681 
682 #endif
CPose3DQuat * m_obj
A reference to the source of this iterator.
Definition: CPose3DQuat.h:413
void getAsVector(mrpt::math::CVectorDouble &v) const
Returns a 1x7 vector with [x y z qr qx qy qz].
Definition: CPose3DQuat.cpp:62
value_type T
The type of the matrix elements.
Definition: CPose3DQuat.h:417
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation.
Definition: CPose3DQuat.h:60
const double & const_reference
Definition: CPose3DQuat.h:376
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:135
static size_type max_size()
Definition: CPose3DQuat.h:387
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, 7 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point L such as .
size_t m_cur_idx
The iterator points to this element.
Definition: CPose3DQuat.h:415
const_iterator end() const
Definition: CPose3DQuat.h:633
void normalize()
Normalize this quaternion, so its norm becomes the unitity.
Definition: CQuaternion.h:272
GLdouble GLdouble z
Definition: glext.h:3872
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
CPose3DQuat(mrpt::math::TConstructorFlags_Quaternions)
Constructor which left all the quaternion members un-initialized, for use when speed is critical; Use...
Definition: CPose3DQuat.h:77
void assign(const size_t N, const double val)
Definition: CPose3DQuat.h:397
mrpt::math::CArrayDouble< 3 > & xyz()
Read/Write access to the translation vector in R^3.
Definition: CPose3DQuat.h:64
CPose3DQuat::reference operator*() const
Definition: CPose3DQuat.h:445
reverse_iterator rbegin()
Definition: CPose3DQuat.h:637
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
iterator_base::difference_type operator-(const iterator &it) const
Definition: CPose3DQuat.h:496
TConstructorFlags_Quaternions
Definition: CQuaternion.h:22
bool operator!=(const const_iterator &it) const
Definition: CPose3DQuat.h:622
iterator(CPose3DQuat &obj, size_t start_idx)
Definition: CPose3DQuat.h:440
static size_type size()
Definition: CPose3DQuat.h:385
#define THROW_EXCEPTION(msg)
const_reverse_iterator rbegin() const
Definition: CPose3DQuat.h:638
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
void fromString(const std::string &s)
Set the current object value from a string generated by &#39;asString&#39; (eg: "[0.02 1.04 -0...
Definition: CPose3DQuat.h:267
GLenum GLsizei n
Definition: glext.h:5074
Scalar * iterator
Definition: eigen_plugins.h:26
bool operator<(const iterator &it2) const
Definition: CPose3DQuat.h:431
mrpt::math::TPoint3D operator+(const mrpt::math::TPoint3D &L) const
Computes the 3D point G such as .
Definition: CPose3DQuat.h:200
CPose3DQuat(const mrpt::math::TPose3DQuat &p)
Constructor from lightweight object.
Definition: CPose3DQuat.h:104
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:42
CPose3DQuat::reference operator[](iterator_base::difference_type off) const
Definition: CPose3DQuat.h:501
void fromStringRaw(const std::string &s)
Same as fromString, but without requiring the square brackets in the string.
void sphericalCoordinates(const mrpt::math::TPoint3D &point, double &out_range, double &out_yaw, double &out_pitch, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacob_dryp_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 7 > *out_jacob_dryp_dpose=nullptr) const
Computes the spherical coordinates of a 3D point as seen from the 6D pose specified by this object...
void check_limits(bool allow_end=false) const
Definition: CPose3DQuat.h:529
const mrpt::math::CArrayDouble< 3 > & xyz() const
Read-only access to the translation vector in R^3.
Definition: CPose3DQuat.h:66
const Scalar * const_iterator
Definition: eigen_plugins.h:27
void setToNaN() override
Set all data fields to quiet NaN.
std::iterator< std::random_access_iterator_tag, value_type > iterator_base
Definition: CPose3DQuat.h:521
GLdouble s
Definition: glext.h:3676
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
bool operator>(const iterator &it2) const
Definition: CPose3DQuat.h:435
reverse_iterator rend()
Definition: CPose3DQuat.h:642
CPose3DQuat::const_reference operator*() const
Definition: CPose3DQuat.h:555
iterator & operator+=(iterator_base::difference_type off)
Definition: CPose3DQuat.h:474
iterator_base::difference_type operator-(const const_iterator &it) const
Definition: CPose3DQuat.h:608
void composePoint(const double lx, const double ly, const double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 7 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point G such as .
bool operator!=(const iterator &it) const
Definition: CPose3DQuat.h:510
A numeric matrix of compile-time fixed size.
const_iterator begin() const
Definition: CPose3DQuat.h:632
void getAsVector(mrpt::math::CArrayDouble< 7 > &v) const
Definition: CPose3DQuat.h:125
const_iterator & operator-=(iterator_base::difference_type off)
Definition: CPose3DQuat.h:597
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void composeFrom(const CPose3DQuat &A, const CPose3DQuat &B)
Makes this method is slightly more efficient than "this= A + B;" since it avoids the temporary objec...
Definition: CPose3DQuat.cpp:78
const_iterator operator+(iterator_base::difference_type off) const
Definition: CPose3DQuat.h:590
const mrpt::math::CQuaternionDouble & quat() const
Read-only access to the quaternion representing the 3D rotation.
Definition: CPose3DQuat.h:62
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
Definition: CPoint.h:171
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
const_iterator operator-(iterator_base::difference_type off) const
Definition: CPose3DQuat.h:601
const CPose3DQuat * m_obj
A reference to the source of this iterator.
Definition: CPose3DQuat.h:523
void inverse()
Convert this pose into its inverse, saving the result in itself.
A base class for representing a pose in 2D or 3D.
Definition: CPose.h:27
const type_value & getPoseMean() const
Definition: CPose3DQuat.h:369
int val
Definition: mrpt_jpeglib.h:955
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:19
GLubyte GLubyte b
Definition: glext.h:6279
double value_type
The type of the elements.
Definition: CPose3DQuat.h:374
bool operator==(const iterator &it) const
Definition: CPose3DQuat.h:506
double & operator[](unsigned int i)
Read/write [] operator.
Definition: CPose3DQuat.h:312
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
virtual void operator*=(const double s)
Scalar multiplication (all x y z qr qx qy qz elements are multiplied by the scalar).
iterator operator-(iterator_base::difference_type off) const
Definition: CPose3DQuat.h:490
GLsizei const GLchar ** string
Definition: glext.h:4101
A class used to store a 3D point.
Definition: CPoint3D.h:32
type_value & getPoseMean()
Definition: CPose3DQuat.h:370
_W64 int ptrdiff_t
Definition: glew.h:137
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z].
Definition: CPose3DQuat.h:54
void inverseComposePoint(const POINT1 &G, POINT2 &L) const
Computes the 3D point L such as .
Definition: CPose3DQuat.h:184
CPose3DQuat(TConstructorFlags_Poses)
Definition: CPose3DQuat.h:82
void composePoint(const POINT1 &L, POINT2 &G) const
Computes the 3D point G such as .
Definition: CPose3DQuat.h:176
const GLdouble * v
Definition: glext.h:3678
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
bool operator<(const const_iterator &it2) const
Definition: CPose3DQuat.h:541
size_t size(const MATRIXLIKE &m, const int dim)
CPose3DQuat mrpt_autotype
See ops_containers.h.
Definition: CPose3DQuat.h:656
static void resize(const size_t n)
Definition: CPose3DQuat.h:388
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
Definition: CPoint.h:163
CPose3DQuat(const double x, const double y, const double z, const mrpt::math::CQuaternionDouble &q)
Constructor with initilization of the pose - the quaternion is normalized to make sure it&#39;s unitary...
Definition: CPose3DQuat.h:89
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
std::ptrdiff_t difference_type
Definition: CPose3DQuat.h:378
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
Definition: CPose3DQuat.cpp:50
bool operator>(const const_iterator &it2) const
Definition: CPose3DQuat.h:545
CPoint3D operator+(const CPoint3D &L) const
Computes the 3D point G such as .
Definition: CPose3DQuat.h:191
CPose3DQuat operator-(const CPose3DQuat &p) const
Return the composed pose .
Definition: CPose3DQuat.h:234
iterator operator+(iterator_base::difference_type off) const
Definition: CPose3DQuat.h:480
iterator & operator-=(iterator_base::difference_type off)
Definition: CPose3DQuat.h:486
const_reverse_iterator rend() const
Definition: CPose3DQuat.h:643
const_iterator & operator+=(iterator_base::difference_type off)
Definition: CPose3DQuat.h:584
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[x y z qr qx qy qz]"...
Definition: CPose3DQuat.h:249
CPose3DQuat()
Default constructor, initialize translation to zeros and quaternion to no rotation.
Definition: CPose3DQuat.h:69
void inverseComposeFrom(const CPose3DQuat &A, const CPose3DQuat &B)
Makes this method is slightly more efficient than "this= A - B;" since it avoids the temporary objec...
Definition: CPose3DQuat.cpp:97
GLenum GLint GLint y
Definition: glext.h:3538
void check_limits(bool allow_end=false) const
Definition: CPose3DQuat.h:419
bool operator==(const const_iterator &it) const
Definition: CPose3DQuat.h:618
mrpt::math::CQuaternionDouble m_quat
The quaternion.
Definition: CPose3DQuat.h:56
std::reverse_iterator< iterator > reverse_iterator
Definition: CPose3DQuat.h:628
const double & operator[](unsigned int i) const
Read only [] operator.
Definition: CPose3DQuat.h:288
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.
std::iterator< std::random_access_iterator_tag, value_type > iterator_base
Definition: CPose3DQuat.h:411
CPose3DQuat type_value
Used to emulate CPosePDF types, for example, in mrpt::graphs::CNetworkOfPoses.
Definition: CPose3DQuat.h:354
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: CPose3DQuat.h:629
size_t m_cur_idx
The iterator points to this element.
Definition: CPose3DQuat.h:525
value_type T
The type of the matrix elements.
Definition: CPose3DQuat.h:527
#define ASSERTMSG_(f, __ERROR_MSG)
CPose3DQuat operator+(const CPose3DQuat &p) const
Return the composed pose .
Definition: CPose3DQuat.h:219
GLfloat GLfloat p
Definition: glext.h:6305
const_iterator(const CPose3DQuat &obj, size_t start_idx)
Definition: CPose3DQuat.h:550
CPose3DQuat & operator+=(const CPose3DQuat &b)
Make .
Definition: CPose3DQuat.h:212
std::string asString() const
Definition: CPose3DQuat.h:255
CPose3DQuat::const_reference operator[](iterator_base::difference_type off) const
Definition: CPose3DQuat.h:613
void swap(CPose3DQuat &o)
Definition: CPose3DQuat.h:648
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
CPose3DQuat & operator-=(const CPose3DQuat &b)
Make .
Definition: CPose3DQuat.h:227



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