Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends
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 >:
+ Collaboration diagram for Eigen::AngleAxis< _Scalar >:

Public Types

enum  { Dim = 3 }
 
enum  { Dim = 3 }
 
typedef _Scalar Scalar
 
typedef Matrix< Scalar, 3, 3 > Matrix3
 
typedef Matrix< Scalar, 3, 1 > Vector3
 
typedef Quaternion< ScalarQuaternionType
 
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  
 
enum  
 
typedef ei_traits< AngleAxis< _Scalar > >::Scalar Scalar
 
typedef internal::traits< AngleAxis< _Scalar > >::Scalar Scalar
 
typedef Matrix< Scalar, Dim, Dim > RotationMatrixType
 
typedef Matrix< Scalar, Dim, Dim > RotationMatrixType
 
typedef Matrix< Scalar, Dim, 1 > VectorType
 

Public Member Functions

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

Static Public Member Functions

static const AngleAxis Identity ()
 

Protected Attributes

Vector3 m_axis
 
Scalar m_angle
 

Friends

QuaternionType operator* (const QuaternionType &a, const AngleAxis &b)
 
Matrix3 operator* (const Matrix3 &a, const AngleAxis &b)
 
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.

Parameters
_Scalarthe scalar type, i.e., the type of the coefficients.

The following two typedefs are provided for convenience:

AngleAxisForEuler How to define a rotation from Euler-angles

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

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()
Parameters
_Scalarthe 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:

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

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()

Definition at line 235 of file ForwardDeclarations.h.

Member Typedef Documentation

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

the scalar type of the coefficients

Definition at line 56 of file AngleAxis.h.

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

the scalar type of the coefficients

Definition at line 59 of file AngleAxis.h.

Constructor & Destructor Documentation

template<typename _Scalar>
Eigen::AngleAxis< _Scalar >::AngleAxis ( )
inline

Default constructor without initialization.

Definition at line 69 of file AngleAxis.h.

