Eigen::AngleAxis< Scalar_ > Class Template Reference

Represents a 3D rotation as a rotation angle around an arbitrary 3D axis. More...

#include <AngleAxis.h>

+ Inheritance diagram for Eigen::AngleAxis< Scalar_ >:

Public Types

enum  { Dim = 3 }
 
typedef Scalar_ Scalar
 
typedef Matrix< Scalar, 3, 3 > Matrix3
 
typedef Matrix< Scalar, 3, 1 > Vector3
 
typedef Quaternion< ScalarQuaternionType
 
- Public Types inherited from Eigen::RotationBase< AngleAxis< Scalar_ >, 3 >
enum  
 
typedef internal::traits< AngleAxis< Scalar_ > >::Scalar Scalar
 
typedef Matrix< Scalar, Dim, DimRotationMatrixType
 
typedef Matrix< Scalar, Dim, 1 > VectorType
 

Public Member Functions

EIGEN_DEVICE_FUNC AngleAxis ()
 
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxis (const Scalar &angle, const MatrixBase< Derived > &axis)
 
template<typename QuatDerived >
EIGEN_DEVICE_FUNC AngleAxis (const QuaternionBase< QuatDerived > &q)
 
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxis (const MatrixBase< Derived > &m)
 
EIGEN_DEVICE_FUNC Scalar angle () const
 
EIGEN_DEVICE_FUNC Scalarangle ()
 
EIGEN_DEVICE_FUNC const Vector3axis () const
 
EIGEN_DEVICE_FUNC Vector3axis ()
 
EIGEN_DEVICE_FUNC QuaternionType operator* (const AngleAxis &other) const
 
EIGEN_DEVICE_FUNC QuaternionType operator* (const QuaternionType &other) const
 
EIGEN_DEVICE_FUNC AngleAxis inverse () const
 
template<class QuatDerived >
EIGEN_DEVICE_FUNC AngleAxisoperator= (const QuaternionBase< QuatDerived > &q)
 
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxisoperator= (const MatrixBase< Derived > &m)
 
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxisfromRotationMatrix (const MatrixBase< Derived > &m)
 
EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix (void) const
 
template<typename NewScalarType >
EIGEN_DEVICE_FUNC internal::cast_return_type< AngleAxis, AngleAxis< NewScalarType > >::type cast () const
 
template<typename OtherScalarType >
EIGEN_DEVICE_FUNC AngleAxis (const AngleAxis< OtherScalarType > &other)
 
