$search
00001 // HOG-Man - Hierarchical Optimization for Pose Graphs on Manifolds 00002 // Copyright (C) 2010 G. Grisetti, R. Kümmerle, C. Stachniss 00003 // 00004 // HOG-Man is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU Lesser General Public License as published 00006 // by the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // HOG-Man is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU Lesser General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU Lesser General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 #ifndef _ROTATIONMATRIX_H_ 00018 #define _ROTATIONMATRIX_H_ 00019 00020 #include "matrix_n.h" 00021 00031 template <int N, typename Base=double> 00032 struct _RotationMatrix: public _Matrix<N, N, Base> { 00033 static const int Dimension=N; 00035 _RotationMatrix(); 00037 _RotationMatrix<N,Base>& operator*=(const _RotationMatrix<N,Base>& m); 00039 _RotationMatrix<N,Base> operator*(const _RotationMatrix<N,Base>& m) const; 00041 _Vector<N,Base> operator*(const _Vector<N,Base>& v) const; 00043 _RotationMatrix<N,Base> inverse() const; 00044 protected: 00045 _RotationMatrix(const _Matrix<N,N,Base> &m); 00046 }; 00047 00049 template < typename Base=double > 00050 struct _RotationMatrix2: public _RotationMatrix<2, Base>{ 00051 static const int Angles=1; 00052 _RotationMatrix2(); 00054 _RotationMatrix2(Base angle); 00056 _RotationMatrix2(const _Vector<1,Base>& angles); 00057 _RotationMatrix2(const _RotationMatrix<2,Base>& rm) {this->_allocator=rm._allocator;} 00060 _RotationMatrix2<Base> rotationMatrix() const {return *this;} 00062 _Vector<1, Base> angles() const {_Vector<1, Base> v; v[0]=angle(); return v;} 00063 Base angle() const; 00064 }; 00065 00067 template <typename Base = double > 00068 struct _RotationMatrix3: public _RotationMatrix<3, Base>{ 00069 static const int Angles=3; 00070 _RotationMatrix3(); 00072 _RotationMatrix3(const _Vector<3, Base>& angles); 00073 _RotationMatrix3(const _RotationMatrix<3,Base>& rm) {this->_allocator=rm._allocator;} 00075 _RotationMatrix3(Base roll, Base pitch, Base yaw); 00078 _RotationMatrix3<Base> rotationMatrix() const {return *this;} 00080 _Vector<3, Base> angles() const; 00081 }; 00083 00084 typedef _RotationMatrix2<double> RotationMatrix2; 00085 typedef _RotationMatrix3<double> RotationMatrix3; 00086 typedef _RotationMatrix2<float> RotationMatrix2f; 00087 typedef _RotationMatrix3<float> RotationMatrix3f; 00088 00089 #include "rotation_matrix.hpp" 00090 00091 00092 #endif