se2.h
Go to the documentation of this file.
00001 // g2o - General Graph Optimization
00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
00003 // 
00004 // g2o 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 // g2o 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 __SE2_H__
00018 #define __SE2_H__
00019 
00020 #include "g2o/stuff/misc.h"
00021 #include "g2o/stuff/macros.h"
00022 #include <Eigen/Core>
00023 #include <Eigen/Geometry>
00024 
00025 namespace g2o {
00026   using namespace Eigen;
00027 
00028   class SE2{
00029   public:
00030     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00031     SE2():_R(0),_t(0,0){}
00032 
00033     SE2(double x, double y, double theta):_R(theta),_t(x,y){}
00034 
00035     inline const Vector2d& translation() const {return _t;}
00036 
00037     inline Vector2d& translation() {return _t;}
00038 
00039     inline const Rotation2Dd& rotation() const {return _R;}
00040 
00041     inline Rotation2Dd& rotation() {return _R;}
00042     
00043     inline SE2 operator * (const SE2& tr2) const{
00044       SE2 result(*this);
00045       result._t += _R*tr2._t;
00046       result._R.angle()+= tr2._R.angle();
00047       result._R.angle()=normalize_theta(result._R.angle());
00048       return result;
00049     }
00050 
00051     inline SE2& operator *= (const SE2& tr2){
00052       _t+=_R*tr2._t;
00053       _R.angle()+=tr2._R.angle();
00054       _R.angle()=normalize_theta(_R.angle());
00055       return *this;
00056     }
00057 
00058     inline Vector2d operator * (const Vector2d& v) const {
00059       return _t+_R*v;
00060     }
00061 
00062     inline SE2 inverse() const{
00063       SE2 ret;
00064       ret._R=_R.inverse();
00065       ret._R.angle()=normalize_theta(ret._R.angle());
00066       ret._t=ret._R*(_t*-1.);
00067       return ret;
00068     }
00069     
00070     inline double operator [](int i) const {
00071       assert (i>=0 && i<3);
00072       if (i<2)
00073         return _t(i);
00074       return _R.angle();
00075     }
00076 
00077     inline double& operator [](int i) {
00078       assert (i>=0 && i<3);
00079       if (i<2)
00080         return _t(i);
00081       return _R.angle();
00082     }
00083 
00084     inline void fromVector (const Vector3d& v){
00085       *this=SE2(v[0], v[1], v[2]);
00086     }
00087 
00088     inline Vector3d toVector() const {
00089       return Vector3d(_t.x(), _t.y(), _R.angle());
00090     }
00091 
00092   protected:
00093     Rotation2Dd _R;
00094     Vector2d _t;
00095   };
00096 
00097 } // end namespace
00098 
00099 #endif


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