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. Eigen itself is part of the KDE project.
00003 //
00004 // Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 // no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
00026 
00027 // this file aims to contains the various representations of rotation/orientation
00028 // in 2D and 3D space excepted Matrix and Quaternion.
00029 
00037 template<typename Derived, int _Dim>
00038 class RotationBase
00039 {
00040   public:
00041     enum { Dim = _Dim };
00043     typedef typename ei_traits<Derived>::Scalar Scalar;
00044     
00046     typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;
00047 
00048     inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
00049     inline Derived& derived() { return *static_cast<Derived*>(this); }
00050 
00052     inline RotationMatrixType toRotationMatrix() const { return derived().toRotationMatrix(); }
00053 
00055     inline Derived inverse() const { return derived().inverse(); }
00056 
00058     inline Transform<Scalar,Dim> operator*(const Translation<Scalar,Dim>& t) const
00059     { return toRotationMatrix() * t; }
00060 
00062     inline RotationMatrixType operator*(const Scaling<Scalar,Dim>& s) const
00063     { return toRotationMatrix() * s; }
00064 
00066     inline Transform<Scalar,Dim> operator*(const Transform<Scalar,Dim>& t) const
00067     { return toRotationMatrix() * t; }
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(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
00078 {
00079   EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
00080   *this = r.toRotationMatrix();
00081 }
00082 
00087 template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
00088 template<typename OtherDerived>
00089 Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>&
00090 Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
00091 ::operator=(const RotationBase<OtherDerived,ColsAtCompileTime>& r)
00092 {
00093   EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
00094   return *this = r.toRotationMatrix();
00095 }
00096 
00115 template<typename Scalar, int Dim>
00116 inline static Matrix<Scalar,2,2> ei_toRotationMatrix(const Scalar& s)
00117 {
00118   EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
00119   return Rotation2D<Scalar>(s).toRotationMatrix();
00120 }
00121 
00122 template<typename Scalar, int Dim, typename OtherDerived>
00123 inline static Matrix<Scalar,Dim,Dim> ei_toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
00124 {
00125   return r.toRotationMatrix();
00126 }
00127 
00128 template<typename Scalar, int Dim, typename OtherDerived>
00129 inline static const MatrixBase<OtherDerived>& ei_toRotationMatrix(const MatrixBase<OtherDerived>& mat)
00130 {
00131   EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,
00132     YOU_MADE_A_PROGRAMMING_MISTAKE)
00133   return mat;
00134 }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:32:23