11#ifndef EIGEN_ROTATIONBASE_H
12#define EIGEN_ROTATIONBASE_H
15#include "./InternalHeaderCheck.h"
21template <
typename RotationDerived,
typename MatrixType,
bool IsVector = MatrixType::IsVectorAtCompileTime>
22struct rotation_base_generic_product_selector;
32template <
typename Derived,
int Dim_>
37 using Scalar =
typename internal::traits<Derived>::Scalar;
44 EIGEN_DEVICE_FUNC
inline const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
45 EIGEN_DEVICE_FUNC
inline Derived& derived() {
return *
static_cast<Derived*
>(
this); }
56 EIGEN_DEVICE_FUNC
inline Derived
inverse()
const {
return derived().inverse(); }
74 template <
typename OtherDerived>
75 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
76 typename internal::rotation_base_generic_product_selector<Derived, OtherDerived,
77 OtherDerived::IsVectorAtCompileTime>::ReturnType
79 return internal::rotation_base_generic_product_selector<Derived, OtherDerived>::run(derived(), e.
derived());
83 template <
typename OtherDerived>
85 return l.
derived() * r.toRotationMatrix();
92 res.
linear().applyOnTheLeft(l);
97 template <
int Mode,
int Options>
103 template <
typename OtherVectorType>
104 EIGEN_DEVICE_FUNC
inline VectorType _transformVector(
const OtherVectorType& v)
const {
112template <
typename RotationDerived,
typename MatrixType>
113struct rotation_base_generic_product_selector<RotationDerived, MatrixType, false> {
114 enum { Dim = RotationDerived::Dim };
115 using ReturnType = Matrix<typename RotationDerived::Scalar, Dim, Dim>;
116 EIGEN_DEVICE_FUNC
static inline ReturnType run(
const RotationDerived& r,
const MatrixType& m) {
117 return r.toRotationMatrix() * m;
121template <
typename RotationDerived,
typename Scalar,
int Dim,
int MaxDim>
122struct rotation_base_generic_product_selector<RotationDerived, DiagonalMatrix<Scalar, Dim, MaxDim>, false> {
123 using ReturnType = Transform<Scalar, Dim, Affine>;
124 EIGEN_DEVICE_FUNC
static inline ReturnType run(
const RotationDerived& r,
125 const DiagonalMatrix<Scalar, Dim, MaxDim>& m) {
132template <
typename RotationDerived,
typename OtherVectorType>
133struct rotation_base_generic_product_selector<RotationDerived, OtherVectorType, true> {
134 enum { Dim = RotationDerived::Dim };
135 using ReturnType = Matrix<typename RotationDerived::Scalar, Dim, 1>;
136 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE ReturnType run(
const RotationDerived& r,
const OtherVectorType& v) {
137 return r._transformVector(v);
147template <
typename Scalar_,
int Rows_,
int Cols_,
int Storage_,
int MaxRows_,
int MaxCols_>
148template <
typename OtherDerived>
151 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(
Matrix,
int(OtherDerived::Dim),
int(OtherDerived::Dim))
159template <
typename Scalar_,
int Rows_,
int Cols_,
int Storage_,
int MaxRows_,
int MaxCols_>
160template <
typename OtherDerived>
164 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(
Matrix,
int(OtherDerived::Dim),
int(OtherDerived::Dim))
188template <
typename Scalar,
int Dim,
typename OtherScalar,
189 std::enable_if_t<std::is_scalar<OtherScalar>::value,
int> = 0>
191 EIGEN_STATIC_ASSERT(Dim == 2, YOU_MADE_A_PROGRAMMING_MISTAKE)
195template <
typename Scalar,
int Dim,
typename OtherDerived,
196 std::enable_if_t<std::is_same<Scalar, typename OtherDerived::Scalar>::value,
int> = 0>
197EIGEN_DEVICE_FUNC
static inline typename OtherDerived::RotationMatrixType toRotationMatrix(
198 const RotationBase<OtherDerived, Dim>& r) {
199 return r.toRotationMatrix();
202template <
typename Scalar,
int Dim,
typename OtherDerived,
203 std::enable_if_t<!std::is_same<Scalar, typename OtherDerived::Scalar>::value,
int> = 0>
204EIGEN_DEVICE_FUNC
static inline Matrix<Scalar, Dim, Dim> toRotationMatrix(
const RotationBase<OtherDerived, Dim>& r) {
205 return r.toRotationMatrix().template cast<Scalar>();
208template <
typename Scalar,
int Dim,
typename OtherDerived,
209 std::enable_if_t<std::is_same<Scalar, typename OtherDerived::Scalar>::value,
int> = 0>
210EIGEN_DEVICE_FUNC
static inline const OtherDerived& toRotationMatrix(
const MatrixBase<OtherDerived>& mat) {
211 EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime == Dim && OtherDerived::ColsAtCompileTime == Dim,
212 YOU_MADE_A_PROGRAMMING_MISTAKE)
213 return mat.derived();
216template <
typename Scalar,
int Dim,
typename OtherDerived,
217 std::enable_if_t<!std::is_same<Scalar, typename OtherDerived::Scalar>::value,
int> = 0>
218EIGEN_DEVICE_FUNC
static inline auto toRotationMatrix(
const MatrixBase<OtherDerived>& mat) {
219 EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime == Dim && OtherDerived::ColsAtCompileTime == Dim,
220 YOU_MADE_A_PROGRAMMING_MISTAKE)
221 return mat.template cast<Scalar>();
Represents a diagonal matrix with its storage.
Definition DiagonalMatrix.h:233
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:188
constexpr Matrix()=default
Default constructor.
constexpr Matrix & operator=(const Matrix &other)
Assigns matrices to each other.
Definition Matrix.h:212
Represents a rotation/orientation in a 2 dimensional space.
Definition Rotation2D.h:45
Matrix2 toRotationMatrix() const
Definition Rotation2D.h:192
Common base class for compact rotation representations.
Definition RotationBase.h:33
RotationMatrixType matrix() const
Definition RotationBase.h:53
internal::rotation_base_generic_product_selector< Derived, OtherDerived, OtherDerived::IsVectorAtCompileTime >::ReturnType operator*(const EigenBase< OtherDerived > &e) const
Definition RotationBase.h:78
Derived inverse() const
Definition RotationBase.h:56
Matrix< Scalar, Dim, Dim > RotationMatrixType
Definition RotationBase.h:40
friend RotationMatrixType operator*(const EigenBase< OtherDerived > &l, const Derived &r)
Definition RotationBase.h:84
Transform< Scalar, Dim, Isometry > operator*(const Translation< Scalar, Dim > &t) const
Definition RotationBase.h:59
Transform< Scalar, Dim, Mode > operator*(const Transform< Scalar, Dim, Mode, Options > &t) const
Definition RotationBase.h:98
RotationMatrixType operator*(const UniformScaling< Scalar > &s) const
Definition RotationBase.h:64
friend Transform< Scalar, Dim, Affine > operator*(const DiagonalMatrix< Scalar, Dim > &l, const Derived &r)
Definition RotationBase.h:89
typename internal::traits< AngleAxis< Scalar_ > >::Scalar Scalar
Definition RotationBase.h:37
RotationMatrixType toRotationMatrix() const
Definition RotationBase.h:48
Represents a translation transformation.
Definition Translation.h:34
Definition EigenBase.h:34
constexpr Derived & derived()
Definition EigenBase.h:50