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_ >:

Public Types

enum  { Dim = 2 }
 
typedef Scalar_ Scalar
 
typedef Matrix< Scalar, 2, 1 > Vector2
 
typedef Matrix< Scalar, 2, 2 > Matrix2
 
- Public Types inherited from Eigen::RotationBase< Rotation2D< Scalar_ >, 2 >
enum  
 
typedef internal::traits< Rotation2D< Scalar_ > >::Scalar Scalar
 
typedef Matrix< Scalar, Dim, DimRotationMatrixType
 
typedef Matrix< Scalar, Dim, 1 > VectorType
 

Public Member Functions

EIGEN_DEVICE_FUNC Rotation2D (const Scalar &a)
 
EIGEN_DEVICE_FUNC Rotation2D ()
 
template<typename Derived >
EIGEN_DEVICE_FUNC Rotation2D (const MatrixBase< Derived > &m)
 
EIGEN_DEVICE_FUNC Scalar angle () const
 
EIGEN_DEVICE_FUNC Scalarangle ()
 
EIGEN_DEVICE_FUNC Scalar smallestPositiveAngle () const
 
EIGEN_DEVICE_FUNC Scalar smallestAngle () const
 
EIGEN_DEVICE_FUNC Rotation2D inverse () const
 
EIGEN_DEVICE_FUNC Rotation2D operator* (const Rotation2D &other) const
 
EIGEN_DEVICE_FUNC Rotation2Doperator*= (const Rotation2D &other)
 
EIGEN_DEVICE_FUNC Vector2 operator* (const Vector2 &vec) const
 
template<typename Derived >
EIGEN_DEVICE_FUNC Rotation2DfromRotationMatrix (const MatrixBase< Derived > &m)
 
EIGEN_DEVICE_FUNC Matrix2 toRotationMatrix () const
 
template<typename Derived >
EIGEN_DEVICE_FUNC Rotation2Doperator= (const MatrixBase< Derived > &m)
 
EIGEN_DEVICE_FUNC Rotation2D slerp (const Scalar &t, const Rotation2D &other) const
 
template<typename NewScalarType >
EIGEN_DEVICE_FUNC internal::cast_return_type< Rotation2D, Rotation2D< NewScalarType > >::type cast () const
 
template<typename OtherScalarType >
EIGEN_DEVICE_FUNC Rotation2D (const Rotation2D< OtherScalarType > &other)
 
EIGEN_DEVICE_FUNC bool isApprox (const Rotation2D &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
 
template<typename Derived >
EIGEN_DEVICE_FUNC Rotation2D< Scalar > & fromRotationMatrix (const MatrixBase< Derived > &mat)
 
- Public Member Functions inherited from Eigen::RotationBase< Rotation2D< Scalar_ >, 2 >
EIGEN_DEVICE_FUNC const Rotation2D< Scalar_ > & derived () const
 
EIGEN_DEVICE_FUNC Rotation2D< Scalar_ > & derived ()
 
EIGEN_DEVICE_FUNC RotationMatrixType toRotationMatrix () const
 
EIGEN_DEVICE_FUNC RotationMatrixType matrix () const
 
EIGEN_DEVICE_FUNC Rotation2D< 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< Rotation2D< 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 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.

\geometry_module

Template Parameters
Scalar_the 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

Member Typedef Documentation

◆ Base

template<typename Scalar_ >
typedef RotationBase<Rotation2D<Scalar_>, 2> Eigen::Rotation2D< Scalar_ >::Base
private

◆ Matrix2

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

◆ Scalar

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

the scalar type of the coefficients

◆ Vector2

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

Member Enumeration Documentation

◆ anonymous enum

template<typename Scalar_ >
anonymous enum
Enumerator
Dim 
50 { Dim = 2 };
@ Dim
Definition: Rotation2D.h:50

Constructor & Destructor Documentation

◆ Rotation2D() [1/4]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Eigen::Rotation2D< Scalar_ >::Rotation2D ( const Scalar a)
inlineexplicit

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

61 : m_angle(a) {}
Scalar m_angle
Definition: Rotation2D.h:57
const Scalar * a
Definition: level2_cplx_impl.h:32

◆ Rotation2D() [2/4]

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

Default constructor without initialization. The represented rotation is undefined.

64 {}

Referenced by Eigen::Rotation2D< Scalar_ >::Identity(), Eigen::Rotation2D< Scalar_ >::inverse(), Eigen::Rotation2D< Scalar_ >::operator*(), and Eigen::Rotation2D< Scalar_ >::slerp().

◆ Rotation2D() [3/4]

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

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

See also
fromRotationMatrix()
71  {
72  fromRotationMatrix(m.derived());
73  }
EIGEN_DEVICE_FUNC Rotation2D & fromRotationMatrix(const MatrixBase< Derived > &m)
int * m
Definition: level2_cplx_impl.h:294

References Eigen::Rotation2D< Scalar_ >::fromRotationMatrix(), and m.

◆ Rotation2D() [4/4]

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

Copy constructor with scalar type conversion

151  {
152  m_angle = Scalar(other.angle());
153  }
Scalar_ Scalar
Definition: Rotation2D.h:52

References Eigen::Rotation2D< Scalar_ >::angle(), and Eigen::Rotation2D< Scalar_ >::m_angle.

Member Function Documentation

◆ angle() [1/2]

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

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

◆ angle() [2/2]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Scalar Eigen::Rotation2D< Scalar_ >::angle ( ) const
inline
Returns
the rotation angle
76 { return m_angle; }

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

Referenced by Eigen::Rotation2D< Scalar_ >::Rotation2D(), and transformations().

◆ cast()

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

145  {
146  return typename internal::cast_return_type<Rotation2D, Rotation2D<NewScalarType> >::type(*this);
147  }
type
Definition: compute_granudrum_aor.py:141

References compute_granudrum_aor::type.

◆ fromRotationMatrix() [1/2]

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

◆ fromRotationMatrix() [2/2]

template<typename Scalar_ >
template<typename Derived >
EIGEN_DEVICE_FUNC 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.

180  {
182  EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 2 && Derived::ColsAtCompileTime == 2,
183  YOU_MADE_A_PROGRAMMING_MISTAKE)
184  m_angle = atan2(mat.coeff(1, 0), mat.coeff(0, 0));
185  return *this;
186 }
#define EIGEN_USING_STD(FUNC)
Definition: Macros.h:1090
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
Scalar coeff(Index row, Index col) const
Definition: SparseMatrix.h:211
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

