Quaternion.h
Go to the documentation of this file.
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>
26 }
27 
34 template<class Derived>
35 class QuaternionBase : public RotationBase<Derived, 3>
36 {
37  public:
39 
40  using Base::operator*;
41  using Base::derived;
42 
46  enum {
48  };
49 
50  // typedef typename Matrix<Scalar,4,1> Coefficients;
57 
58 
59 
61  EIGEN_DEVICE_FUNC inline Scalar x() const { return this->derived().coeffs().coeff(0); }
63  EIGEN_DEVICE_FUNC inline Scalar y() const { return this->derived().coeffs().coeff(1); }
65  EIGEN_DEVICE_FUNC inline Scalar z() const { return this->derived().coeffs().coeff(2); }
67  EIGEN_DEVICE_FUNC inline Scalar w() const { return this->derived().coeffs().coeff(3); }
68 
70  EIGEN_DEVICE_FUNC inline Scalar& x() { return this->derived().coeffs().coeffRef(0); }
72  EIGEN_DEVICE_FUNC inline Scalar& y() { return this->derived().coeffs().coeffRef(1); }
74  EIGEN_DEVICE_FUNC inline Scalar& z() { return this->derived().coeffs().coeffRef(2); }
76  EIGEN_DEVICE_FUNC inline Scalar& w() { return this->derived().coeffs().coeffRef(3); }
77 
79  EIGEN_DEVICE_FUNC inline const VectorBlock<const Coefficients,3> vec() const { return coeffs().template head<3>(); }
80 
82  EIGEN_DEVICE_FUNC inline VectorBlock<Coefficients,3> vec() { return coeffs().template head<3>(); }
83 
85  EIGEN_DEVICE_FUNC inline const typename internal::traits<Derived>::Coefficients& coeffs() const { return derived().coeffs(); }
86 
88  EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Coefficients& coeffs() { return derived().coeffs(); }
89 
90  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE QuaternionBase<Derived>& operator=(const QuaternionBase<Derived>& other);
91  template<class OtherDerived> EIGEN_DEVICE_FUNC 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  EIGEN_DEVICE_FUNC Derived& operator=(const AngleAxisType& aa);
101  template<class OtherDerived> EIGEN_DEVICE_FUNC Derived& operator=(const MatrixBase<OtherDerived>& m);
102 
106  EIGEN_DEVICE_FUNC static inline Quaternion<Scalar> Identity() { return Quaternion<Scalar>(Scalar(1), Scalar(0), Scalar(0), Scalar(0)); }
107 
110  EIGEN_DEVICE_FUNC inline QuaternionBase& setIdentity() { coeffs() << Scalar(0), Scalar(0), Scalar(0), Scalar(1); return *this; }
111 
115  EIGEN_DEVICE_FUNC inline Scalar squaredNorm() const { return coeffs().squaredNorm(); }
116 
120  EIGEN_DEVICE_FUNC inline Scalar norm() const { return coeffs().norm(); }
121 
124  EIGEN_DEVICE_FUNC inline void normalize() { coeffs().normalize(); }
127  EIGEN_DEVICE_FUNC inline Quaternion<Scalar> normalized() const { return Quaternion<Scalar>(coeffs().normalized()); }
128 
134  template<class OtherDerived> EIGEN_DEVICE_FUNC inline Scalar dot(const QuaternionBase<OtherDerived>& other) const { return coeffs().dot(other.coeffs()); }
135 
136  template<class OtherDerived> EIGEN_DEVICE_FUNC Scalar angularDistance(const QuaternionBase<OtherDerived>& other) const;
137 
139  EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix() const;
140 
142  template<typename Derived1, typename Derived2>
143  EIGEN_DEVICE_FUNC Derived& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
144 
145  template<class OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion<Scalar> operator* (const QuaternionBase<OtherDerived>& q) const;
146  template<class OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator*= (const QuaternionBase<OtherDerived>& q);
147 
149  EIGEN_DEVICE_FUNC Quaternion<Scalar> inverse() const;
150 
152  EIGEN_DEVICE_FUNC Quaternion<Scalar> conjugate() const;
153 
154  template<class OtherDerived> EIGEN_DEVICE_FUNC Quaternion<Scalar> slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const;
155 
160  template<class OtherDerived>
161  EIGEN_DEVICE_FUNC bool isApprox(const QuaternionBase<OtherDerived>& other, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const
162  { return coeffs().isApprox(other.coeffs(), prec); }
163 
165  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3& v) const;
166 
172  template<typename NewScalarType>
173  EIGEN_DEVICE_FUNC 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 {
217  typedef _Scalar Scalar;
219  enum{
221  Flags = LvalueBit
222  };
223 };
224 }
225 
226 template<typename _Scalar, int _Options>
227 class Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >
228 {
229 public:
231  enum { NeedsAlignment = internal::traits<Quaternion>::Alignment>0 };
232 
233  typedef _Scalar Scalar;
234 
236  using Base::operator*=;
237 
238  typedef typename internal::traits<Quaternion>::Coefficients Coefficients;
239  typedef typename Base::AngleAxisType AngleAxisType;
240 
242  EIGEN_DEVICE_FUNC inline Quaternion() {}
243 
251  EIGEN_DEVICE_FUNC inline Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar& z) : m_coeffs(x, y, z, w){}
252 
254  EIGEN_DEVICE_FUNC explicit inline Quaternion(const Scalar* data) : m_coeffs(data) {}
255 
257  template<class Derived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion(const QuaternionBase<Derived>& other) { this->Base::operator=(other); }
258 
260  EIGEN_DEVICE_FUNC explicit inline Quaternion(const AngleAxisType& aa) { *this = aa; }
261 
266  template<typename Derived>
267  EIGEN_DEVICE_FUNC explicit inline Quaternion(const MatrixBase<Derived>& other) { *this = other; }
268 
270  template<typename OtherScalar, int OtherOptions>
271  EIGEN_DEVICE_FUNC explicit inline Quaternion(const Quaternion<OtherScalar, OtherOptions>& other)
272  { m_coeffs = other.coeffs().template cast<Scalar>(); }
273 
274  EIGEN_DEVICE_FUNC static Quaternion UnitRandom();
275 
276  template<typename Derived1, typename Derived2>
277  EIGEN_DEVICE_FUNC static Quaternion FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
278 
279  EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs;}
280  EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs;}
281 
282  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(NeedsAlignment))
283 
284 #ifdef EIGEN_QUATERNION_PLUGIN
285 # include EIGEN_QUATERNION_PLUGIN
286 #endif
287 
288 protected:
289  Coefficients m_coeffs;
290 
291 #ifndef EIGEN_PARSED_BY_DOXYGEN
293  {
294  EIGEN_STATIC_ASSERT( (_Options & DontAlign) == _Options,
295  INVALID_MATRIX_TEMPLATE_PARAMETERS)
296  }
297 #endif
298 };
299 
306 
307 /***************************************************************************
308 * Specialization of Map<Quaternion<Scalar>>
309 ***************************************************************************/
310 
311 namespace internal {
312  template<typename _Scalar, int _Options>
313  struct traits<Map<Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
314  {
316  };
317 }
318 
319 namespace internal {
320  template<typename _Scalar, int _Options>
321  struct traits<Map<const Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
322  {
325  enum {
326  Flags = TraitsBase::Flags & ~LvalueBit
327  };
328  };
329 }
330 
342 template<typename _Scalar, int _Options>
343 class Map<const Quaternion<_Scalar>, _Options >
344  : public QuaternionBase<Map<const Quaternion<_Scalar>, _Options> >
345 {
346  public:
348 
349  typedef _Scalar Scalar;
352  using Base::operator*=;
353 
360  EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(const Scalar* coeffs) : m_coeffs(coeffs) {}
361 
362  EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs;}
363 
364  protected:
365  const Coefficients m_coeffs;
366 };
367 
379 template<typename _Scalar, int _Options>
380 class Map<Quaternion<_Scalar>, _Options >
381  : public QuaternionBase<Map<Quaternion<_Scalar>, _Options> >
382 {
383  public:
385 
386  typedef _Scalar Scalar;
389  using Base::operator*=;
390 
397  EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(Scalar* coeffs) : m_coeffs(coeffs) {}
398 
399  EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs; }
400  EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs; }
401 
402  protected:
403  Coefficients m_coeffs;
404 };
405 
414 typedef Map<Quaternion<float>, Aligned> QuaternionMapAlignedf;
417 typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd;
418 
419 /***************************************************************************
420 * Implementation of QuaternionBase methods
421 ***************************************************************************/
422 
423 // Generic Quaternion * Quaternion product
424 // This product can be specialized for a given architecture via the Arch template argument.
425 namespace internal {
426 template<int Arch, class Derived1, class Derived2, typename Scalar> struct quat_product
427 {
429  return Quaternion<Scalar>
430  (
431  a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
432  a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
433  a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),
434  a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x()
435  );
436  }
437 };
438 }
439 
441 template <class Derived>
442 template <class OtherDerived>
445 {
447  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
448  return internal::quat_product<Architecture::Target, Derived, OtherDerived,
449  typename internal::traits<Derived>::Scalar>::run(*this, other);
450 }
451 
453 template <class Derived>
454 template <class OtherDerived>
456 {
457  derived() = derived() * other.derived();
458  return derived();
459 }
460 
468 template <class Derived>
469 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename QuaternionBase<Derived>::Vector3
471 {
472  // Note that this algorithm comes from the optimization by hand
473  // of the conversion to a Matrix followed by a Matrix/Vector product.
474  // It appears to be much faster than the common algorithm found
475  // in the literature (30 versus 39 flops). It also requires two
476  // Vector3 as temporaries.
477  Vector3 uv = this->vec().cross(v);
478  uv += uv;
479  return v + this->w() * uv + this->vec().cross(uv);
480 }
481 
482 template<class Derived>
484 {
485  coeffs() = other.coeffs();
486  return derived();
487 }
488 
489 template<class Derived>
490 template<class OtherDerived>
492 {
493  coeffs() = other.coeffs();
494  return derived();
495 }
496 
499 template<class Derived>
500 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa)
501 {
502  EIGEN_USING_STD_MATH(cos)
503  EIGEN_USING_STD_MATH(sin)
504  Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
505  this->w() = cos(ha);
506  this->vec() = sin(ha) * aa.axis();
507  return derived();
508 }
509 
516 template<class Derived>
517 template<class MatrixDerived>
518 EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::operator=(const MatrixBase<MatrixDerived>& xpr)
519 {
521  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
523  return derived();
524 }
525 
529 template<class Derived>
530 EIGEN_DEVICE_FUNC inline typename QuaternionBase<Derived>::Matrix3
532 {
533  // NOTE if inlined, then gcc 4.2 and 4.4 get rid of the temporary (not gcc 4.3 !!)
534  // if not inlined then the cost of the return by value is huge ~ +35%,
535  // however, not inlining this function is an order of magnitude slower, so
536  // it has to be inlined, and so the return by value is not an issue
537  Matrix3 res;
538 
539  const Scalar tx = Scalar(2)*this->x();
540  const Scalar ty = Scalar(2)*this->y();
541  const Scalar tz = Scalar(2)*this->z();
542  const Scalar twx = tx*this->w();
543  const Scalar twy = ty*this->w();
544  const Scalar twz = tz*this->w();
545  const Scalar txx = tx*this->x();
546  const Scalar txy = ty*this->x();
547  const Scalar txz = tz*this->x();
548  const Scalar tyy = ty*this->y();
549  const Scalar tyz = tz*this->y();
550  const Scalar tzz = tz*this->z();
551 
552  res.coeffRef(0,0) = Scalar(1)-(tyy+tzz);
553  res.coeffRef(0,1) = txy-twz;
554  res.coeffRef(0,2) = txz+twy;
555  res.coeffRef(1,0) = txy+twz;
556  res.coeffRef(1,1) = Scalar(1)-(txx+tzz);
557  res.coeffRef(1,2) = tyz-twx;
558  res.coeffRef(2,0) = txz-twy;
559  res.coeffRef(2,1) = tyz+twx;
560  res.coeffRef(2,2) = Scalar(1)-(txx+tyy);
561 
562  return res;
563 }
564 
575 template<class Derived>
576 template<typename Derived1, typename Derived2>
577 EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
578 {
579  EIGEN_USING_STD_MATH(sqrt)
580  Vector3 v0 = a.normalized();
581  Vector3 v1 = b.normalized();
582  Scalar c = v1.dot(v0);
583 
584  // if dot == -1, vectors are nearly opposites
585  // => accurately compute the rotation axis by computing the
586  // intersection of the two planes. This is done by solving:
587  // x^T v0 = 0
588  // x^T v1 = 0
589  // under the constraint:
590  // ||x|| = 1
591  // which yields a singular value problem
592  if (c < Scalar(-1)+NumTraits<Scalar>::dummy_precision())
593  {
594  c = numext::maxi(c,Scalar(-1));
595  Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();
597  Vector3 axis = svd.matrixV().col(2);
598 
599  Scalar w2 = (Scalar(1)+c)*Scalar(0.5);
600  this->w() = sqrt(w2);
601  this->vec() = axis * sqrt(Scalar(1) - w2);
602  return derived();
603  }
604  Vector3 axis = v0.cross(v1);
605  Scalar s = sqrt((Scalar(1)+c)*Scalar(2));
606  Scalar invs = Scalar(1)/s;
607  this->vec() = axis * invs;
608  this->w() = s * Scalar(0.5);
609 
610  return derived();
611 }
612 
617 template<typename Scalar, int Options>
619 {
620  EIGEN_USING_STD_MATH(sqrt)
621  EIGEN_USING_STD_MATH(sin)
622  EIGEN_USING_STD_MATH(cos)
623  const Scalar u1 = internal::random<Scalar>(0, 1),
624  u2 = internal::random<Scalar>(0, 2*EIGEN_PI),
625  u3 = internal::random<Scalar>(0, 2*EIGEN_PI);
626  const Scalar a = sqrt(1 - u1),
627  b = sqrt(u1);
628  return Quaternion (a * sin(u2), a * cos(u2), b * sin(u3), b * cos(u3));
629 }
630 
631 
642 template<typename Scalar, int Options>
643 template<typename Derived1, typename Derived2>
645 {
646  Quaternion quat;
647  quat.setFromTwoVectors(a, b);
648  return quat;
649 }
650 
651 
658 template <class Derived>
660 {
661  // FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite() ??
662  Scalar n2 = this->squaredNorm();
663  if (n2 > Scalar(0))
664  return Quaternion<Scalar>(conjugate().coeffs() / n2);
665  else
666  {
667  // return an invalid result to flag the error
668  return Quaternion<Scalar>(Coefficients::Zero());
669  }
670 }
671 
672 // Generic conjugate of a Quaternion
673 namespace internal {
674 template<int Arch, class Derived, typename Scalar> struct quat_conj
675 {
677  return Quaternion<Scalar>(q.w(),-q.x(),-q.y(),-q.z());
678  }
679 };
680 }
681 
688 template <class Derived>
691 {
694 
695 }
696 
700 template <class Derived>
701 template <class OtherDerived>
702 EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Scalar
704 {
705  EIGEN_USING_STD_MATH(atan2)
706  Quaternion<Scalar> d = (*this) * other.conjugate();
707  return Scalar(2) * atan2( d.vec().norm(), numext::abs(d.w()) );
708 }
709 
710 
711 
718 template <class Derived>
719 template <class OtherDerived>
722 {
723  EIGEN_USING_STD_MATH(acos)
724  EIGEN_USING_STD_MATH(sin)
725  const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();
726  Scalar d = this->dot(other);
727  Scalar absD = numext::abs(d);
728 
729  Scalar scale0;
730  Scalar scale1;
731 
732  if(absD>=one)
733  {
734  scale0 = Scalar(1) - t;
735  scale1 = t;
736  }
737  else
738  {
739  // theta is the angle between the 2 quaternions
740  Scalar theta = acos(absD);
741  Scalar sinTheta = sin(theta);
742 
743  scale0 = sin( ( Scalar(1) - t ) * theta) / sinTheta;
744  scale1 = sin( ( t * theta) ) / sinTheta;
745  }
746  if(d<Scalar(0)) scale1 = -scale1;
747 
748  return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());
749 }
750 
751 namespace internal {
752 
753 // set from a rotation matrix
754 template<typename Other>
755 struct quaternionbase_assign_impl<Other,3,3>
756 {
757  typedef typename Other::Scalar Scalar;
758  template<class Derived> EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& a_mat)
759  {
760  const typename internal::nested_eval<Other,2>::type mat(a_mat);
761  EIGEN_USING_STD_MATH(sqrt)
762  // This algorithm comes from "Quaternion Calculus and Fast Animation",
763  // Ken Shoemake, 1987 SIGGRAPH course notes
764  Scalar t = mat.trace();
765  if (t > Scalar(0))
766  {
767  t = sqrt(t + Scalar(1.0));
768  q.w() = Scalar(0.5)*t;
769  t = Scalar(0.5)/t;
770  q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
771  q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
772  q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
773  }
774  else
775  {
776  Index i = 0;
777  if (mat.coeff(1,1) > mat.coeff(0,0))
778  i = 1;
779  if (mat.coeff(2,2) > mat.coeff(i,i))
780  i = 2;
781  Index j = (i+1)%3;
782  Index k = (j+1)%3;
783 
784  t = sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
785  q.coeffs().coeffRef(i) = Scalar(0.5) * t;
786  t = Scalar(0.5)/t;
787  q.w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
788  q.coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;
789  q.coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;
790  }
791  }
792 };
793 
794 // set from a vector of coefficients assumed to be a quaternion
795 template<typename Other>
796 struct quaternionbase_assign_impl<Other,4,1>
797 {
798  typedef typename Other::Scalar Scalar;
799  template<class Derived> EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& vec)
800  {
801  q.coeffs() = vec;
802  }
803 };
804 
805 } // end namespace internal
806 
807 } // end namespace Eigen
808 
809 #endif // EIGEN_QUATERNION_H
EIGEN_DEVICE_FUNC Scalar z() const
Definition: Quaternion.h:65
d
EIGEN_DEVICE_FUNC Coefficients & coeffs()
Definition: Quaternion.h:279
internal::traits< Derived >::Coefficients Coefficients
Definition: Quaternion.h:45
EIGEN_DEVICE_FUNC internal::cast_return_type< Derived, Quaternion< NewScalarType > >::type cast() const
Definition: Quaternion.h:173
#define EIGEN_STRONG_INLINE
Definition: Macros.h:493
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half & operator*=(half &a, const half &b)
Definition: Half.h:228
NumTraits< Scalar >::Real RealScalar
Definition: Quaternion.h:44
#define EIGEN_PI
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion(const QuaternionBase< Derived > &other)
Definition: Quaternion.h:257
EIGEN_DEVICE_FUNC Quaternion< Scalar > normalized() const
Definition: Quaternion.h:127
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:88
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator*=(const QuaternionBase< OtherDerived > &q)
Definition: Quaternion.h:455
Matrix< Scalar, 3, 1 > Vector3
Definition: Quaternion.h:52
Quaternion< double > Quaterniond
Definition: Quaternion.h:305
const unsigned int LvalueBit
Definition: Constants.h:139
XmlRpcServer s
EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix() const
Definition: Quaternion.h:531
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Definition: LDLT.h:16
EIGEN_DEVICE_FUNC Quaternion(const Scalar &w, const Scalar &x, const Scalar &y, const Scalar &z)
Definition: Quaternion.h:251
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:150
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion< Scalar > run(const QuaternionBase< Derived > &q)
Definition: Quaternion.h:676
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition: StaticAssert.h:122
EIGEN_DEVICE_FUNC Quaternion< Scalar > conjugate() const
Definition: Quaternion.h:690
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
AngleAxis< Scalar > AngleAxisType
Definition: Quaternion.h:56
Coefficients m_coeffs
Definition: Quaternion.h:289
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion< Scalar > operator*(const QuaternionBase< OtherDerived > &q) const
EIGEN_DEVICE_FUNC const Coefficients & coeffs() const
Definition: Quaternion.h:280
EIGEN_DEVICE_FUNC Scalar & y()
Definition: Quaternion.h:72
TFSIMD_FORCE_INLINE Quaternion slerp(const Quaternion &q1, const Quaternion &q2, const tfScalar &t)
Map< const Matrix< _Scalar, 4, 1 >, _Options > Coefficients
Definition: Quaternion.h:323
EIGEN_DEVICE_FUNC Quaternion< Scalar > inverse() const
Definition: Quaternion.h:659
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
EIGEN_DEVICE_FUNC const Vector3 & axis() const
Definition: AngleAxis.h:96
EIGEN_DEVICE_FUNC Quaternion(const MatrixBase< Derived > &other)
Definition: Quaternion.h:267
static EIGEN_DEVICE_FUNC void run(QuaternionBase< Derived > &q, const Other &vec)
Definition: Quaternion.h:799
EIGEN_DEVICE_FUNC Derived & setFromTwoVectors(const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b)
Definition: Quaternion.h:577
EIGEN_DEVICE_FUNC const VectorBlock< const Coefficients, 3 > vec() const
Definition: Quaternion.h:79
static EIGEN_STRONG_INLINE void _check_template_params()
Definition: Quaternion.h:292
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
Definition: Memory.h:687
EIGEN_DEVICE_FUNC const CosReturnType cos() const
EIGEN_DEVICE_FUNC Scalar angle() const
Definition: AngleAxis.h:91
Expression of a fixed-size or dynamic-size sub-vector.
static EIGEN_DEVICE_FUNC Quaternion< Scalar > Identity()
Definition: Quaternion.h:106
EIGEN_DEVICE_FUNC const internal::traits< Derived >::Coefficients & coeffs() const
Definition: Quaternion.h:85
EIGEN_DEVICE_FUNC void normalize()
Definition: Quaternion.h:124
EIGEN_DEVICE_FUNC bool isApprox(const QuaternionBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Quaternion.h:161
EIGEN_DEVICE_FUNC VectorBlock< Coefficients, 3 > vec()
Definition: Quaternion.h:82
EIGEN_DEVICE_FUNC const Coefficients & coeffs() const
Definition: Quaternion.h:400
EIGEN_DEVICE_FUNC Scalar w() const
Definition: Quaternion.h:67
Map< Matrix< _Scalar, 4, 1 >, _Options > Coefficients
Definition: Quaternion.h:315
traits< Quaternion< _Scalar,(int(_Options)&Aligned)==Aligned?AutoAlign:DontAlign > > TraitsBase
Definition: Quaternion.h:324
EIGEN_DEVICE_FUNC internal::traits< Derived >::Coefficients & coeffs()
Definition: Quaternion.h:88
static EIGEN_DEVICE_FUNC Matrix< Scalar, 2, 2 > toRotationMatrix(const Scalar &s)
Definition: RotationBase.h:182
EIGEN_DEVICE_FUNC Scalar dot(const QuaternionBase< OtherDerived > &other) const
Definition: Quaternion.h:134
EIGEN_DEVICE_FUNC ConjugateReturnType conjugate() const
EIGEN_DEVICE_FUNC Scalar angularDistance(const QuaternionBase< OtherDerived > &other) const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
static EIGEN_DEVICE_FUNC Quaternion FromTwoVectors(const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b)
EIGEN_DEVICE_FUNC Quaternion(const Scalar *data)
Definition: Quaternion.h:254
EIGEN_DEVICE_FUNC const PlainObject normalized() const
Definition: Dot.h:121
Common base class for compact rotation representations.
EIGEN_DEVICE_FUNC const Scalar & q
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Definition: Macros.h:839
EIGEN_DEVICE_FUNC Quaternion(const Quaternion< OtherScalar, OtherOptions > &other)
Definition: Quaternion.h:271
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorUInt128< uint64_t, uint64_t > operator*(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Base class for quaternion expressions.
internal::traits< Map >::Coefficients Coefficients
Definition: Quaternion.h:350
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE QuaternionBase< Derived > & operator=(const QuaternionBase< Derived > &other)
Definition: Quaternion.h:483
EIGEN_DEVICE_FUNC Quaternion(const AngleAxisType &aa)
Definition: Quaternion.h:260
EIGEN_DEVICE_FUNC QuaternionBase & setIdentity()
Definition: Quaternion.h:110
EIGEN_DEVICE_FUNC Scalar & z()
Definition: Quaternion.h:74
TFSIMD_FORCE_INLINE tfScalar dot(const Quaternion &q1, const Quaternion &q2)
QuaternionBase< Map< const Quaternion< _Scalar >, _Options > > Base
Definition: Quaternion.h:347
TFSIMD_FORCE_INLINE const tfScalar & z() const
EIGEN_DEVICE_FUNC const Derived & derived() const
Definition: RotationBase.h:41
EIGEN_DEVICE_FUNC const AcosReturnType acos() const
Map< Quaternion< float >, 0 > QuaternionMapf
Definition: Quaternion.h:408
EIGEN_DEVICE_FUNC Coefficients & coeffs()
Definition: Quaternion.h:399
TFSIMD_FORCE_INLINE const tfScalar & w() const
EIGEN_DEVICE_FUNC Scalar norm() const
Definition: Quaternion.h:120
EIGEN_DEVICE_FUNC const Coefficients & coeffs() const
Definition: Quaternion.h:362
The quaternion class used to represent 3D orientations and rotations.
RotationBase< Derived, 3 > Base
Definition: Quaternion.h:38
Map< Quaternion< double >, 0 > QuaternionMapd
Definition: Quaternion.h:411
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Map< Quaternion< float >, Aligned > QuaternionMapAlignedf
Definition: Quaternion.h:414
const AutoDiffScalar< Matrix< typename internal::traits< typename internal::remove_all< DerTypeA >::type >::Scalar, Dynamic, 1 > > atan2(const AutoDiffScalar< DerTypeA > &a, const AutoDiffScalar< DerTypeB > &b)
EIGEN_DEVICE_FUNC Quaternion< Scalar > slerp(const Scalar &t, const QuaternionBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC const SinReturnType sin() const
EIGEN_DEVICE_FUNC Scalar x() const
Definition: Quaternion.h:61
EIGEN_DEVICE_FUNC Scalar & w()
Definition: Quaternion.h:76
internal::traits< Map >::Coefficients Coefficients
Definition: Quaternion.h:387
Matrix< Scalar, 3, 3 > Matrix3
Definition: Quaternion.h:54
EIGEN_DEVICE_FUNC Scalar & x()
Definition: Quaternion.h:70
static EIGEN_DEVICE_FUNC Quaternion UnitRandom()
Definition: Quaternion.h:618
void run(Expr &expr, Dev &dev)
Definition: TensorSyclRun.h:33
EIGEN_DEVICE_FUNC Scalar y() const
Definition: Quaternion.h:63
EIGEN_DEVICE_FUNC const Scalar & b
internal::traits< Derived >::Scalar Scalar
Definition: Quaternion.h:43
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3 &v) const
Definition: Quaternion.h:470
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.
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion< Scalar > run(const QuaternionBase< Derived1 > &a, const QuaternionBase< Derived2 > &b)
Definition: Quaternion.h:428
QuaternionBase< Quaternion< _Scalar, _Options > > Base
Definition: Quaternion.h:230
Quaternion< float > Quaternionf
Definition: Quaternion.h:302
Map< Quaternion< double >, Aligned > QuaternionMapAlignedd
Definition: Quaternion.h:417
EIGEN_DEVICE_FUNC Scalar squaredNorm() const
Definition: Quaternion.h:115
const T & y
QuaternionBase< Map< Quaternion< _Scalar >, _Options > > Base
Definition: Quaternion.h:384
static EIGEN_DEVICE_FUNC void run(QuaternionBase< Derived > &q, const Other &a_mat)
Definition: Quaternion.h:758


hebiros
Author(s): Xavier Artache , Matthew Tesch
autogenerated on Thu Sep 3 2020 04:08:42