Transform.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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         // Zero by default
00044         Transform();
00045         // rotation matrix r## and origin o##
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         // x,y,z, roll,pitch,yaw
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 /* TRANSFORM_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Fri Aug 28 2015 12:51:42