00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef EIGEN_ROTATIONBASE_H
00026 #define EIGEN_ROTATIONBASE_H
00027
00028
00029
00030
00038 template<typename Derived, int _Dim>
00039 class RotationBase
00040 {
00041 public:
00042 enum { Dim = _Dim };
00044 typedef typename ei_traits<Derived>::Scalar Scalar;
00045
00047 typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;
00048
00049 inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
00050 inline Derived& derived() { return *static_cast<Derived*>(this); }
00051
00053 inline RotationMatrixType toRotationMatrix() const { return derived().toRotationMatrix(); }
00054
00056 inline Derived inverse() const { return derived().inverse(); }
00057
00059 inline Transform<Scalar,Dim> operator*(const Translation<Scalar,Dim>& t) const
00060 { return toRotationMatrix() * t; }
00061
00063 inline RotationMatrixType operator*(const Scaling<Scalar,Dim>& s) const
00064 { return toRotationMatrix() * s; }
00065
00067 inline Transform<Scalar,Dim> operator*(const Transform<Scalar,Dim>& t) const
00068 { return toRotationMatrix() * t; }
00069 };
00070
00075 template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
00076 template<typename OtherDerived>
00077 Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
00078 ::Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
00079 {
00080 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
00081 *this = r.toRotationMatrix();
00082 }
00083
00088 template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
00089 template<typename OtherDerived>
00090 Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>&
00091 Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
00092 ::operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
00093 {
00094 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
00095 return *this = r.toRotationMatrix();
00096 }
00097
00116 template<typename Scalar, int Dim>
00117 inline static Matrix<Scalar,2,2> ei_toRotationMatrix(const Scalar& s)
00118 {
00119 EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
00120 return Rotation2D<Scalar>(s).toRotationMatrix();
00121 }
00122
00123 template<typename Scalar, int Dim, typename OtherDerived>
00124 inline static Matrix<Scalar,Dim,Dim> ei_toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
00125 {
00126 return r.toRotationMatrix();
00127 }
00128
00129 template<typename Scalar, int Dim, typename OtherDerived>
00130 inline static const MatrixBase<OtherDerived>& ei_toRotationMatrix(const MatrixBase<OtherDerived>& mat)
00131 {
00132 EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,
00133 YOU_MADE_A_PROGRAMMING_MISTAKE)
00134 return mat;
00135 }
00136
00137 #endif // EIGEN_ROTATIONBASE_H