EIGEN_DEVICE_FUNC bool isApprox (const AngleAxis &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
 
template<typename QuatDerived >
EIGEN_DEVICE_FUNC AngleAxis< Scalar > & operator= (const QuaternionBase< QuatDerived > &q)
 
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxis< Scalar > & operator= (const MatrixBase< Derived > &mat)
 
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxis< Scalar > & fromRotationMatrix (const MatrixBase< Derived > &mat)
 Sets *this from a 3x3 rotation matrix. More...
 
- Public Member Functions inherited from Eigen::RotationBase< AngleAxis< Scalar_ >, 3 >
EIGEN_DEVICE_FUNC const AngleAxis< Scalar_ > & derived () const
 
EIGEN_DEVICE_FUNC AngleAxis< Scalar_ > & derived ()
 
EIGEN_DEVICE_FUNC RotationMatrixType toRotationMatrix () const
 
EIGEN_DEVICE_FUNC RotationMatrixType matrix () const
 
EIGEN_DEVICE_FUNC AngleAxis< Scalar_ > inverse () const
 
EIGEN_DEVICE_FUNC Transform< Scalar, Dim, Isometry > operator* (const Translation< Scalar, Dim > &t) const
 
EIGEN_DEVICE_FUNC RotationMatrixType operator* (const UniformScaling< Scalar > &s) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::rotation_base_generic_product_selector< AngleAxis< Scalar_ >, OtherDerived, OtherDerived::IsVectorAtCompileTime >::ReturnType operator* (const EigenBase< OtherDerived > &e) const
 
EIGEN_DEVICE_FUNC Transform< Scalar, Dim, Mode > operator* (const Transform< Scalar, Dim, Mode, Options > &t) const
 
EIGEN_DEVICE_FUNC VectorType _transformVector (const OtherVectorType &v) const
 

Static Public Member Functions

static EIGEN_DEVICE_FUNC const AngleAxis Identity ()
 

Protected Attributes

Vector3 m_axis
 
Scalar m_angle
 

Private Types

typedef RotationBase< AngleAxis< Scalar_ >, 3 > Base
 

Friends

EIGEN_DEVICE_FUNC QuaternionType operator* (const QuaternionType &a, const AngleAxis &b)
 

Detailed Description

template<typename Scalar_>
class Eigen::AngleAxis< Scalar_ >

Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.

\geometry_module

Parameters
Scalar_the scalar type, i.e., the type of the coefficients.
Warning
When setting up an AngleAxis object, the axis vector must be normalized.

The following two typedefs are provided for convenience:

  • AngleAxisf for float
  • AngleAxisd for double

Combined with MatrixBase::Unit{X,Y,Z}, AngleAxis can be used to easily mimic Euler-angles. Here is an example:

Matrix3f m;
m = AngleAxisf(0.25 * M_PI, Vector3f::UnitX()) * AngleAxisf(0.5 * M_PI, Vector3f::UnitY()) *
AngleAxisf(0.33 * M_PI, Vector3f::UnitZ());
cout << m << endl << "is unitary: " << m.isUnitary() << endl;
AngleAxis< float > AngleAxisf
Definition: AngleAxis.h:165
int * m
Definition: level2_cplx_impl.h:294
#define M_PI
Definition: main.h:121

Output:

Note
This class is not aimed to be used to store a rotation transformation, but rather to make easier the creation of other rotation (Quaternion, rotation Matrix) and transformation objects.
See also
class Quaternion, class Transform, MatrixBase::UnitX()

Member Typedef Documentation

◆ Base

template<typename Scalar_ >
typedef RotationBase<AngleAxis<Scalar_>, 3> Eigen::AngleAxis< Scalar_ >::Base
private

◆ Matrix3

template<typename Scalar_ >
typedef Matrix<Scalar, 3, 3> Eigen::AngleAxis< Scalar_ >::Matrix3

◆ QuaternionType

template<typename Scalar_ >
typedef Quaternion<Scalar> Eigen::AngleAxis< Scalar_ >::QuaternionType

◆ Scalar

template<typename Scalar_ >
typedef Scalar_ Eigen::AngleAxis< Scalar_ >::Scalar

the scalar type of the coefficients

◆ Vector3

template<typename Scalar_ >
typedef Matrix<Scalar, 3, 1> Eigen::AngleAxis< Scalar_ >::Vector3

Member Enumeration Documentation

◆ anonymous enum

template<typename Scalar_ >
anonymous enum
Enumerator
Dim 
58 { Dim = 3 };
@ Dim
Definition: AngleAxis.h:58

Constructor & Destructor Documentation

◆ AngleAxis() [1/5]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Eigen::AngleAxis< Scalar_ >::AngleAxis ( )
inline

Default constructor without initialization.

71 {}

Referenced by Eigen::AngleAxis< Scalar_ >::Identity(), and Eigen::AngleAxis< Scalar_ >::inverse().

◆ AngleAxis() [2/5]

template<typename Scalar_ >
template<typename Derived >
EIGEN_DEVICE_FUNC Eigen::AngleAxis< Scalar_ >::AngleAxis ( const Scalar angle,
const MatrixBase< Derived > &  axis 
)
inline

Constructs and initialize the angle-axis rotation from an angle in radian and an axis which must be normalized.

Warning
If the axis vector is not normalized, then the angle-axis object represents an invalid rotation.
79  : m_axis(axis), m_angle(angle) {}
Vector3 m_axis
Definition: AngleAxis.h:66
EIGEN_DEVICE_FUNC const Vector3 & axis() const
Definition: AngleAxis.h:99
EIGEN_DEVICE_FUNC Scalar angle() const
Definition: AngleAxis.h:94
Scalar m_angle
Definition: AngleAxis.h:67

◆ AngleAxis() [3/5]

template<typename Scalar_ >
template<typename QuatDerived >
EIGEN_DEVICE_FUNC Eigen::AngleAxis< Scalar_ >::AngleAxis ( const QuaternionBase< QuatDerived > &  q)
inlineexplicit

Constructs and initialize the angle-axis rotation from a quaternion q. This function implicitly normalizes the quaternion q.

84  {
85  *this = q;
86  }
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:2019

References Eigen::numext::q.

◆ AngleAxis() [4/5]

template<typename Scalar_ >
template<typename Derived >
EIGEN_DEVICE_FUNC Eigen::AngleAxis< Scalar_ >::AngleAxis ( const MatrixBase< Derived > &  m)
inlineexplicit

Constructs and initialize the angle-axis rotation from a 3x3 rotation matrix.

89  {
90  *this = m;
91  }

References m.

◆ AngleAxis() [5/5]

template<typename Scalar_ >
template<typename OtherScalarType >
EIGEN_DEVICE_FUNC Eigen::AngleAxis< Scalar_ >::AngleAxis ( const AngleAxis< OtherScalarType > &  other)
inlineexplicit

Copy constructor with scalar type conversion

146  {
147  m_axis = other.axis().template cast<Scalar>();
148  m_angle = Scalar(other.angle());
149  }
Scalar_ Scalar
Definition: AngleAxis.h:60

References Eigen::AngleAxis< Scalar_ >::angle(), Eigen::AngleAxis< Scalar_ >::axis(), Eigen::AngleAxis< Scalar_ >::m_angle, and Eigen::AngleAxis< Scalar_ >::m_axis.

Member Function Documentation

◆ angle() [1/2]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Scalar& Eigen::AngleAxis< Scalar_ >::angle ( )
inline
Returns
a read-write reference to the stored angle in radian
96 { return m_angle; }

References Eigen::AngleAxis< Scalar_ >::m_angle.

◆ angle() [2/2]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Scalar Eigen::AngleAxis< Scalar_ >::angle ( ) const
inline
Returns
the value of the rotation angle in radian
94 { return m_angle; }

References Eigen::AngleAxis< Scalar_ >::m_angle.

Referenced by Eigen::AngleAxis< Scalar_ >::AngleAxis(), and Eigen::QuaternionBase< Derived >::operator=().

◆ axis() [1/2]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Vector3& Eigen::AngleAxis< Scalar_ >::axis ( )
inline
Returns
a read-write reference to the stored rotation axis.
Warning
The rotation axis must remain a unit vector.
104 { return m_axis; }

References Eigen::AngleAxis< Scalar_ >::m_axis.

◆ axis() [2/2]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC const Vector3& Eigen::AngleAxis< Scalar_ >::axis ( ) const
inline

◆ cast()

template<typename Scalar_ >
template<typename NewScalarType >
EIGEN_DEVICE_FUNC internal::cast_return_type<AngleAxis, AngleAxis<NewScalarType> >::type Eigen::AngleAxis< Scalar_ >::cast ( ) const
inline
Returns
*this with 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.

140  {
141  return typename internal::cast_return_type<AngleAxis, AngleAxis<NewScalarType> >::type(*this);
142  }
type
Definition: compute_granudrum_aor.py:141

References compute_granudrum_aor::type.

◆ fromRotationMatrix() [1/2]

template<typename Scalar_ >
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxis& Eigen::AngleAxis< Scalar_ >::fromRotationMatrix ( const MatrixBase< Derived > &  m)

◆ fromRotationMatrix() [2/2]

template<typename Scalar_ >
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxis<Scalar>& Eigen::AngleAxis< Scalar_ >::fromRotationMatrix ( const MatrixBase< Derived > &  mat)

Sets *this from a 3x3 rotation matrix.

210  {
211  return *this = QuaternionType(mat);
212 }
Quaternion< Scalar > QuaternionType
Definition: AngleAxis.h:63

◆ Identity()

template<typename Scalar_ >
static EIGEN_DEVICE_FUNC const AngleAxis Eigen::AngleAxis< Scalar_ >::Identity ( )
inlinestatic
151 { return AngleAxis(Scalar(0), Vector3::UnitX()); }
EIGEN_DEVICE_FUNC AngleAxis()
Definition: AngleAxis.h:71

References Eigen::AngleAxis< Scalar_ >::AngleAxis().

◆ inverse()

template<typename Scalar_ >
EIGEN_DEVICE_FUNC AngleAxis Eigen::AngleAxis< Scalar_ >::inverse ( ) const
inline
Returns
the inverse rotation, i.e., an angle-axis with opposite rotation angle
122 { return AngleAxis(-m_angle, m_axis); }

References Eigen::AngleAxis< Scalar_ >::AngleAxis(), Eigen::AngleAxis< Scalar_ >::m_angle, and Eigen::AngleAxis< Scalar_ >::m_axis.

◆ isApprox()

template<typename Scalar_ >
EIGEN_DEVICE_FUNC bool Eigen::AngleAxis< Scalar_ >::isApprox ( const AngleAxis< Scalar_ > &  other,
const typename NumTraits< Scalar >::Real prec = NumTraits<Scalar>::dummy_precision() 
) const
inline
Returns
true if *this is approximately equal to other, within the precision determined by prec.
See also
MatrixBase::isApprox()
158  {
159  return m_axis.isApprox(other.m_axis, prec) && internal::isApprox(m_angle, other.m_angle, prec);
160  }
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1923

References Eigen::internal::isApprox(), Eigen::AngleAxis< Scalar_ >::m_angle, and Eigen::AngleAxis< Scalar_ >::m_axis.

◆ operator*() [1/2]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC QuaternionType Eigen::AngleAxis< Scalar_ >::operator* ( const AngleAxis< Scalar_ > &  other) const
inline

Concatenates two rotations

107  {
108  return QuaternionType(*this) * QuaternionType(other);
109  }

◆ operator*() [2/2]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC QuaternionType Eigen::AngleAxis< Scalar_ >::operator* ( const QuaternionType other) const
inline

Concatenates two rotations

112  {
113  return QuaternionType(*this) * other;
114  }

◆ operator=() [1/4]

template<typename Scalar_ >
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxis& Eigen::AngleAxis< Scalar_ >::operator= ( const MatrixBase< Derived > &  m)

◆ operator=() [2/4]

template<typename Scalar_ >
template<typename Derived >
EIGEN_DEVICE_FUNC AngleAxis<Scalar>& Eigen::AngleAxis< Scalar_ >::operator= ( const MatrixBase< Derived > &  mat)

Set *this from a 3x3 rotation matrix mat.

199  {
200  // Since a direct conversion would not be really faster,
201  // let's use the robust Quaternion implementation:
202  return *this = QuaternionType(mat);
203 }

◆ operator=() [3/4]

template<typename Scalar_ >
template<class QuatDerived >
EIGEN_DEVICE_FUNC AngleAxis& Eigen::AngleAxis< Scalar_ >::operator= ( const QuaternionBase< QuatDerived > &  q)

◆ operator=() [4/4]

template<typename Scalar_ >
template<typename QuatDerived >
EIGEN_DEVICE_FUNC AngleAxis<Scalar>& Eigen::AngleAxis< Scalar_ >::operator= ( const QuaternionBase< QuatDerived > &  q)

Set *this from a unit quaternion.

The resulting axis is normalized, and the computed angle is in the [0,pi] range.

This function implicitly normalizes the quaternion q.

178  {
181  Scalar n = q.vec().norm();
182  if (n < NumTraits<Scalar>::epsilon()) n = q.vec().stableNorm();
183 
184  if (n != Scalar(0)) {
185  m_angle = Scalar(2) * atan2(n, abs(q.w()));
186  if (q.w() < Scalar(0)) n = -n;
187  m_axis = q.vec() / n;
188  } else {
189  m_angle = Scalar(0);
190  m_axis << Scalar(1), Scalar(0), Scalar(0);
191  }
192  return *this;
193 }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
#define EIGEN_USING_STD(FUNC)
Definition: Macros.h:1090
SCALAR Scalar
Definition: bench_gemm.cpp:45
AutoDiffScalar< Matrix< typename internal::traits< internal::remove_all_t< DerTypeA > >::Scalar, Dynamic, 1 > > atan2(const AutoDiffScalar< DerTypeA > &a, const AutoDiffScalar< DerTypeB > &b)
Definition: AutoDiffScalar.h:558
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43

References abs(), Eigen::atan2(), EIGEN_USING_STD, n, and Eigen::numext::q.

◆ toRotationMatrix()

template<typename Scalar >
AngleAxis< Scalar >::Matrix3 EIGEN_DEVICE_FUNC Eigen::AngleAxis< Scalar >::toRotationMatrix ( void  ) const

Constructs and

Returns
an equivalent 3x3 rotation matrix.
217  {
220  Matrix3 res;
221  Vector3 sin_axis = sin(m_angle) * m_axis;
222  Scalar c = cos(m_angle);
223  Vector3 cos1_axis = (Scalar(1) - c) * m_axis;
224 
225  Scalar tmp;
226  tmp = cos1_axis.x() * m_axis.y();
227  res.coeffRef(0, 1) = tmp - sin_axis.z();
228  res.coeffRef(1, 0) = tmp + sin_axis.z();
229 
230  tmp = cos1_axis.x() * m_axis.z();
231  res.coeffRef(0, 2) = tmp + sin_axis.y();
232  res.coeffRef(2, 0) = tmp - sin_axis.y();
233 
234  tmp = cos1_axis.y() * m_axis.z();
235  res.coeffRef(1, 2) = tmp - sin_axis.x();
236  res.coeffRef(2, 1) = tmp + sin_axis.x();
237 
238  res.diagonal() = (cos1_axis.cwiseProduct(m_axis)).array() + c;
239 
240  return res;
241 }
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
Matrix< Scalar, 3, 3 > Matrix3
Definition: AngleAxis.h:61
Matrix< Scalar, 3, 1 > Vector3
Definition: AngleAxis.h:62
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
std::array< T, N > array
Definition: EmulateArray.h:231
int c
Definition: calibrate.py:100

References calibrate::c, cos(), EIGEN_USING_STD, res, sin(), and tmp.

Referenced by rotate3DZAxisIntegral().

Friends And Related Function Documentation

◆ operator*

template<typename Scalar_ >
EIGEN_DEVICE_FUNC QuaternionType operator* ( const QuaternionType a,
const AngleAxis< Scalar_ > &  b 
)
friend

Concatenates two rotations

117  {
118  return a * QuaternionType(b);
119  }
Scalar * b
Definition: benchVecAdd.cpp:17
const Scalar * a
Definition: level2_cplx_impl.h:32

Member Data Documentation

◆ m_angle

◆ m_axis


The documentation for this class was generated from the following files: