RotationBase.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 // no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
00011 
00012 namespace Eigen { 
00013 
00014 // this file aims to contains the various representations of rotation/orientation
00015 // in 2D and 3D space excepted Matrix and Quaternion.
00016 
00024 template<typename Derived, int _Dim>
00025 class RotationBase
00026 {
00027   public:
00028     enum { Dim = _Dim };
00030     typedef typename ei_traits<Derived>::Scalar Scalar;
00031     
00033     typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;
00034 
00035     inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
00036     inline Derived& derived() { return *static_cast<Derived*>(this); }
00037 
00039     inline RotationMatrixType toRotationMatrix() const { return derived().toRotationMatrix(); }
00040 
00042     inline Derived inverse() const { return derived().inverse(); }
00043 
00045     inline Transform<Scalar,Dim> operator*(const Translation<Scalar,Dim>& t) const
00046     { return toRotationMatrix() * t; }
00047 
00049     inline RotationMatrixType operator*(const Scaling<Scalar,Dim>& s) const
00050     { return toRotationMatrix() * s; }
00051 
00053     inline Transform<Scalar,Dim> operator*(const Transform<Scalar,Dim>& t) const
00054     { return toRotationMatrix() * t; }
00055 };
00056 
00061 template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
00062 template<typename OtherDerived>
00063 Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
00064 ::Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
00065 {
00066   EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
00067   *this = r.toRotationMatrix();
00068 }
00069 
00074 template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
00075 template<typename OtherDerived>
00076 Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>&
00077 Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
00078 ::operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
00079 {
00080   EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
00081   return *this = r.toRotationMatrix();
00082 }
00083 
00102 template<typename Scalar, int Dim>
00103 static inline Matrix<Scalar,2,2> ei_toRotationMatrix(const Scalar& s)
00104 {
00105   EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
00106   return Rotation2D<Scalar>(s).toRotationMatrix();
00107 }
00108 
00109 template<typename Scalar, int Dim, typename OtherDerived>
00110 static inline Matrix<Scalar,Dim,Dim> ei_toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
00111 {
00112   return r.toRotationMatrix();
00113 }
00114 
00115 template<typename Scalar, int Dim, typename OtherDerived>
00116 static inline const MatrixBase<OtherDerived>& ei_toRotationMatrix(const MatrixBase<OtherDerived>& mat)
00117 {
00118   EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,
00119     YOU_MADE_A_PROGRAMMING_MISTAKE)
00120   return mat;
00121 }
00122 
00123 } // end namespace Eigen


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:59:55