References Eigen::atan2(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::coeff(), EIGEN_STATIC_ASSERT, and EIGEN_USING_STD.

◆ Identity()

template<typename Scalar_ >
static EIGEN_DEVICE_FUNC Rotation2D Eigen::Rotation2D< Scalar_ >::Identity ( )
inlinestatic
155 { return Rotation2D(0); }
EIGEN_DEVICE_FUNC Rotation2D()
Definition: Rotation2D.h:64

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

◆ inverse()

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Rotation2D Eigen::Rotation2D< Scalar_ >::inverse ( ) const
inline
Returns
the inverse rotation
98 { return Rotation2D(-m_angle); }

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

◆ isApprox()

template<typename Scalar_ >
EIGEN_DEVICE_FUNC 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()
162  {
163  return internal::isApprox(m_angle, other.m_angle, prec);
164  }
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(), and Eigen::Rotation2D< Scalar_ >::m_angle.

◆ operator*() [1/2]

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

Concatenates two rotations

101  {
102  return Rotation2D(m_angle + other.m_angle);
103  }

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

◆ operator*() [2/2]

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Vector2 Eigen::Rotation2D< Scalar_ >::operator* ( const Vector2 vec) const
inline

Applies the rotation to a 2D vector

112 { return toRotationMatrix() * vec; }
EIGEN_DEVICE_FUNC Matrix2 toRotationMatrix() const
Definition: Rotation2D.h:191

References Eigen::Rotation2D< Scalar_ >::toRotationMatrix().

◆ operator*=()

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

Concatenates two rotations

106  {
107  m_angle += other.m_angle;
108  return *this;
109  }

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

◆ operator=()

template<typename Scalar_ >
template<typename Derived >
EIGEN_DEVICE_FUNC 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()
126  {
127  return fromRotationMatrix(m.derived());
128  }

References Eigen::Rotation2D< Scalar_ >::fromRotationMatrix(), and m.

◆ slerp()

template<typename Scalar_ >
EIGEN_DEVICE_FUNC 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.
133  {
134  Scalar dist = Rotation2D(other.m_angle - m_angle).smallestAngle();
135  return Rotation2D(m_angle + dist * t);
136  }
SCALAR Scalar
Definition: bench_gemm.cpp:45
t
Definition: plotPSD.py:36

References Eigen::Rotation2D< Scalar_ >::m_angle, Eigen::Rotation2D< Scalar_ >::Rotation2D(), and plotPSD::t.

◆ smallestAngle()

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Scalar Eigen::Rotation2D< Scalar_ >::smallestAngle ( ) const
inline
Returns
the rotation angle in [-pi,pi]
88  {
90  if (tmp > Scalar(EIGEN_PI))
91  tmp -= Scalar(2 * EIGEN_PI);
92  else if (tmp < -Scalar(EIGEN_PI))
93  tmp += Scalar(2 * EIGEN_PI);
94  return tmp;
95  }
#define EIGEN_PI
Definition: MathFunctions.h:16
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T fmod(const T &a, const T &b)
Definition: MathFunctions.h:1788

References EIGEN_PI, Eigen::numext::fmod(), Eigen::Rotation2D< Scalar_ >::m_angle, and tmp.

Referenced by transformations().

◆ smallestPositiveAngle()

template<typename Scalar_ >
EIGEN_DEVICE_FUNC Scalar Eigen::Rotation2D< Scalar_ >::smallestPositiveAngle ( ) const
inline
Returns
the rotation angle in [0,2pi]
82  {
84  return tmp < Scalar(0) ? tmp + Scalar(2 * EIGEN_PI) : tmp;
85  }

References EIGEN_PI, Eigen::numext::fmod(), Eigen::Rotation2D< Scalar_ >::m_angle, and tmp.

Referenced by transformations().

◆ toRotationMatrix()

template<typename Scalar >
Rotation2D< Scalar >::Matrix2 EIGEN_DEVICE_FUNC Eigen::Rotation2D< Scalar >::toRotationMatrix ( void  ) const

Constructs and

Returns
an equivalent 2x2 rotation matrix.
191  {
194  Scalar sinA = sin(m_angle);
195  Scalar cosA = cos(m_angle);
196  return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
197 }
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
Matrix< Scalar, 2, 2 > Matrix2
Definition: Rotation2D.h:54

References cos(), EIGEN_USING_STD, and sin().

Referenced by Eigen::Rotation2D< Scalar_ >::operator*(), rotate2DIntegral(), Eigen::internal::toRotationMatrix(), and transformations().

Member Data Documentation

◆ m_angle


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