Eigen  3.2.91
Quaternion.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2009 Mathieu Gautier <mathieu.gautier@cea.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_QUATERNION_H
12 #define EIGEN_QUATERNION_H
13 namespace Eigen {
14 
15 
16 /***************************************************************************
17 * Definition of QuaternionBase<Derived>
18 * The implementation is at the end of the file
19 ***************************************************************************/
20 
21 namespace internal {
22 template<typename Other,
23  int OtherRows=Other::RowsAtCompileTime,
24  int OtherCols=Other::ColsAtCompileTime>
25 struct quaternionbase_assign_impl;
26 }
27 
34 template<class Derived>
35 class QuaternionBase : public RotationBase<Derived, 3>
36 {
37  public:
38  typedef RotationBase<Derived, 3> Base;
39 
40  using Base::operator*;
41  using Base::derived;
42 
43  typedef typename internal::traits<Derived>::Scalar Scalar;
44  typedef typename NumTraits<Scalar>::Real RealScalar;
45  typedef typename internal::traits<Derived>::Coefficients Coefficients;
46  enum {
47  Flags = Eigen::internal::traits<Derived>::Flags
48  };
49 
50  // typedef typename Matrix<Scalar,4,1> Coefficients;
57 
58 
59 
61  inline Scalar x() const { return this->derived().coeffs().coeff(0); }
63  inline Scalar y() const { return this->derived().coeffs().coeff(1); }
65  inline Scalar z() const { return this->derived().coeffs().coeff(2); }
67  inline Scalar w() const { return this->derived().coeffs().coeff(3); }
68 
70  inline Scalar& x() { return this->derived().coeffs().coeffRef(0); }
72  inline Scalar& y() { return this->derived().coeffs().coeffRef(1); }
74  inline Scalar& z() { return this->derived().coeffs().coeffRef(2); }
76  inline Scalar& w() { return this->derived().coeffs().coeffRef(3); }
77 
79  inline const VectorBlock<const Coefficients,3> vec() const { return coeffs().template head<3>(); }
80 
82  inline VectorBlock<Coefficients,3> vec() { return coeffs().template head<3>(); }
83 
85  inline const typename internal::traits<Derived>::Coefficients& coeffs() const { return derived().coeffs(); }
86 
88  inline typename internal::traits<Derived>::Coefficients& coeffs() { return derived().coeffs(); }
89 
90  EIGEN_STRONG_INLINE QuaternionBase<Derived>& operator=(const QuaternionBase<Derived>& other);
91  template<class OtherDerived> EIGEN_STRONG_INLINE Derived& operator=(const QuaternionBase<OtherDerived>& other);
92 
93 // disabled this copy operator as it is giving very strange compilation errors when compiling
94 // test_stdvector with GCC 4.4.2. This looks like a GCC bug though, so feel free to re-enable it if it's
95 // useful; however notice that we already have the templated operator= above and e.g. in MatrixBase
96 // we didn't have to add, in addition to templated operator=, such a non-templated copy operator.
97 // Derived& operator=(const QuaternionBase& other)
98 // { return operator=<Derived>(other); }
99 
100  Derived& operator=(const AngleAxisType& aa);
101  template<class OtherDerived> Derived& operator=(const MatrixBase<OtherDerived>& m);
102 
106  static inline Quaternion<Scalar> Identity() { return Quaternion<Scalar>(Scalar(1), Scalar(0), Scalar(0), Scalar(0)); }
107 
110  inline QuaternionBase& setIdentity() { coeffs() << Scalar(0), Scalar(0), Scalar(0), Scalar(1); return *this; }
111 
115  inline Scalar squaredNorm() const { return coeffs().squaredNorm(); }
116 
120  inline Scalar norm() const { return coeffs().norm(); }
121 
124  inline void normalize() { coeffs().normalize(); }
127  inline Quaternion<Scalar> normalized() const { return Quaternion<Scalar>(coeffs().normalized()); }
128 
134  template<class OtherDerived> inline Scalar dot(const QuaternionBase<OtherDerived>& other) const { return coeffs().dot(other.coeffs()); }
135 
136  template<class OtherDerived> Scalar angularDistance(const QuaternionBase<OtherDerived>& other) const;
137 
139  Matrix3 toRotationMatrix() const;
140 
142  template<typename Derived1, typename Derived2>
143  Derived& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
144 
145  template<class OtherDerived> EIGEN_STRONG_INLINE Quaternion<Scalar> operator* (const QuaternionBase<OtherDerived>& q) const;
146  template<class OtherDerived> EIGEN_STRONG_INLINE Derived& operator*= (const QuaternionBase<OtherDerived>& q);
147 
149  Quaternion<Scalar> inverse() const;
150 
153 
154  template<class OtherDerived> Quaternion<Scalar> slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const;
155 
160  template<class OtherDerived>
161  bool isApprox(const QuaternionBase<OtherDerived>& other, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const
162  { return coeffs().isApprox(other.coeffs(), prec); }
163 
165  EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3& v) const;
166 
172  template<typename NewScalarType>
173  inline typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type cast() const
174  {
175  return typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type(derived());
176  }
177 
178 #ifdef EIGEN_QUATERNIONBASE_PLUGIN
179 # include EIGEN_QUATERNIONBASE_PLUGIN
180 #endif
181 };
182 
183 /***************************************************************************
184 * Definition/implementation of Quaternion<Scalar>
185 ***************************************************************************/
186 
212 namespace internal {
213 template<typename _Scalar,int _Options>
214 struct traits<Quaternion<_Scalar,_Options> >
215 {
216  typedef Quaternion<_Scalar,_Options> PlainObject;
217  typedef _Scalar Scalar;
218  typedef Matrix<_Scalar,4,1,_Options> Coefficients;
219  enum{
220  Alignment = internal::traits<Coefficients>::Alignment,
221  Flags = LvalueBit
222  };
223 };
224 }
225 
226 template<typename _Scalar, int _Options>
227 class Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >
228 {
229 public:
230  typedef QuaternionBase<Quaternion<_Scalar,_Options> > Base;
231  enum { NeedsAlignment = internal::traits<Quaternion>::Alignment>0 };
232 
233  typedef _Scalar Scalar;
234 
235  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Quaternion)
236  using Base::operator*=;
237 
238  typedef typename internal::traits<Quaternion>::Coefficients Coefficients;
239  typedef typename Base::AngleAxisType AngleAxisType;
240 
242  inline Quaternion() {}
243 
251  inline Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar& z) : m_coeffs(x, y, z, w){}
252 
254  explicit inline Quaternion(const Scalar* data) : m_coeffs(data) {}
255 
257  template<class Derived> EIGEN_STRONG_INLINE Quaternion(const QuaternionBase<Derived>& other) { this->Base::operator=(other); }
258 
260  explicit inline Quaternion(const AngleAxisType& aa) { *this = aa; }
261 
266  template<typename Derived>
267  explicit inline Quaternion(const MatrixBase<Derived>& other) { *this = other; }
268 
270  template<typename OtherScalar, int OtherOptions>
271  explicit inline Quaternion(const Quaternion<OtherScalar, OtherOptions>& other)
272  { m_coeffs = other.coeffs().template cast<Scalar>(); }
273 
274  template<typename Derived1, typename Derived2>
275  static Quaternion FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
276 
277  inline Coefficients& coeffs() { return m_coeffs;}
278  inline const Coefficients& coeffs() const { return m_coeffs;}
279 
280  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsAlignment)
281 
282 protected:
283  Coefficients m_coeffs;
284 
285 #ifndef EIGEN_PARSED_BY_DOXYGEN
286  static EIGEN_STRONG_INLINE void _check_template_params()
287  {
288  EIGEN_STATIC_ASSERT( (_Options & DontAlign) == _Options,
289  INVALID_MATRIX_TEMPLATE_PARAMETERS)
290  }
291 #endif
292 };
293 
300 
301 /***************************************************************************
302 * Specialization of Map<Quaternion<Scalar>>
303 ***************************************************************************/
304 
305 namespace internal {
306  template<typename _Scalar, int _Options>
307  struct traits<Map<Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
308  {
309  typedef Map<Matrix<_Scalar,4,1>, _Options> Coefficients;
310  };
311 }
312 
313 namespace internal {
314  template<typename _Scalar, int _Options>
315  struct traits<Map<const Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
316  {
317  typedef Map<const Matrix<_Scalar,4,1>, _Options> Coefficients;
318  typedef traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> > TraitsBase;
319  enum {
320  Flags = TraitsBase::Flags & ~LvalueBit
321  };
322  };
323 }
324 
336 template<typename _Scalar, int _Options>
337 class Map<const Quaternion<_Scalar>, _Options >
338  : public QuaternionBase<Map<const Quaternion<_Scalar>, _Options> >
339 {
340  public:
341  typedef QuaternionBase<Map<const Quaternion<_Scalar>, _Options> > Base;
342 
343  typedef _Scalar Scalar;
344  typedef typename internal::traits<Map>::Coefficients Coefficients;
345  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
346  using Base::operator*=;
347 
354  explicit EIGEN_STRONG_INLINE Map(const Scalar* coeffs) : m_coeffs(coeffs) {}
355 
356  inline const Coefficients& coeffs() const { return m_coeffs;}
357 
358  protected:
359  const Coefficients m_coeffs;
360 };
361 
373 template<typename _Scalar, int _Options>
374 class Map<Quaternion<_Scalar>, _Options >
375  : public QuaternionBase<Map<Quaternion<_Scalar>, _Options> >
376 {
377  public:
378  typedef QuaternionBase<Map<Quaternion<_Scalar>, _Options> > Base;
379 
380  typedef _Scalar Scalar;
381  typedef typename internal::traits<Map>::Coefficients Coefficients;
382  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
383  using Base::operator*=;
384 
391  explicit EIGEN_STRONG_INLINE Map(Scalar* coeffs) : m_coeffs(coeffs) {}
392 
393  inline Coefficients& coeffs() { return m_coeffs; }
394  inline const Coefficients& coeffs() const { return m_coeffs; }
395 
396  protected:
397  Coefficients m_coeffs;
398 };
399 
408 typedef Map<Quaternion<float>, Aligned> QuaternionMapAlignedf;
411 typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd;
412 
413 /***************************************************************************
414 * Implementation of QuaternionBase methods
415 ***************************************************************************/
416 
417 // Generic Quaternion * Quaternion product
418 // This product can be specialized for a given architecture via the Arch template argument.
419 namespace internal {
420 template<int Arch, class Derived1, class Derived2, typename Scalar, int _Options> struct quat_product
421 {
422  static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived1>& a, const QuaternionBase<Derived2>& b){
423  return Quaternion<Scalar>
424  (
425  a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
426  a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
427  a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),
428  a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x()
429  );
430  }
431 };
432 }
433 
435 template <class Derived>
436 template <class OtherDerived>
437 EIGEN_STRONG_INLINE Quaternion<typename internal::traits<Derived>::Scalar>
439 {
440  EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename OtherDerived::Scalar>::value),
441  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
442  return internal::quat_product<Architecture::Target, Derived, OtherDerived,
443  typename internal::traits<Derived>::Scalar,
444  EIGEN_PLAIN_ENUM_MIN(internal::traits<Derived>::Alignment, internal::traits<OtherDerived>::Alignment)>::run(*this, other);
445 }
446 
448 template <class Derived>
449 template <class OtherDerived>
450 EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator*= (const QuaternionBase<OtherDerived>& other)
451 {
452  derived() = derived() * other.derived();
453  return derived();
454 }
455 
463 template <class Derived>
464 EIGEN_STRONG_INLINE typename QuaternionBase<Derived>::Vector3
466 {
467  // Note that this algorithm comes from the optimization by hand
468  // of the conversion to a Matrix followed by a Matrix/Vector product.
469  // It appears to be much faster than the common algorithm found
470  // in the literature (30 versus 39 flops). It also requires two
471  // Vector3 as temporaries.
472  Vector3 uv = this->vec().cross(v);
473  uv += uv;
474  return v + this->w() * uv + this->vec().cross(uv);
475 }
476 
477 template<class Derived>
479 {
480  coeffs() = other.coeffs();
481  return derived();
482 }
483 
484 template<class Derived>
485 template<class OtherDerived>
486 EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const QuaternionBase<OtherDerived>& other)
487 {
488  coeffs() = other.coeffs();
489  return derived();
490 }
491 
494 template<class Derived>
495 EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa)
496 {
497  using std::cos;
498  using std::sin;
499  Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
500  this->w() = cos(ha);
501  this->vec() = sin(ha) * aa.axis();
502  return derived();
503 }
504 
511 template<class Derived>
512 template<class MatrixDerived>
514 {
515  EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename MatrixDerived::Scalar>::value),
516  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
517  internal::quaternionbase_assign_impl<MatrixDerived>::run(*this, xpr.derived());
518  return derived();
519 }
520 
524 template<class Derived>
525 inline typename QuaternionBase<Derived>::Matrix3
527 {
528  // NOTE if inlined, then gcc 4.2 and 4.4 get rid of the temporary (not gcc 4.3 !!)
529  // if not inlined then the cost of the return by value is huge ~ +35%,
530  // however, not inlining this function is an order of magnitude slower, so
531  // it has to be inlined, and so the return by value is not an issue
532  Matrix3 res;
533 
534  const Scalar tx = Scalar(2)*this->x();
535  const Scalar ty = Scalar(2)*this->y();
536  const Scalar tz = Scalar(2)*this->z();
537  const Scalar twx = tx*this->w();
538  const Scalar twy = ty*this->w();
539  const Scalar twz = tz*this->w();
540  const Scalar txx = tx*this->x();
541  const Scalar txy = ty*this->x();
542  const Scalar txz = tz*this->x();
543  const Scalar tyy = ty*this->y();
544  const Scalar tyz = tz*this->y();
545  const Scalar tzz = tz*this->z();
546 
547  res.coeffRef(0,0) = Scalar(1)-(tyy+tzz);
548  res.coeffRef(0,1) = txy-twz;
549  res.coeffRef(0,2) = txz+twy;
550  res.coeffRef(1,0) = txy+twz;
551  res.coeffRef(1,1) = Scalar(1)-(txx+tzz);
552  res.coeffRef(1,2) = tyz-twx;
553  res.coeffRef(2,0) = txz-twy;
554  res.coeffRef(2,1) = tyz+twx;
555  res.coeffRef(2,2) = Scalar(1)-(txx+tyy);
556 
557  return res;
558 }
559 
570 template<class Derived>
571 template<typename Derived1, typename Derived2>
573 {
574  using std::sqrt;
575  Vector3 v0 = a.normalized();
576  Vector3 v1 = b.normalized();
577  Scalar c = v1.dot(v0);
578 
579  // if dot == -1, vectors are nearly opposites
580  // => accurately compute the rotation axis by computing the
581  // intersection of the two planes. This is done by solving:
582  // x^T v0 = 0
583  // x^T v1 = 0
584  // under the constraint:
585  // ||x|| = 1
586  // which yields a singular value problem
587  if (c < Scalar(-1)+NumTraits<Scalar>::dummy_precision())
588  {
589  c = numext::maxi(c,Scalar(-1));
590  Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();
592  Vector3 axis = svd.matrixV().col(2);
593 
594  Scalar w2 = (Scalar(1)+c)*Scalar(0.5);
595  this->w() = sqrt(w2);
596  this->vec() = axis * sqrt(Scalar(1) - w2);
597  return derived();
598  }
599  Vector3 axis = v0.cross(v1);
600  Scalar s = sqrt((Scalar(1)+c)*Scalar(2));
601  Scalar invs = Scalar(1)/s;
602  this->vec() = axis * invs;
603  this->w() = s * Scalar(0.5);
604 
605  return derived();
606 }
607 
608 
619 template<typename Scalar, int Options>
620 template<typename Derived1, typename Derived2>
622 {
623  Quaternion quat;
624  quat.setFromTwoVectors(a, b);
625  return quat;
626 }
627 
628 
635 template <class Derived>
637 {
638  // FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite() ??
639  Scalar n2 = this->squaredNorm();
640  if (n2 > Scalar(0))
641  return Quaternion<Scalar>(conjugate().coeffs() / n2);
642  else
643  {
644  // return an invalid result to flag the error
645  return Quaternion<Scalar>(Coefficients::Zero());
646  }
647 }
648 
649 // Generic conjugate of a Quaternion
650 namespace internal {
651 template<int Arch, class Derived, typename Scalar, int _Options> struct quat_conj
652 {
653  static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived>& q){
654  return Quaternion<Scalar>(q.w(),-q.x(),-q.y(),-q.z());
655  }
656 };
657 }
658 
665 template <class Derived>
666 inline Quaternion<typename internal::traits<Derived>::Scalar>
668 {
669  return internal::quat_conj<Architecture::Target, Derived,
670  typename internal::traits<Derived>::Scalar,
671  internal::traits<Derived>::Alignment>::run(*this);
672 
673 }
674 
678 template <class Derived>
679 template <class OtherDerived>
680 inline typename internal::traits<Derived>::Scalar
682 {
683  using std::atan2;
684  using std::abs;
685  Quaternion<Scalar> d = (*this) * other.conjugate();
686  return Scalar(2) * atan2( d.vec().norm(), abs(d.w()) );
687 }
688 
689 
690 
697 template <class Derived>
698 template <class OtherDerived>
701 {
702  using std::acos;
703  using std::sin;
704  using std::abs;
705  static const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();
706  Scalar d = this->dot(other);
707  Scalar absD = abs(d);
708 
709  Scalar scale0;
710  Scalar scale1;
711 
712  if(absD>=one)
713  {
714  scale0 = Scalar(1) - t;
715  scale1 = t;
716  }
717  else
718  {
719  // theta is the angle between the 2 quaternions
720  Scalar theta = acos(absD);
721  Scalar sinTheta = sin(theta);
722 
723  scale0 = sin( ( Scalar(1) - t ) * theta) / sinTheta;
724  scale1 = sin( ( t * theta) ) / sinTheta;
725  }
726  if(d<Scalar(0)) scale1 = -scale1;
727 
728  return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());
729 }
730 
731 namespace internal {
732 
733 // set from a rotation matrix
734 template<typename Other>
735 struct quaternionbase_assign_impl<Other,3,3>
736 {
737  typedef typename Other::Scalar Scalar;
738  template<class Derived> static inline void run(QuaternionBase<Derived>& q, const Other& mat)
739  {
740  using std::sqrt;
741  // This algorithm comes from "Quaternion Calculus and Fast Animation",
742  // Ken Shoemake, 1987 SIGGRAPH course notes
743  Scalar t = mat.trace();
744  if (t > Scalar(0))
745  {
746  t = sqrt(t + Scalar(1.0));
747  q.w() = Scalar(0.5)*t;
748  t = Scalar(0.5)/t;
749  q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
750  q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
751  q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
752  }
753  else
754  {
755  Index i = 0;
756  if (mat.coeff(1,1) > mat.coeff(0,0))
757  i = 1;
758  if (mat.coeff(2,2) > mat.coeff(i,i))
759  i = 2;
760  Index j = (i+1)%3;
761  Index k = (j+1)%3;
762 
763  t = sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
764  q.coeffs().coeffRef(i) = Scalar(0.5) * t;
765  t = Scalar(0.5)/t;
766  q.w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
767  q.coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;
768  q.coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;
769  }
770  }
771 };
772 
773 // set from a vector of coefficients assumed to be a quaternion
774 template<typename Other>
775 struct quaternionbase_assign_impl<Other,4,1>
776 {
777  typedef typename Other::Scalar Scalar;
778  template<class Derived> static inline void run(QuaternionBase<Derived>& q, const Other& vec)
779  {
780  q.coeffs() = vec;
781  }
782 };
783 
784 } // end namespace internal
785 
786 } // end namespace Eigen
787 
788 #endif // EIGEN_QUATERNION_H
Scalar x() const
Definition: Quaternion.h:61
Scalar dot(const QuaternionBase< OtherDerived > &other) const
Definition: Quaternion.h:134
Vector3 _transformVector(const Vector3 &v) const
Definition: Quaternion.h:465
Scalar y() const
Definition: Quaternion.h:63
Scalar norm() const
Definition: Quaternion.h:120
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:89
Matrix< Scalar, 3, 1 > Vector3
Definition: Quaternion.h:52
Quaternion< double > Quaterniond
Definition: Quaternion.h:299
const unsigned int LvalueBit
Definition: Constants.h:130
Definition: LDLT.h:16
const VectorBlock< const Coefficients, 3 > vec() const
Definition: Quaternion.h:79
internal::cast_return_type< Derived, Quaternion< NewScalarType > >::type cast() const
Definition: Quaternion.h:173
const internal::traits< Derived >::Coefficients & coeffs() const
Definition: Quaternion.h:85
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:107
AngleAxis< Scalar > AngleAxisType
Definition: Quaternion.h:56
Scalar z() const
Definition: Quaternion.h:65
Quaternion()
Definition: Quaternion.h:242
Derived & operator*=(const QuaternionBase< OtherDerived > &q)
Definition: Quaternion.h:450
Definition: Constants.h:318
static Quaternion< Scalar > Identity()
Definition: Quaternion.h:106
Scalar squaredNorm() const
Definition: Quaternion.h:115
Map(const Scalar *coeffs)
Definition: Quaternion.h:354
void normalize()
Definition: Quaternion.h:124
Derived & setFromTwoVectors(const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b)
Definition: Quaternion.h:572
Expression of a fixed-size or dynamic-size sub-vector.
Definition: ForwardDeclarations.h:87
internal::traits< Derived >::Coefficients & coeffs()
Definition: Quaternion.h:88
Scalar & x()
Definition: Quaternion.h:70
Map(Scalar *coeffs)
Definition: Quaternion.h:391
bool isApprox(const QuaternionBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Quaternion.h:161
const PlainObject normalized() const
Definition: Dot.h:114
const MatrixVType & matrixV() const
Definition: SVDBase.h:99
Quaternion(const Quaternion< OtherScalar, OtherOptions > &other)
Definition: Quaternion.h:271
Quaternion< Scalar > conjugate() const
Definition: Quaternion.h:667
Scalar & z()
Definition: Quaternion.h:74
Base class for quaternion expressions.
Definition: ForwardDeclarations.h:264
Quaternion< Scalar > inverse() const
Definition: Quaternion.h:636
Map< Quaternion< float >, 0 > QuaternionMapf
Definition: Quaternion.h:402
Definition: Eigen_Colamd.h:54
Quaternion(const AngleAxisType &aa)
Definition: Quaternion.h:260
The quaternion class used to represent 3D orientations and rotations.
Definition: ForwardDeclarations.h:270
Quaternion(const MatrixBase< Derived > &other)
Definition: Quaternion.h:267
Map< Quaternion< double >, 0 > QuaternionMapd
Definition: Quaternion.h:405
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: ForwardDeclarations.h:254
Scalar w() const
Definition: Quaternion.h:67
Matrix3 toRotationMatrix() const
Definition: Quaternion.h:526
Map< Quaternion< float >, Aligned > QuaternionMapAlignedf
Definition: Quaternion.h:408
QuaternionBase & setIdentity()
Definition: Quaternion.h:110
Scalar & w()
Definition: Quaternion.h:76
Quaternion< Scalar > normalized() const
Definition: Quaternion.h:127
Scalar & y()
Definition: Quaternion.h:72
Matrix< Scalar, 3, 3 > Matrix3
Definition: Quaternion.h:54
VectorBlock< Coefficients, 3 > vec()
Definition: Quaternion.h:82
Definition: Constants.h:379
Definition: Constants.h:227
Quaternion(const Scalar &w, const Scalar &x, const Scalar &y, const Scalar &z)
Definition: Quaternion.h:251
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.
Definition: ForwardDeclarations.h:266
Quaternion(const Scalar *data)
Definition: Quaternion.h:254
Quaternion< float > Quaternionf
Definition: Quaternion.h:296
Map< Quaternion< double >, Aligned > QuaternionMapAlignedd
Definition: Quaternion.h:411
Quaternion(const QuaternionBase< Derived > &other)
Definition: Quaternion.h:257