MOAB  4.9.3pre
Eigen::Rotation2D< _Scalar > Class Template Reference

Represents a rotation/orientation in a 2 dimensional space. More...

#include <Rotation2D.h>

Inheritance diagram for Eigen::Rotation2D< _Scalar >:
Collaboration diagram for Eigen::Rotation2D< _Scalar >:

List of all members.

Public Types

enum  { Dim = 2 }
typedef _Scalar Scalar
typedef Matrix< Scalar, 2, 1 > Vector2
typedef Matrix< Scalar, 2, 2 > Matrix2

Public Member Functions

 Rotation2D (const Scalar &a)
 Rotation2D ()
template<typename Derived >
 Rotation2D (const MatrixBase< Derived > &m)
Scalar angle () const
Scalarangle ()
Scalar smallestPositiveAngle () const
Scalar smallestAngle () const
Rotation2D inverse () const
Rotation2D operator* (const Rotation2D &other) const
Rotation2Doperator*= (const Rotation2D &other)
Vector2 operator* (const Vector2 &vec) const
template<typename Derived >
Rotation2DfromRotationMatrix (const MatrixBase< Derived > &m)
Matrix2 toRotationMatrix () const
template<typename Derived >
Rotation2Doperator= (const MatrixBase< Derived > &m)
Rotation2D slerp (const Scalar &t, const Rotation2D &other) const
template<typename NewScalarType >
internal::cast_return_type
< Rotation2D, Rotation2D
< NewScalarType > >::type 
cast () const
template<typename OtherScalarType >
 Rotation2D (const Rotation2D< OtherScalarType > &other)
bool isApprox (const Rotation2D &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const

Static Public Member Functions

static Rotation2D Identity ()

Protected Attributes

Scalar m_angle

Private Types

typedef RotationBase
< Rotation2D< _Scalar >, 2 > 
Base

Detailed Description

template<typename _Scalar>
class Eigen::Rotation2D< _Scalar >

Represents a rotation/orientation in a 2 dimensional space.

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

This class is equivalent to a single scalar representing a counter clock wise rotation as a single angle in radian. It provides some additional features such as the automatic conversion from/to a 2x2 rotation matrix. Moreover this class aims to provide a similar interface to Quaternion in order to facilitate the writing of generic algorithms dealing with rotations.

See also:
class Quaternion, class Transform

Definition at line 41 of file Rotation2D.h.


Member Typedef Documentation

template<typename _Scalar>
typedef RotationBase<Rotation2D<_Scalar>,2> Eigen::Rotation2D< _Scalar >::Base [private]

Definition at line 43 of file Rotation2D.h.

template<typename _Scalar>
typedef Matrix<Scalar,2,2> Eigen::Rotation2D< _Scalar >::Matrix2

Definition at line 53 of file Rotation2D.h.

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

the scalar type of the coefficients

Reimplemented from Eigen::RotationBase< Rotation2D< _Scalar >, 2 >.

Definition at line 51 of file Rotation2D.h.

template<typename _Scalar>
typedef Matrix<Scalar,2,1> Eigen::Rotation2D< _Scalar >::Vector2

Definition at line 52 of file Rotation2D.h.


Member Enumeration Documentation

template<typename _Scalar>
anonymous enum
Enumerator:
Dim 

Definition at line 49 of file Rotation2D.h.

{ Dim = 2 };

Constructor & Destructor Documentation

template<typename _Scalar>
Eigen::Rotation2D< _Scalar >::Rotation2D ( const Scalar a) [inline, explicit]

Construct a 2D counter clock wise rotation from the angle a in radian.

Definition at line 62 of file Rotation2D.h.

: m_angle(a) {}
template<typename _Scalar>
Eigen::Rotation2D< _Scalar >::Rotation2D ( ) [inline]

Default constructor wihtout initialization. The represented rotation is undefined.

Definition at line 65 of file Rotation2D.h.

{}
template<typename _Scalar>
template<typename Derived >
Eigen::Rotation2D< _Scalar >::Rotation2D ( const MatrixBase< Derived > &  m) [inline, explicit]

Construct a 2D rotation from a 2x2 rotation matrix mat.

See also:
fromRotationMatrix()

Definition at line 72 of file Rotation2D.h.

  {
    fromRotationMatrix(m.derived());
  }
template<typename _Scalar>
template<typename OtherScalarType >
Eigen::Rotation2D< _Scalar >::Rotation2D ( const Rotation2D< OtherScalarType > &  other) [inline, explicit]

Copy constructor with scalar type conversion

Definition at line 147 of file Rotation2D.h.

  {
    m_angle = Scalar(other.angle());
  }

Member Function Documentation

template<typename _Scalar>
Scalar Eigen::Rotation2D< _Scalar >::angle ( ) const [inline]
Returns:
the rotation angle

Definition at line 78 of file Rotation2D.h.

{ return m_angle; }
template<typename _Scalar>
Scalar& Eigen::Rotation2D< _Scalar >::angle ( ) [inline]
Returns:
a read-write reference to the rotation angle

Definition at line 81 of file Rotation2D.h.

{ return m_angle; }
template<typename _Scalar>
template<typename NewScalarType >
internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type Eigen::Rotation2D< _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 142 of file Rotation2D.h.

  { return typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*this); }
