Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Eigen_test Odometry_test AttitudeEstimation_usingTicker MPU9250_Quaternion_Binary_Serial ... more
QuaternionBase< Derived > Class Template Reference
[Geometry module]
  #include <Quaternion.h>
Inherits RotationBase< Derived, 3 >.
| Public Types | |
| typedef internal::traits < Derived >::Scalar | Scalar | 
| the scalar type of the coefficients | |
| typedef Matrix< Scalar, 3, 1 > | Vector3 | 
| the type of a 3D vector | |
| typedef Matrix< Scalar, 3, 3 > | Matrix3 | 
| the equivalent rotation matrix type | |
| typedef AngleAxis< Scalar > | AngleAxisType | 
| the equivalent angle-axis type | |
| typedef Matrix< Scalar, Dim, Dim > | RotationMatrixType | 
| corresponding linear transformation matrix type | |
| Public Member Functions | |
| Scalar | x () const | 
| Scalar | y () const | 
| Scalar | z () const | 
| Scalar | w () const | 
| Scalar & | x () | 
| Scalar & | y () | 
| Scalar & | z () | 
| Scalar & | w () | 
| const VectorBlock< const Coefficients, 3 > | vec () const | 
| VectorBlock< Coefficients, 3 > | vec () | 
| const internal::traits < Derived >::Coefficients & | coeffs () const | 
| internal::traits< Derived > ::Coefficients & | coeffs () | 
| Derived & | operator= (const AngleAxisType &aa) | 
| Set *thisfrom an angle-axis aa and returns a reference to*this. | |
| QuaternionBase & | setIdentity () | 
| Scalar | squaredNorm () const | 
| Scalar | norm () const | 
| void | normalize () | 
| Normalizes the quaternion *this. | |
| Quaternion< Scalar > | normalized () const | 
| template<class OtherDerived > | |
| Scalar | dot (const QuaternionBase< OtherDerived > &other) const | 
| template<class OtherDerived > | |
| Scalar | angularDistance (const QuaternionBase< OtherDerived > &other) const | 
| Matrix3 | toRotationMatrix () const | 
| Convert the quaternion to a 3x3 rotation matrix. | |
| template<typename Derived1 , typename Derived2 > | |
| Derived & | setFromTwoVectors (const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b) | 
| Sets *thisto be a quaternion representing a rotation between the two arbitrary vectors a and b. | |
| template<class OtherDerived > | |
| EIGEN_STRONG_INLINE Quaternion < Scalar > | operator* (const QuaternionBase< OtherDerived > &q) const | 
| template<class OtherDerived > | |
| EIGEN_STRONG_INLINE Derived & | operator*= (const QuaternionBase< OtherDerived > &q) | 
| Quaternion< Scalar > | inverse () const | 
| Quaternion< Scalar > | conjugate () const | 
| template<class OtherDerived > | |
| Quaternion< Scalar > | slerp (const Scalar &t, const QuaternionBase< OtherDerived > &other) const | 
| template<class OtherDerived > | |
| bool | isApprox (const QuaternionBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const | 
| EIGEN_STRONG_INLINE Vector3 | _transformVector (const Vector3 &v) const | 
| return the result vector of v through the rotation | |
| template<typename NewScalarType > | |
| internal::cast_return_type < Derived, Quaternion < NewScalarType > >::type | cast () const | 
| template<class MatrixDerived > | |
| Derived & | operator= (const MatrixBase< MatrixDerived > &xpr) | 
| Set *thisfrom the expression xpr:
 | |
| RotationMatrixType | matrix () const | 
| Transform< Scalar, Dim, Isometry > | operator* (const Translation< Scalar, Dim > &t) const | 
| RotationMatrixType | operator* (const UniformScaling< Scalar > &s) const | 
| EIGEN_STRONG_INLINE internal::rotation_base_generic_product_selector < Derived, OtherDerived, OtherDerived::IsVectorAtCompileTime > ::ReturnType | operator* (const EigenBase< OtherDerived > &e) const | 
| Transform< Scalar, Dim, Mode > | operator* (const Transform< Scalar, Dim, Mode, Options > &t) const | 
| Static Public Member Functions | |
| static Quaternion< Scalar > | Identity () | 
| Friends | |
| RotationMatrixType | operator* (const EigenBase< OtherDerived > &l, const Derived &r) | 
| Transform< Scalar, Dim, Affine > | operator* (const DiagonalMatrix< Scalar, Dim > &l, const Derived &r) | 
Detailed Description
template<class Derived>
 class Eigen::QuaternionBase< Derived >
Base class for quaternion expressions
- Template Parameters:
- 
  Derived derived type (CRTP) 
- See also:
- class Quaternion
Definition at line 35 of file Quaternion.h.
Member Typedef Documentation
| typedef AngleAxis<Scalar> AngleAxisType | 
the equivalent angle-axis type
Reimplemented in Quaternion< _Scalar, _Options >.
Definition at line 55 of file Quaternion.h.
the equivalent rotation matrix type
Definition at line 53 of file Quaternion.h.
| typedef Matrix<Scalar,Dim,Dim> RotationMatrixType  [inherited] | 
corresponding linear transformation matrix type
Definition at line 37 of file RotationBase.h.
the scalar type of the coefficients
Reimplemented from RotationBase< Derived, 3 >.
Reimplemented in Quaternion< _Scalar, _Options >, Map< const Quaternion< _Scalar >, _Options >, and Map< Quaternion< _Scalar >, _Options >.
Definition at line 42 of file Quaternion.h.
the type of a 3D vector
Definition at line 51 of file Quaternion.h.
Member Function Documentation
| EIGEN_STRONG_INLINE QuaternionBase< Derived >::Vector3 _transformVector | ( | const Vector3 & | v ) | const | 
return the result vector of v through the rotation
Rotation of a vector by a quaternion.
- Remarks:
- If the quaternion is used to rotate several points (>1) then it is much more efficient to first convert it to a 3x3 Matrix. Comparison of the operation cost for n transformations:- Quaternion2: 30n
- Via a Matrix3: 24 + 15n
 
Definition at line 464 of file Quaternion.h.
| internal::traits< Derived >::Scalar angularDistance | ( | const QuaternionBase< OtherDerived > & | other ) | const | 
- Returns:
- the angle (in radian) between two rotations
- See also:
- dot()
Definition at line 668 of file Quaternion.h.
| internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type cast | ( | ) | const | 
- Returns:
- *thiswith scalar type casted to NewScalarType
Note that if NewScalarType is equal to the current scalar type of *this then this function smartly returns a const reference to *this. 
Definition at line 172 of file Quaternion.h.
| const internal::traits<Derived>::Coefficients& coeffs | ( | ) | const | 
- Returns:
- a read-only vector expression of the coefficients (x,y,z,w)
Reimplemented in Quaternion< _Scalar, _Options >, Map< const Quaternion< _Scalar >, _Options >, and Map< Quaternion< _Scalar >, _Options >.
Definition at line 84 of file Quaternion.h.
| internal::traits<Derived>::Coefficients& coeffs | ( | ) | 
- Returns:
- a vector expression of the coefficients (x,y,z,w)
Reimplemented in Quaternion< _Scalar, _Options >, and Map< Quaternion< _Scalar >, _Options >.
Definition at line 87 of file Quaternion.h.
| Quaternion< typename internal::traits< Derived >::Scalar > conjugate | ( | ) | const | 
- Returns:
- the conjugated quaternion
- 
the conjugate of the *thiswhich is equal to the multiplicative inverse if the quaternion is normalized. The conjugate of a quaternion represents the opposite rotation.
- See also:
- Quaternion2::inverse()
Definition at line 657 of file Quaternion.h.
| Scalar dot | ( | const QuaternionBase< OtherDerived > & | other ) | const | 
- Returns:
- the dot product of *thisand other Geometrically speaking, the dot product of two unit quaternions corresponds to the cosine of half the angle between the two rotations.
- See also:
- angularDistance()
Definition at line 133 of file Quaternion.h.
| static Quaternion<Scalar> Identity | ( | ) |  [static] | 
- Returns:
- a quaternion representing an identity rotation
- See also:
- MatrixBase::Identity()
Definition at line 105 of file Quaternion.h.
| Quaternion< typename internal::traits< Derived >::Scalar > inverse | ( | ) | const | 
- Returns:
- the quaternion describing the inverse rotation
- 
the multiplicative inverse of *thisNote that in most cases, i.e., if you simply want the opposite rotation, and/or the quaternion is normalized, then it is enough to use the conjugate.
- See also:
- QuaternionBase::conjugate()
Reimplemented from RotationBase< Derived, 3 >.
Definition at line 636 of file Quaternion.h.
| bool isApprox | ( | const QuaternionBase< OtherDerived > & | other, | 
| const RealScalar & | prec = NumTraits<Scalar>::dummy_precision() | ||
| ) | const | 
- Returns:
- trueif- *thisis approximately equal to other, within the precision determined by prec.
- See also:
- MatrixBase::isApprox()
Definition at line 160 of file Quaternion.h.
| RotationMatrixType matrix | ( | ) | const  [inherited] | 
- Returns:
- an equivalent rotation matrix This function is added to be conform with the Transform class' naming scheme.
Definition at line 50 of file RotationBase.h.
| Scalar norm | ( | ) | const | 
- Returns:
- the norm of the quaternion's coefficients
Definition at line 119 of file Quaternion.h.
| void normalize | ( | void | ) | 
Normalizes the quaternion *this. 
- See also:
- normalized(), MatrixBase::normalize()
Definition at line 123 of file Quaternion.h.
| Quaternion<Scalar> normalized | ( | ) | const | 
- Returns:
- a normalized copy of *this
- See also:
- normalize(), MatrixBase::normalized()
Definition at line 126 of file Quaternion.h.
| EIGEN_STRONG_INLINE internal::rotation_base_generic_product_selector<Derived,OtherDerived,OtherDerived::IsVectorAtCompileTime>::ReturnType operator* | ( | const EigenBase< OtherDerived > & | e ) | const  [inherited] | 
- Returns:
- the concatenation of the rotation *thiswith a generic expression e e can be:- a DimxDim linear transformation matrix
- a DimxDim diagonal matrix (axis aligned scaling)
- a vector of size Dim
 
Definition at line 71 of file RotationBase.h.
| RotationMatrixType operator* | ( | const UniformScaling< Scalar > & | s ) | const  [inherited] | 
- Returns:
- the concatenation of the rotation *thiswith a uniform scaling s
Definition at line 60 of file RotationBase.h.
| Transform<Scalar,Dim,Mode> operator* | ( | const Transform< Scalar, Dim, Mode, Options > & | t ) | const  [inherited] | 
- Returns:
- the concatenation of the rotation *thiswith a transformation t
Definition at line 89 of file RotationBase.h.
| EIGEN_STRONG_INLINE Quaternion< typename internal::traits< Derived >::Scalar > operator* | ( | const QuaternionBase< OtherDerived > & | other ) | const | 
- Returns:
- the concatenation of two rotations as a quaternion-quaternion product
Definition at line 437 of file Quaternion.h.
| Transform<Scalar,Dim,Isometry> operator* | ( | const Translation< Scalar, Dim > & | t ) | const  [inherited] | 
- Returns:
- the concatenation of the rotation *thiswith a translation t
Definition at line 56 of file RotationBase.h.
| EIGEN_STRONG_INLINE Derived & operator*= | ( | const QuaternionBase< OtherDerived > & | other ) | 
- See also:
- operator*(Quaternion)
Definition at line 449 of file Quaternion.h.
| Derived& operator= | ( | const MatrixBase< MatrixDerived > & | xpr ) | 
Set *this from the expression xpr: 
- if xpr is a 4x1 vector, then xpr is assumed to be a quaternion
- if xpr is a 3x3 matrix, then xpr is assumed to be rotation matrix and xpr is converted to a quaternion.
Definition at line 512 of file Quaternion.h.
| EIGEN_STRONG_INLINE Derived & operator= | ( | const AngleAxisType & | aa ) | 
Set *this from an angle-axis aa and returns a reference to *this. 
Definition at line 494 of file Quaternion.h.
| Derived & setFromTwoVectors | ( | const MatrixBase< Derived1 > & | a, | 
| const MatrixBase< Derived2 > & | b | ||
| ) | 
Sets *this to be a quaternion representing a rotation between the two arbitrary vectors a and b. 
- Returns:
- the quaternion which transform a into b through a rotation
In other words, the built rotation represent a rotation sending the line of direction a to the line of direction b, both lines passing through the origin.
- Returns:
- a reference to *this.
Note that the two input vectors do not have to be normalized, and do not need to have the same norm.
Definition at line 571 of file Quaternion.h.
| QuaternionBase& setIdentity | ( | ) | 
Definition at line 109 of file Quaternion.h.
| Quaternion< typename internal::traits< Derived >::Scalar > slerp | ( | const Scalar & | t, | 
| const QuaternionBase< OtherDerived > & | other | ||
| ) | const | 
- Returns:
- the spherical linear interpolation between the two quaternions *thisand other at the parameter t in [0;1].
This represents an interpolation for a constant motion between *this and other, see also http://en.wikipedia.org/wiki/Slerp. 
Definition at line 687 of file Quaternion.h.
| Scalar squaredNorm | ( | ) | const | 
- Returns:
- the squared norm of the quaternion's coefficients
Definition at line 114 of file Quaternion.h.
| QuaternionBase< Derived >::Matrix3 toRotationMatrix | ( | void | ) | const | 
Convert the quaternion to a 3x3 rotation matrix.
- Returns:
- an equivalent 3x3 rotation matrix
The quaternion is required to be normalized, otherwise the result is undefined.
Reimplemented from RotationBase< Derived, 3 >.
Definition at line 525 of file Quaternion.h.
| const VectorBlock<const Coefficients,3> vec | ( | ) | const | 
- Returns:
- a read-only vector expression of the imaginary part (x,y,z)
Definition at line 78 of file Quaternion.h.
| VectorBlock<Coefficients,3> vec | ( | ) | 
- Returns:
- a vector expression of the imaginary part (x,y,z)
Definition at line 81 of file Quaternion.h.
| Scalar& w | ( | ) | 
- Returns:
- a reference to the wcoefficient
Definition at line 75 of file Quaternion.h.
| Scalar w | ( | ) | const | 
- Returns:
- the wcoefficient
Definition at line 66 of file Quaternion.h.
| Scalar x | ( | ) | const | 
- Returns:
- the xcoefficient
Definition at line 60 of file Quaternion.h.
| Scalar& x | ( | ) | 
- Returns:
- a reference to the xcoefficient
Definition at line 69 of file Quaternion.h.
| Scalar& y | ( | ) | 
- Returns:
- a reference to the ycoefficient
Definition at line 71 of file Quaternion.h.
| Scalar y | ( | ) | const | 
- Returns:
- the ycoefficient
Definition at line 62 of file Quaternion.h.
| Scalar& z | ( | ) | 
- Returns:
- a reference to the zcoefficient
Definition at line 73 of file Quaternion.h.
| Scalar z | ( | ) | const | 
- Returns:
- the zcoefficient
Definition at line 64 of file Quaternion.h.
Friends And Related Function Documentation
| RotationMatrixType operator* | ( | const EigenBase< OtherDerived > & | l, | 
| const Derived & | r | ||
| ) |  [friend, inherited] | 
- Returns:
- the concatenation of a linear transformation l with the rotation r
Definition at line 76 of file RotationBase.h.
| Transform<Scalar,Dim,Affine> operator* | ( | const DiagonalMatrix< Scalar, Dim > & | l, | 
| const Derived & | r | ||
| ) |  [friend, inherited] | 
- Returns:
- the concatenation of a scaling l with the rotation r
Definition at line 80 of file RotationBase.h.
Generated on Tue Jul 12 2022 17:47:05 by
 1.7.2
 1.7.2