Warning, file /include/eigen3/Eigen/src/Geometry/RotationBase.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef EIGEN_ROTATIONBASE_H
0011 #define EIGEN_ROTATIONBASE_H
0012
0013 namespace Eigen {
0014
0015
0016 namespace internal {
0017 template<typename RotationDerived, typename MatrixType, bool IsVector=MatrixType::IsVectorAtCompileTime>
0018 struct rotation_base_generic_product_selector;
0019 }
0020
0021
0022
0023
0024
0025
0026
0027
0028 template<typename Derived, int _Dim>
0029 class RotationBase
0030 {
0031 public:
0032 enum { Dim = _Dim };
0033
0034 typedef typename internal::traits<Derived>::Scalar Scalar;
0035
0036
0037 typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;
0038 typedef Matrix<Scalar,Dim,1> VectorType;
0039
0040 public:
0041 EIGEN_DEVICE_FUNC inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
0042 EIGEN_DEVICE_FUNC inline Derived& derived() { return *static_cast<Derived*>(this); }
0043
0044
0045 EIGEN_DEVICE_FUNC inline RotationMatrixType toRotationMatrix() const { return derived().toRotationMatrix(); }
0046
0047
0048
0049
0050 EIGEN_DEVICE_FUNC inline RotationMatrixType matrix() const { return derived().toRotationMatrix(); }
0051
0052
0053 EIGEN_DEVICE_FUNC inline Derived inverse() const { return derived().inverse(); }
0054
0055
0056 EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Isometry> operator*(const Translation<Scalar,Dim>& t) const
0057 { return Transform<Scalar,Dim,Isometry>(*this) * t; }
0058
0059
0060 EIGEN_DEVICE_FUNC inline RotationMatrixType operator*(const UniformScaling<Scalar>& s) const
0061 { return toRotationMatrix() * s.factor(); }
0062
0063
0064
0065
0066
0067
0068
0069 template<typename OtherDerived>
0070 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename internal::rotation_base_generic_product_selector<Derived,OtherDerived,OtherDerived::IsVectorAtCompileTime>::ReturnType
0071 operator*(const EigenBase<OtherDerived>& e) const
0072 { return internal::rotation_base_generic_product_selector<Derived,OtherDerived>::run(derived(), e.derived()); }
0073
0074
0075 template<typename OtherDerived> friend
0076 EIGEN_DEVICE_FUNC inline RotationMatrixType operator*(const EigenBase<OtherDerived>& l, const Derived& r)
0077 { return l.derived() * r.toRotationMatrix(); }
0078
0079
0080 EIGEN_DEVICE_FUNC friend inline Transform<Scalar,Dim,Affine> operator*(const DiagonalMatrix<Scalar,Dim>& l, const Derived& r)
0081 {
0082 Transform<Scalar,Dim,Affine> res(r);
0083 res.linear().applyOnTheLeft(l);
0084 return res;
0085 }
0086
0087
0088 template<int Mode, int Options>
0089 EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode> operator*(const Transform<Scalar,Dim,Mode,Options>& t) const
0090 { return toRotationMatrix() * t; }
0091
0092 template<typename OtherVectorType>
0093 EIGEN_DEVICE_FUNC inline VectorType _transformVector(const OtherVectorType& v) const
0094 { return toRotationMatrix() * v; }
0095 };
0096
0097 namespace internal {
0098
0099
0100 template<typename RotationDerived, typename MatrixType>
0101 struct rotation_base_generic_product_selector<RotationDerived,MatrixType,false>
0102 {
0103 enum { Dim = RotationDerived::Dim };
0104 typedef Matrix<typename RotationDerived::Scalar,Dim,Dim> ReturnType;
0105 EIGEN_DEVICE_FUNC static inline ReturnType run(const RotationDerived& r, const MatrixType& m)
0106 { return r.toRotationMatrix() * m; }
0107 };
0108
0109 template<typename RotationDerived, typename Scalar, int Dim, int MaxDim>
0110 struct rotation_base_generic_product_selector< RotationDerived, DiagonalMatrix<Scalar,Dim,MaxDim>, false >
0111 {
0112 typedef Transform<Scalar,Dim,Affine> ReturnType;
0113 EIGEN_DEVICE_FUNC static inline ReturnType run(const RotationDerived& r, const DiagonalMatrix<Scalar,Dim,MaxDim>& m)
0114 {
0115 ReturnType res(r);
0116 res.linear() *= m;
0117 return res;
0118 }
0119 };
0120
0121 template<typename RotationDerived,typename OtherVectorType>
0122 struct rotation_base_generic_product_selector<RotationDerived,OtherVectorType,true>
0123 {
0124 enum { Dim = RotationDerived::Dim };
0125 typedef Matrix<typename RotationDerived::Scalar,Dim,1> ReturnType;
0126 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE ReturnType run(const RotationDerived& r, const OtherVectorType& v)
0127 {
0128 return r._transformVector(v);
0129 }
0130 };
0131
0132 }
0133
0134
0135
0136
0137
0138 template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
0139 template<typename OtherDerived>
0140 EIGEN_DEVICE_FUNC Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
0141 ::Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
0142 {
0143 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
0144 *this = r.toRotationMatrix();
0145 }
0146
0147
0148
0149
0150
0151 template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
0152 template<typename OtherDerived>
0153 EIGEN_DEVICE_FUNC Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>&
0154 Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
0155 ::operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
0156 {
0157 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
0158 return *this = r.toRotationMatrix();
0159 }
0160
0161 namespace internal {
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181 template<typename Scalar, int Dim>
0182 EIGEN_DEVICE_FUNC static inline Matrix<Scalar,2,2> toRotationMatrix(const Scalar& s)
0183 {
0184 EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
0185 return Rotation2D<Scalar>(s).toRotationMatrix();
0186 }
0187
0188 template<typename Scalar, int Dim, typename OtherDerived>
0189 EIGEN_DEVICE_FUNC static inline Matrix<Scalar,Dim,Dim> toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
0190 {
0191 return r.toRotationMatrix();
0192 }
0193
0194 template<typename Scalar, int Dim, typename OtherDerived>
0195 EIGEN_DEVICE_FUNC static inline const MatrixBase<OtherDerived>& toRotationMatrix(const MatrixBase<OtherDerived>& mat)
0196 {
0197 EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,
0198 YOU_MADE_A_PROGRAMMING_MISTAKE)
0199 return mat;
0200 }
0201
0202 }
0203
0204 }
0205
0206 #endif