Go to the documentation of this file.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
00026
00027
00028 #ifndef TRANSFORM_H_
00029 #define TRANSFORM_H_
00030
00031 #include <rtabmap/core/RtabmapExp.h>
00032 #include <vector>
00033 #include <string>
00034 #include <Eigen/Core>
00035 #include <Eigen/Geometry>
00036
00037 namespace rtabmap {
00038
00039 class RTABMAP_EXP Transform
00040 {
00041 public:
00042
00043
00044 Transform();
00045
00046 Transform(float r11, float r12, float r13, float o14,
00047 float r21, float r22, float r23, float o24,
00048 float r31, float r32, float r33, float o34);
00049
00050 Transform(float x, float y, float z, float roll, float pitch, float yaw);
00051
00052 float r11() const {return data_[0];}
00053 float r12() const {return data_[1];}
00054 float r13() const {return data_[2];}
00055 float r21() const {return data_[4];}
00056 float r22() const {return data_[5];}
00057 float r23() const {return data_[6];}
00058 float r31() const {return data_[8];}
00059 float r32() const {return data_[9];}
00060 float r33() const {return data_[10];}
00061
00062 float o14() const {return data_[3];}
00063 float o24() const {return data_[7];}
00064 float o34() const {return data_[11];}
00065
00066 float & operator[](int index) {return data_[index];}
00067 const float & operator[](int index) const {return data_[index];}
00068
00069 bool isNull() const;
00070 bool isIdentity() const;
00071
00072 void setNull();
00073 void setIdentity();
00074
00075 const float * data() const {return data_.data();}
00076 float * data() {return data_.data();}
00077 int size() const {return (int)data_.size();}
00078
00079 float & x() {return data_[3];}
00080 float & y() {return data_[7];}
00081 float & z() {return data_[11];}
00082 const float & x() const {return data_[3];}
00083 const float & y() const {return data_[7];}
00084 const float & z() const {return data_[11];}
00085
00086 float theta() const;
00087
00088 Transform inverse() const;
00089 Transform rotation() const;
00090 Transform translation() const;
00091
00092 void getTranslationAndEulerAngles(float & x, float & y, float & z, float & roll, float & pitch, float & yaw) const;
00093 void getEulerAngles(float & roll, float & pitch, float & yaw) const;
00094 void getTranslation(float & x, float & y, float & z) const;
00095 float getNorm() const;
00096 float getNormSquared() const;
00097 float getDistance(const Transform & t) const;
00098 float getDistanceSquared(const Transform & t) const;
00099 std::string prettyPrint() const;
00100
00101 Transform operator*(const Transform & t) const;
00102 Transform & operator*=(const Transform & t);
00103 bool operator==(const Transform & t) const;
00104 bool operator!=(const Transform & t) const;
00105
00106 Eigen::Matrix4f toEigen4f() const;
00107 Eigen::Matrix4d toEigen4d() const;
00108 Eigen::Affine3f toEigen3f() const;
00109 Eigen::Affine3d toEigen3d() const;
00110
00111 Eigen::Quaternionf getQuaternionf() const;
00112 Eigen::Quaterniond getQuaterniond() const;
00113
00114 public:
00115 static Transform getIdentity();
00116 static Transform fromEigen4f(const Eigen::Matrix4f & matrix);
00117 static Transform fromEigen4d(const Eigen::Matrix4d & matrix);
00118 static Transform fromEigen3f(const Eigen::Affine3f & matrix);
00119 static Transform fromEigen3d(const Eigen::Affine3d & matrix);
00120 static Transform fromEigen3f(const Eigen::Isometry3f & matrix);
00121 static Transform fromEigen3d(const Eigen::Isometry3d & matrix);
00122
00123 private:
00124 std::vector<float> data_;
00125 };
00126
00127 RTABMAP_EXP std::ostream& operator<<(std::ostream& os, const Transform& s);
00128
00129 }
00130
00131 #endif