10 #ifndef EIGEN_ROTATION2D_H 11 #define EIGEN_ROTATION2D_H 34 template<
typename _Scalar>
struct traits<Rotation2D<_Scalar> >
36 typedef _Scalar Scalar;
40 template<
typename _Scalar>
47 using Base::operator*;
62 EIGEN_DEVICE_FUNC
explicit inline Rotation2D(
const Scalar& a) : m_angle(a) {}
71 template<
typename Derived>
74 fromRotationMatrix(m.
derived());
78 EIGEN_DEVICE_FUNC
inline Scalar
angle()
const {
return m_angle; }
81 EIGEN_DEVICE_FUNC
inline Scalar&
angle() {
return m_angle; }
85 Scalar tmp = numext::fmod(m_angle,Scalar(2*EIGEN_PI));
86 return tmp<Scalar(0) ? tmp + Scalar(2*EIGEN_PI) : tmp;
91 Scalar tmp = numext::fmod(m_angle,Scalar(2*EIGEN_PI));
92 if(tmp>Scalar(EIGEN_PI)) tmp -= Scalar(2*EIGEN_PI);
93 else if(tmp<-Scalar(EIGEN_PI)) tmp += Scalar(2*EIGEN_PI);
102 {
return Rotation2D(m_angle + other.m_angle); }
106 { m_angle += other.m_angle;
return *
this; }
109 EIGEN_DEVICE_FUNC Vector2
operator* (
const Vector2& vec)
const 110 {
return toRotationMatrix() * vec; }
112 template<
typename Derived>
114 EIGEN_DEVICE_FUNC Matrix2 toRotationMatrix()
const;
123 template<
typename Derived>
125 {
return fromRotationMatrix(m.
derived()); }
141 template<
typename NewScalarType>
142 EIGEN_DEVICE_FUNC
inline typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type
cast()
const 143 {
return typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*
this); }
146 template<
typename OtherScalarType>
149 m_angle = Scalar(other.
angle());
159 {
return internal::isApprox(m_angle,other.m_angle, prec); }
174 template<
typename Scalar>
175 template<
typename Derived>
178 EIGEN_USING_STD(atan2)
179 EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime==2 && Derived::ColsAtCompileTime==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
180 m_angle = atan2(mat.
coeff(1,0), mat.
coeff(0,0));
186 template<
typename Scalar>
192 Scalar sinA =
sin(m_angle);
193 Scalar cosA =
cos(m_angle);
194 return (
Matrix2() << cosA, -sinA, sinA, cosA).finished();
199 #endif // EIGEN_ROTATION2D_H Matrix< Type, 2, 2 > Matrix2
[c++11]
Definition: Matrix.h:540
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Rotation2D(const Scalar &a)
Definition: Rotation2D.h:62
Rotation2D(const Rotation2D< OtherScalarType > &other)
Definition: Rotation2D.h:147
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:232
internal::cast_return_type< Rotation2D, Rotation2D< NewScalarType > >::type cast() const
Definition: Rotation2D.h:142
Scalar smallestPositiveAngle() const
Definition: Rotation2D.h:84
Derived & derived()
Definition: EigenBase.h:46
bool isApprox(const Rotation2D &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Rotation2D.h:158
CoeffReturnType coeff(Index row, Index col) const
Definition: DenseCoeffsBase.h:97
Rotation2D()
Definition: Rotation2D.h:65
Rotation2D(const MatrixBase< Derived > &m)
Definition: Rotation2D.h:72
Scalar smallestAngle() const
Definition: Rotation2D.h:90
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_cos_op< typename Derived::Scalar >, const Derived > cos(const Eigen::ArrayBase< Derived > &x)
const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition: PermutationMatrix.h:515
Common base class for compact rotation representations.
Definition: RotationBase.h:29
Rotation2D & operator=(const MatrixBase< Derived > &m)
Definition: Rotation2D.h:124
Definition: Eigen_Colamd.h:50
Rotation2D & operator*=(const Rotation2D &other)
Definition: Rotation2D.h:105
Represents a rotation/orientation in a 2 dimensional space.
Definition: Rotation2D.h:41
Rotation2D slerp(const Scalar &t, const Rotation2D &other) const
Definition: Rotation2D.h:130
Rotation2D inverse() const
Definition: Rotation2D.h:98
Matrix2 toRotationMatrix() const
Definition: Rotation2D.h:188
Rotation2D< double > Rotation2Dd
Definition: Rotation2D.h:168
_Scalar Scalar
Definition: Rotation2D.h:51
Rotation2D operator*(const Rotation2D &other) const
Definition: Rotation2D.h:101
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Rotation2D< float > Rotation2Df
Definition: Rotation2D.h:165
Scalar & angle()
Definition: Rotation2D.h:81
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sin_op< typename Derived::Scalar >, const Derived > sin(const Eigen::ArrayBase< Derived > &x)
Matrix< Type, 2, 1 > Vector2
[c++11]
Definition: Matrix.h:540
Scalar angle() const
Definition: Rotation2D.h:78