template<typename Scalar >
template<typename Derived >
Rotation2D< Scalar > & Eigen::Rotation2D< Scalar >::fromRotationMatrix ( const MatrixBase< Derived > &  mat)

Set *this from a 2x2 rotation matrix mat. In other words, this function extract the rotation angle from the rotation matrix.

Definition at line 176 of file Rotation2D.h.

{
  using std::atan2;
  EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime==2 && Derived::ColsAtCompileTime==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
  m_angle = atan2(mat.coeff(1,0), mat.coeff(0,0));
  return *this;
}
template<typename _Scalar>
static Rotation2D Eigen::Rotation2D< _Scalar >::Identity ( ) [inline, static]

Definition at line 152 of file Rotation2D.h.

{ return Rotation2D(0); }
template<typename _Scalar>
Rotation2D Eigen::Rotation2D< _Scalar >::inverse ( ) const [inline]
Returns:
the inverse rotation

Reimplemented from Eigen::RotationBase< Rotation2D< _Scalar >, 2 >.

Definition at line 98 of file Rotation2D.h.

{ return Rotation2D(-m_angle); }
template<typename _Scalar>
bool Eigen::Rotation2D< _Scalar >::isApprox ( const Rotation2D< _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 158 of file Rotation2D.h.

  { return internal::isApprox(m_angle,other.m_angle, prec); }
template<typename _Scalar>
Rotation2D Eigen::Rotation2D< _Scalar >::operator* ( const Rotation2D< _Scalar > &  other) const [inline]

Concatenates two rotations

Definition at line 101 of file Rotation2D.h.

  { return Rotation2D(m_angle + other.m_angle); }
template<typename _Scalar>
Vector2 Eigen::Rotation2D< _Scalar >::operator* ( const Vector2 vec) const [inline]

Applies the rotation to a 2D vector

Definition at line 109 of file Rotation2D.h.

  { return toRotationMatrix() * vec; }
template<typename _Scalar>
Rotation2D& Eigen::Rotation2D< _Scalar >::operator*= ( const Rotation2D< _Scalar > &  other) [inline]

Concatenates two rotations

Definition at line 105 of file Rotation2D.h.

  { m_angle += other.m_angle; return *this; }
template<typename _Scalar>
template<typename Derived >
Rotation2D& Eigen::Rotation2D< _Scalar >::operator= ( const MatrixBase< Derived > &  m) [inline]

Set *this from a 2x2 rotation matrix mat. In other words, this function extract the rotation angle from the rotation matrix.

This method is an alias for fromRotationMatrix()

See also:
fromRotationMatrix()

Definition at line 124 of file Rotation2D.h.

  { return fromRotationMatrix(m.derived()); }
template<typename _Scalar>
Rotation2D Eigen::Rotation2D< _Scalar >::slerp ( const Scalar t,
const Rotation2D< _Scalar > &  other 
) const [inline]
Returns:
the spherical interpolation between *this and other using parameter t. It is in fact equivalent to a linear interpolation.

Definition at line 130 of file Rotation2D.h.

  {
    Scalar dist = Rotation2D(other.m_angle-m_angle).smallestAngle();
    return Rotation2D(m_angle + dist*t);
  }
template<typename _Scalar>
Scalar Eigen::Rotation2D< _Scalar >::smallestAngle ( ) const [inline]
Returns:
the rotation angle in [-pi,pi]

Definition at line 90 of file Rotation2D.h.

                                      {
    Scalar tmp = fmod(m_angle,Scalar(2)*EIGEN_PI);
    if(tmp>Scalar(EIGEN_PI))       tmp -= Scalar(2)*Scalar(EIGEN_PI);
    else if(tmp<-Scalar(EIGEN_PI)) tmp += Scalar(2)*Scalar(EIGEN_PI);
    return tmp;
  }
template<typename _Scalar>
Scalar Eigen::Rotation2D< _Scalar >::smallestPositiveAngle ( ) const [inline]
Returns:
the rotation angle in [0,2pi]

Definition at line 84 of file Rotation2D.h.

                                              {
    Scalar tmp = fmod(m_angle,Scalar(2)*EIGEN_PI);
    return tmp<Scalar(0) ? tmp + Scalar(2)*EIGEN_PI : tmp;
  }
template<typename Scalar >
Rotation2D< Scalar >::Matrix2 Eigen::Rotation2D< Scalar >::toRotationMatrix ( void  ) const

Constructs and

Returns:
an equivalent 2x2 rotation matrix.

Reimplemented from Eigen::RotationBase< Rotation2D< _Scalar >, 2 >.

Definition at line 188 of file Rotation2D.h.

{
  using std::sin;
  using std::cos;
  Scalar sinA = sin(m_angle);
  Scalar cosA = cos(m_angle);
  return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
}

Member Data Documentation

template<typename _Scalar>
Scalar Eigen::Rotation2D< _Scalar >::m_angle [protected]

Definition at line 57 of file Rotation2D.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines