11#ifndef EIGEN_ROTATION2D_H
12#define EIGEN_ROTATION2D_H
15#include "./InternalHeaderCheck.h"
38template <
typename Scalar_>
39struct traits<Rotation2D<Scalar_> > {
40 using Scalar = Scalar_;
44template <
typename Scalar_>
49 using Base::operator*;
71 template <
typename Derived>
73 fromRotationMatrix(m.derived());
77 EIGEN_DEVICE_FUNC
inline Scalar angle()
const {
return m_angle; }
84 Scalar tmp = numext::fmod(m_angle,
Scalar(2 * EIGEN_PI));
85 return tmp <
Scalar(0) ? tmp +
Scalar(2 * EIGEN_PI) : tmp;
90 Scalar tmp = numext::fmod(m_angle,
Scalar(2 * EIGEN_PI));
91 if (tmp >
Scalar(EIGEN_PI))
92 tmp -=
Scalar(2 * EIGEN_PI);
93 else if (tmp < -
Scalar(EIGEN_PI))
94 tmp +=
Scalar(2 * EIGEN_PI);
108 m_angle += other.m_angle;
115 template <
typename Derived>
126 template <
typename Derived>
128 return fromRotationMatrix(m.derived());
144 template <
typename NewScalarType>
145 EIGEN_DEVICE_FUNC
inline typename internal::cast_return_type<Rotation2D, Rotation2D<NewScalarType> >::type
cast()
147 return typename internal::cast_return_type<Rotation2D, Rotation2D<NewScalarType> >::type(*
this);
151 template <
typename OtherScalarType>
162 EIGEN_DEVICE_FUNC
bool isApprox(
const Rotation2D& other,
const typename NumTraits<Scalar>::Real& prec =
163 NumTraits<Scalar>::dummy_precision())
const {
164 return internal::isApprox(m_angle, other.m_angle, prec);
179template <
typename Scalar>
180template <
typename Derived>
182 EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 2 && Derived::ColsAtCompileTime == 2,
183 YOU_MADE_A_PROGRAMMING_MISTAKE)
184 m_angle = numext::atan2(
Scalar(mat.coeff(1, 0)),
Scalar(mat.coeff(0, 0)));
190template <
typename Scalar>
192 Scalar sinA = numext::sin(m_angle);
193 Scalar cosA = numext::cos(m_angle);
194 return (
Matrix2() << cosA, -sinA, sinA, cosA).finished();
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:53
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:188
Represents a rotation/orientation in a 2 dimensional space.
Definition Rotation2D.h:45
Rotation2D inverse() const
Definition Rotation2D.h:99
Scalar smallestPositiveAngle() const
Definition Rotation2D.h:83
Scalar smallestAngle() const
Definition Rotation2D.h:89
Rotation2D(const Scalar &a)
Definition Rotation2D.h:62
Rotation2D & operator=(const MatrixBase< Derived > &m)
Definition Rotation2D.h:127
Vector2 operator*(const Vector2 &vec) const
Definition Rotation2D.h:113
Scalar angle() const
Definition Rotation2D.h:77
Scalar_ Scalar
Definition Rotation2D.h:53
Matrix2 toRotationMatrix() const
Definition Rotation2D.h:191
Rotation2D operator*(const Rotation2D &other) const
Definition Rotation2D.h:102
internal::cast_return_type< Rotation2D, Rotation2D< NewScalarType > >::type cast() const
Definition Rotation2D.h:145
Rotation2D(const Rotation2D< OtherScalarType > &other)
Definition Rotation2D.h:152
Rotation2D()
Definition Rotation2D.h:65
Rotation2D & operator*=(const Rotation2D &other)
Definition Rotation2D.h:107
Scalar & angle()
Definition Rotation2D.h:80
Rotation2D slerp(const Scalar &t, const Rotation2D &other) const
Definition Rotation2D.h:134
bool isApprox(const Rotation2D &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Rotation2D.h:162
Rotation2D(const MatrixBase< Derived > &m)
Definition Rotation2D.h:72
Common base class for compact rotation representations.
Definition RotationBase.h:33
Rotation2D< double > Rotation2Dd
Definition Rotation2D.h:173
Rotation2D< float > Rotation2Df
Definition Rotation2D.h:170
Matrix< Type, 2, 2 > Matrix2
2×2 matrix of type Type.
Definition Matrix.h:521