transformation3.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * This source code is part of the Tree-based Network Optimizer (TORO)
4  *
5  * TORO Copyright (c) 2007 Giorgio Grisetti, Cyrill Stachniss,
6  * Slawomir Grzonka, and Wolfram Burgard
7  *
8  * TORO is licences under the Common Creative License,
9  * Attribution-NonCommercial-ShareAlike 3.0
10  *
11  * You are free:
12  * - to Share - to copy, distribute and transmit the work
13  * - to Remix - to adapt the work
14  *
15  * Under the following conditions:
16  *
17  * - Attribution. You must attribute the work in the manner specified
18  * by the author or licensor (but not in any way that suggests that
19  * they endorse you or your use of the work).
20  *
21  * - Noncommercial. You may not use this work for commercial purposes.
22  *
23  * - Share Alike. If you alter, transform, or build upon this work,
24  * you may distribute the resulting work only under the same or
25  * similar license to this one.
26  *
27  * Any of the above conditions can be waived if you get permission
28  * from the copyright holder. Nothing in this license impairs or
29  * restricts the author's moral rights.
30  *
31  * TORO is distributed in the hope that it will be useful,
32  * but WITHOUT ANY WARRANTY; without even the implied
33  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
34  * PURPOSE.
35  **********************************************************************/
36 
37 #ifndef _TRANSFORMATION3_HXX_
38 #define _TRANSFORMATION3_HXX_
39 
40 #include <assert.h>
41 #include <cmath>
42 
43 #include "dmatrix.h"
44 
45 namespace AISNavigation {
46 
47 template <class T>
48 struct Vector3 {
49  T elems[3] ;
50 
51  Vector3(T x, T y, T z) {elems[0]=x; elems[1]=y; elems[2]=z;}
52  Vector3() {elems[0]=0.; elems[1]=0.; elems[2]=0.;}
53  Vector3(const DVector<T>& t){}
54 
55  // translational view
56  inline const T& x() const {return elems[0];}
57  inline const T& y() const {return elems[1];}
58  inline const T& z() const {return elems[2];}
59  inline T& x() {return elems[0];}
60  inline T& y() {return elems[1];}
61  inline T& z() {return elems[2];}
62 
63  // rotational view
64  inline const T& roll() const {return elems[0];}
65  inline const T& pitch() const {return elems[1];}
66  inline const T& yaw() const {return elems[2];}
67  inline T& roll() {return elems[0];}
68  inline T& pitch() {return elems[1];}
69  inline T& yaw() {return elems[2];}
70 
71 };
72 
73 template <class T>
74 struct Pose3 : public DVector<T>{
75  Pose3();
76  Pose3(const Vector3<T>& rot, const Vector3<T>& trans);
77  Pose3(const T& x, const T& y, const T& z, const T& roll, const T& pitch, const T& yaw);
78  Pose3(const DVector<T>& v): DVector<T>(v) {assert(v.dim()==6);}
79 
80  inline operator const DVector<T>& () {return (const DVector<T>)*this;}
81  inline operator DVector<T>& () {return *this;}
82 
83  inline const T& roll() const {return DVector<T>::elems[0];}
84  inline const T& pitch() const {return DVector<T>::elems[1];}
85  inline const T& yaw() const {return DVector<T>::elems[2];}
86  inline const T& x() const {return DVector<T>::elems[3];}
87  inline const T& y() const {return DVector<T>::elems[4];}
88  inline const T& z() const {return DVector<T>::elems[5];}
89 
90  inline T& roll() {return DVector<T>::elems[0];}
91  inline T& pitch() {return DVector<T>::elems[1];}
92  inline T& yaw() {return DVector<T>::elems[2];}
93  inline T& x() {return DVector<T>::elems[3];}
94  inline T& y() {return DVector<T>::elems[4];}
95  inline T& z() {return DVector<T>::elems[5];}
96 
97 };
98 
99 
105 template <class T>
106 struct Quaternion{
107 
111  Quaternion();
112 
116  Quaternion(const Vector3<T>& pose);
117 
121  Quaternion(const T _w, const T _x, const T _y, const T _z);
122 
126  Quaternion(const T _roll_x_phi, const T _pitch_y_theta, const T _yaw_z_psi);
127 
131  inline Quaternion<T> conjugated() const;
132 
136  inline Quaternion<T> normalized() const;
137 
141  inline Quaternion<T> inverse() const;
142 
143  /*construct a quaternion on the axis/angle representation*/
144  inline Quaternion(const Vector3<T>& axis, const T& angle);
145 
152  inline Quaternion<T> rotateThisAlong (const Vector3<T>& axis, const T alpha) const;
153 
154 
161  inline Quaternion<T> rotatePoint(const Quaternion& p) const;
162 
169  inline Vector3<T> rotatePoint(const Vector3<T>& p) const;
170 
177  inline Quaternion withRotation (const T alpha) const;
178 
183  inline Vector3<T> toAngles() const;
184 
185  inline Vector3<T> axis() const;
186  inline T angle() const;
187 
188 
192  inline T norm() const;
193 
197  inline T re() const;
198 
202  inline Vector3<T> im() const;
203 
204  T w,x,y,z;
205 };
206 
207 
208 
209 template <class T> inline Quaternion<T> operator + (const Quaternion<T> & left, const Quaternion<T>& right);
210 template <class T> inline Quaternion<T> operator - (const Quaternion<T> & left, const Quaternion<T>& right);
211 template <class T> inline Quaternion<T> operator * (const Quaternion<T> & left, const Quaternion<T>& right);
212 template <class T> inline Quaternion<T> operator * (const Quaternion<T> & left, const T scalar);
213 template <class T> inline Quaternion<T> operator * (const T scalar, const Quaternion<T>& right);
214 template <class T> std::ostream& operator << (std::ostream& os, const Quaternion<T>& q);
215 
216 template <class T> inline T innerproduct(const Quaternion<T>& left, const Quaternion<T>& right);
217 template <class T> inline Quaternion<T> slerp(const Quaternion<T>& from, const Quaternion<T>& to, const T lambda);
218 
219 
220 
221 template <class T>
222 struct Transformation3{
225 
226  Transformation3(){}
227 
228  inline static Transformation3<T> identity();
229 
230  Transformation3 (const Vector3<T>& trans, const Quaternion<T>& rot);
231  Transformation3 (const Pose3<T>& v);
232  Transformation3 (const T& x, const T& y, const T& z, const T& roll, const T& pitch, const T& yaw);
233 
234  inline Vector3<T> translation() const;
235  inline Quaternion <T> rotation() const;
236 
237  inline Pose3<T> toPoseType() const;
238 
239  inline void setTranslation(const Vector3<T>& t);
240  inline void setTranslation(const T& x, const T& y, const T& z);
241 
242  inline void setRotation(const Vector3<T>& r);
243  inline void setRotation(const T& roll, const T& pitch, const T& yaw);
244  inline void setRotation(const Quaternion<T>& q);
245 
246 
247  inline Transformation3<T> inv() const;
248  inline bool validRotation(const T& epsilon=0.001) const;
249 
250 };
251 
252 template <class T>
253 inline Vector3<T> operator * (const Transformation3<T>& m, const Vector3<T>& v);
254 
255 template <class T>
257 
258 template <class T>
259 struct Operations3D{
260  typedef T BaseType;
261  typedef Pose3<T> PoseType;
262  typedef Quaternion<T> RotationType;
263  typedef Vector3<T> TranslationType;
265  typedef DMatrix<T> CovarianceType;
266  typedef DMatrix<T> InformationType;
268 };
269 
270 } // namespace AISNavigation
271 /**************************** IMPLEMENTATION ****************************/
272 
273 #include "transformation3.hxx"
274 
275 #endif
276 
AISNavigation::Vector3::elems
T elems[3]
Definition: transformation3.h:117
AISNavigation::Vector3::y
const T & y() const
Definition: transformation3.h:125
AISNavigation::Vector3::yaw
const T & yaw() const
Definition: transformation3.h:134
AISNavigation::Pose3::y
const T & y() const
Definition: transformation3.h:121
AISNavigation::Vector3::x
const T & x() const
Definition: transformation3.h:124
AISNavigation::Quaternion::normalized
Quaternion< T > normalized() const
glm::yaw
GLM_FUNC_DECL T yaw(detail::tquat< T, P > const &x)
AISNavigation::Vector3::Vector3
Vector3()
Definition: transformation3.h:120
AISNavigation::Quaternion::axis
Vector3< T > axis() const
AISNavigation::Quaternion::im
Vector3< T > im() const
AISNavigation::Vector3::z
const T & z() const
Definition: transformation3.h:126
AISNavigation::Transformation3::setTranslation
void setTranslation(const Vector3< T > &t)
AISNavigation::Quaternion::norm
T norm() const
AISNavigation::operator*
Vector2< T > operator*(const T &d, const Vector2< T > &v)
Definition: transformation2.h:81
AISNavigation::Quaternion::withRotation
Quaternion withRotation(const T alpha) const
AISNavigation::Transformation3::inv
Transformation3< T > inv() const
AISNavigation::Quaternion::rotatePoint
Quaternion< T > rotatePoint(const Quaternion &p) const
Vector3
Eigen::Vector3d Vector3
AISNavigation::Quaternion::inverse
Quaternion< T > inverse() const
AISNavigation::Transformation3::rotationQuaternion
Quaternion< T > rotationQuaternion
Definition: transformation3.h:257
AISNavigation::Transformation3::toPoseType
Pose3< T > toPoseType() const
AISNavigation::innerproduct
T innerproduct(const Quaternion< T > &left, const Quaternion< T > &right)
AISNavigation::Quaternion::x
T x
Definition: transformation3.h:238
AISNavigation::Pose3
Definition: transformation3.h:108
AISNavigation::Vector3::pitch
const T & pitch() const
Definition: transformation3.h:133
AISNavigation::Pose3::pitch
const T & pitch() const
Definition: transformation3.h:118
AISNavigation::Quaternion::w
T w
Definition: transformation3.h:238
AISNavigation::Quaternion::angle
T angle() const
AISNavigation::Transformation3::rotation
Quaternion< T > rotation() const
AISNavigation::Operations3D::TransformationType
Transformation3< T > TransformationType
Definition: transformation3.h:298
AISNavigation::Transformation3::validRotation
bool validRotation(const T &epsilon=0.001) const
AISNavigation::Quaternion::re
T re() const
AISNavigation::Pose3::yaw
const T & yaw() const
Definition: transformation3.h:119
AISNavigation::Transformation3::Transformation3
Transformation3()
Definition: transformation3.h:260
Eigen::Triplet
AISNavigation::operator+
Vector2< T > operator+(const Vector2< T > &v1, const Vector2< T > &v2)
Definition: transformation2.h:100
AISNavigation::Pose3::z
const T & z() const
Definition: transformation3.h:122
AISNavigation::Transformation3::setRotation
void setRotation(const Vector3< T > &r)
glm::pitch
GLM_FUNC_DECL T pitch(detail::tquat< T, P > const &x)
AISNavigation::Operations3D::CovarianceType
DMatrix< T > CovarianceType
Definition: transformation3.h:299
AISNavigation::operator<<
std::ostream & operator<<(std::ostream &os, const Quaternion< T > &q)
AISNavigation::Quaternion::Quaternion
Quaternion()
AISNavigation::slerp
Quaternion< T > slerp(const Quaternion< T > &from, const Quaternion< T > &to, const T lambda)
AISNavigation::Quaternion::conjugated
Quaternion< T > conjugated() const
Eigen::Quaternion
AISNavigation::Operations3D::InformationType
DMatrix< T > InformationType
Definition: transformation3.h:300
AISNavigation::Operations3D::TranslationType
Vector3< T > TranslationType
Definition: transformation3.h:297
AISNavigation::Vector3
Definition: transformation3.h:82
AISNavigation::Quaternion
Definition: transformation3.h:140
v
Array< int, Dynamic, 1 > v
AISNavigation::Pose3::Pose3
Pose3()
AISNavigation::Quaternion::rotateThisAlong
Quaternion< T > rotateThisAlong(const Vector3< T > &axis, const T alpha) const
epsilon
double epsilon
AISNavigation::Operations3D::RotationType
Quaternion< T > RotationType
Definition: transformation3.h:296
AISNavigation::Transformation3::identity
static Transformation3< T > identity()
AISNavigation::Operations3D::PoseType
Pose3< T > PoseType
Definition: transformation3.h:295
AISNavigation::Transformation3::translationVector
Vector3< T > translationVector
Definition: transformation3.h:258
assert.h
AISNavigation::Quaternion::y
T y
Definition: transformation3.h:238
AISNavigation::Operations3D::ParametersType
Transformation3< T > ParametersType
Definition: transformation3.h:301
AISNavigation::operator-
Vector2< T > operator-(const Vector2< T > &v1, const Vector2< T > &v2)
Definition: transformation2.h:107
dmatrix.h
Pose3
AISNavigation::Quaternion::z
T z
Definition: transformation3.h:238
AISNavigation
Definition: posegraph.h:57
AISNavigation::Operations3D
Definition: transformation3.h:293
AISNavigation::Quaternion::toAngles
Vector3< T > toAngles() const
AISNavigation::Vector3::roll
const T & roll() const
Definition: transformation3.h:132
DVector< T >
AISNavigation::Pose3::x
const T & x() const
Definition: transformation3.h:120
AISNavigation::Transformation3::translation
Vector3< T > translation() const
glm::roll
GLM_FUNC_DECL T roll(detail::tquat< T, P > const &x)
DMatrix
Definition: dmatrix.h:46
AISNavigation::Pose3::roll
const T & roll() const
Definition: transformation3.h:117
AISNavigation::Operations3D::BaseType
T BaseType
Definition: transformation3.h:294
AISNavigation::Transformation3
Definition: transformation3.h:256


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:22