69 {}
template<typename _Scalar>
template<typename Derived >
Eigen::AngleAxis< _Scalar >::AngleAxis ( 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.

Definition at line 73 of file AngleAxis.h.

73 : m_axis(axis), m_angle(angle) {}
template<typename _Scalar>
Eigen::AngleAxis< _Scalar >::AngleAxis ( const QuaternionType q)
inline

Constructs and initialize the angle-axis rotation from a quaternion q.

Definition at line 75 of file AngleAxis.h.

75 { *this = q; }
template<typename _Scalar>
template<typename Derived >
Eigen::AngleAxis< _Scalar >::AngleAxis ( const MatrixBase< Derived > &  m)
inlineexplicit

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

Definition at line 78 of file AngleAxis.h.

78 { *this = m; }
template<typename _Scalar>
template<typename OtherScalarType >
Eigen::AngleAxis< _Scalar >::AngleAxis ( const AngleAxis< OtherScalarType > &  other)
inlineexplicit

Copy constructor with scalar type conversion

Definition at line 133 of file AngleAxis.h.

134  {
135  m_axis = other.axis().template cast<Scalar>();
136  m_angle = Scalar(other.angle());
137  }
_Scalar Scalar
Definition: AngleAxis.h:56
template<typename _Scalar>
Eigen::AngleAxis< _Scalar >::AngleAxis ( )
inline

Default constructor without initialization.

Definition at line 72 of file AngleAxis.h.

72 {}
template<typename _Scalar>
template<typename Derived >
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.

Definition at line 79 of file AngleAxis.h.

79 : m_axis(axis), m_angle(angle) {}
template<typename _Scalar>
template<typename QuatDerived >
Eigen::AngleAxis< _Scalar >::AngleAxis ( const QuaternionBase< QuatDerived > &  q)
inlineexplicit

Constructs and initialize the angle-axis rotation from a quaternion q.

Definition at line 81 of file AngleAxis.h.

81 { *this = q; }
template<typename _Scalar>
template<typename Derived >
Eigen::AngleAxis< _Scalar >::AngleAxis ( const MatrixBase< Derived > &  m)
inlineexplicit

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

Definition at line 84 of file AngleAxis.h.

84 { *this = m; }
template<typename _Scalar>
template<typename OtherScalarType >
Eigen::AngleAxis< _Scalar >::AngleAxis ( const AngleAxis< OtherScalarType > &  other)
inlineexplicit

Copy constructor with scalar type conversion

Definition at line 128 of file AngleAxis.h.

129  {
130  m_axis = other.axis().template cast<Scalar>();
131  m_angle = Scalar(other.angle());
132  }
_Scalar Scalar
Definition: AngleAxis.h:56

Member Function Documentation

template<typename _Scalar>
template<typename NewScalarType >
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.

Definition at line 123 of file AngleAxis.h.

124  { return typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type(*this); }
template<typename _Scalar>
template<typename NewScalarType >
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.

Definition at line 128 of file AngleAxis.h.

129  { return typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type(*this); }
template<typename _Scalar>
AngleAxis Eigen::AngleAxis< _Scalar >::inverse ( void  ) const
inline
Returns
the inverse rotation, i.e., an angle-axis with opposite rotation angle

Definition at line 105 of file AngleAxis.h.

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

Definition at line 111 of file AngleAxis.h.

112  { return AngleAxis(-m_angle, m_axis); }
template<typename _Scalar>
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()

Definition at line 140 of file AngleAxis.h.

141  { return m_axis.isApprox(other.m_axis, prec) && internal::isApprox(m_angle,other.m_angle, prec); }
template<typename _Scalar>
bool Eigen::AngleAxis< _Scalar >::isApprox ( const AngleAxis< _Scalar > &  other,
typename NumTraits< Scalar >::Real  prec = precision<Scalar>() 
) const
inline
Returns
true if *this is approximately equal to other, within the precision determined by prec.
See also
MatrixBase::isApprox()

Definition at line 143 of file AngleAxis.h.

144  { return m_axis.isApprox(other.m_axis, prec) && ei_isApprox(m_angle,other.m_angle, prec); }
template<typename _Scalar>
QuaternionType Eigen::AngleAxis< _Scalar >::operator* ( const AngleAxis< _Scalar > &  other) const
inline

Concatenates two rotations

Definition at line 87 of file AngleAxis.h.

88  { return QuaternionType(*this) * QuaternionType(other); }
template<typename _Scalar>
QuaternionType Eigen::AngleAxis< _Scalar >::operator* ( const QuaternionType other) const
inline

Concatenates two rotations

Definition at line 91 of file AngleAxis.h.

92  { return QuaternionType(*this) * other; }
template<typename _Scalar>
QuaternionType Eigen::AngleAxis< _Scalar >::operator* ( const AngleAxis< _Scalar > &  other) const
inline

Concatenates two rotations

Definition at line 93 of file AngleAxis.h.

94  { return QuaternionType(*this) * QuaternionType(other); }
template<typename _Scalar>
QuaternionType Eigen::AngleAxis< _Scalar >::operator* ( const QuaternionType other) const
inline

Concatenates two rotations

Definition at line 97 of file AngleAxis.h.

98  { return QuaternionType(*this) * other; }
template<typename _Scalar>
Matrix3 Eigen::AngleAxis< _Scalar >::operator* ( const Matrix3 other) const
inline

Concatenates two rotations

Definition at line 99 of file AngleAxis.h.

100  { return toRotationMatrix() * other; }
Matrix3 toRotationMatrix(void) const
Definition: AngleAxis.h:189
template<typename _Scalar>
Vector3 Eigen::AngleAxis< _Scalar >::operator* ( const Vector3 other) const
inline

Applies rotation to vector

Definition at line 107 of file AngleAxis.h.

108  { return toRotationMatrix() * other; }
Matrix3 toRotationMatrix(void) const
Definition: AngleAxis.h:189
template<typename Scalar >
AngleAxis< Scalar > & Eigen::AngleAxis< Scalar >::operator= ( const QuaternionType q)

Set *this from a quaternion. The axis is normalized.

Definition at line 158 of file AngleAxis.h.

159 {
160  Scalar n2 = q.vec().squaredNorm();
161  if (n2 < precision<Scalar>()*precision<Scalar>())
162  {
163  m_angle = 0;
164  m_axis << 1, 0, 0;
165  }
166  else
167  {
168  m_angle = 2*std::acos(q.w());
169  m_axis = q.vec() / ei_sqrt(n2);
170  }
171  return *this;
172 }
_Scalar Scalar
Definition: AngleAxis.h:56
template<typename _Scalar>
template<typename QuatDerived >
AngleAxis<Scalar>& Eigen::AngleAxis< _Scalar >::operator= ( const QuaternionBase< QuatDerived > &  q)

Set *this from a unit quaternion. The axis is normalized.

Warning
As any other method dealing with quaternion, if the input quaternion is not normalized then the result is undefined.

Definition at line 159 of file AngleAxis.h.

160 {
161  using std::acos;
162  using std::min;
163  using std::max;
164  using std::sqrt;
165  Scalar n2 = q.vec().squaredNorm();
166  if (n2 < NumTraits<Scalar>::dummy_precision()*NumTraits<Scalar>::dummy_precision())
167  {
168  m_angle = 0;
169  m_axis << 1, 0, 0;
170  }
171  else
172  {
173  m_angle = Scalar(2)*acos((min)((max)(Scalar(-1),q.w()),Scalar(1)));
174  m_axis = q.vec() / sqrt(n2);
175  }
176  return *this;
177 }
_Scalar Scalar
Definition: AngleAxis.h:56
template<typename Scalar >
template<typename Derived >
AngleAxis< Scalar > & Eigen::AngleAxis< Scalar >::operator= ( const MatrixBase< Derived > &  mat)

Set *this from a 3x3 rotation matrix mat.

Definition at line 178 of file AngleAxis.h.

179 {
180  // Since a direct conversion would not be really faster,
181  // let's use the robust Quaternion implementation:
182  return *this = QuaternionType(mat);
183 }
template<typename Scalar >
AngleAxis< Scalar >::Matrix3 Eigen::AngleAxis< Scalar >::toRotationMatrix ( void  ) const

Constructs and

Returns
an equivalent 3x3 rotation matrix.

Definition at line 189 of file AngleAxis.h.

190 {
191  Matrix3 res;
192  Vector3 sin_axis = ei_sin(m_angle) * m_axis;
193  Scalar c = ei_cos(m_angle);
194  Vector3 cos1_axis = (Scalar(1)-c) * m_axis;
195 
196  Scalar tmp;
197  tmp = cos1_axis.x() * m_axis.y();
198  res.coeffRef(0,1) = tmp - sin_axis.z();
199  res.coeffRef(1,0) = tmp + sin_axis.z();
200 
201  tmp = cos1_axis.x() * m_axis.z();
202  res.coeffRef(0,2) = tmp + sin_axis.y();
203  res.coeffRef(2,0) = tmp - sin_axis.y();
204 
205  tmp = cos1_axis.y() * m_axis.z();
206  res.coeffRef(1,2) = tmp - sin_axis.x();
207  res.coeffRef(2,1) = tmp + sin_axis.x();
208 
209  res.diagonal() = (cos1_axis.cwise() * m_axis).cwise() + c;
210 
211  return res;
212 }
_Scalar Scalar
Definition: AngleAxis.h:56

Friends And Related Function Documentation

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

Concatenates two rotations

Definition at line 95 of file AngleAxis.h.

96  { return a * QuaternionType(b); }
template<typename _Scalar>
QuaternionType operator* ( const QuaternionType a,
const AngleAxis< _Scalar > &  b 
)
friend

Concatenates two rotations

Definition at line 101 of file AngleAxis.h.

102  { return a * QuaternionType(b); }
template<typename _Scalar>
Matrix3 operator* ( const Matrix3 a,
const AngleAxis< _Scalar > &  b 
)
friend

Concatenates two rotations

Definition at line 103 of file AngleAxis.h.

104  { return a * b.toRotationMatrix(); }

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