Quaternion.hpp
Go to the documentation of this file.
1 
28 /*
29  * Quatrnion.hpp
30  *
31  * @date 29.08.2008
32  * @author Thomas Wiemann (twiemann@uos.de)
33  */
34 
36 //
37 // Author: Thomas Wiemann
38 // Date: 29.08.2008
39 //
40 // Quaternion representation of rotations.
41 //
42 // Based on: http://gpwiki.org/index.php/OpenGL:Tutorials:Using_Quaternions_to_represent_rotation
43 //
45 
46 
47 #ifndef __GLQUATERNION_H__
48 #define __GLQUATERNION_H__
49 
50 #include "math.h"
51 
54 #include "lvr2/geometry/Normal.hpp"
55 
56 #include <iostream>
57 
58 using namespace std;
59 
60 namespace lvr2
61 {
62 
63 template<typename BaseVecT>
64 class Quaternion{
65 
66  using ValueType = typename BaseVecT::CoordType;
67 
68 public:
69  Quaternion();
70  Quaternion(const Quaternion<BaseVecT> &o){ x = o.x; y = o.y; z = o.z; w = o.w;};
71  Quaternion(BaseVecT vec, ValueType angle);
72  Quaternion(ValueType pitch, ValueType yaw, ValueType roll);
75 
76  ~Quaternion();
77 
78  void normalize();
79  void fromAxis(ValueType *vec, ValueType angle);
80  void fromAxis(BaseVecT axis, ValueType angle);
81  void fromEuler(ValueType pitch, ValueType yaw, ValueType roll);
82 
83  void getAxisAngle(BaseVecT *axis, ValueType *angle);
84  void getMatrix(ValueType *m);
85 
86  void printMatrix();
87  void printDebugInfo();
88 
89  BaseVecT toEuler();
90 
91  ValueType X() const {return x;};
92  ValueType Y() const {return y;};
93  ValueType Z() const {return z;};
94  ValueType W() const {return w;};
95 
96  Quaternion<BaseVecT> getConjugate();
97  Quaternion<BaseVecT> copy();
98 
100 
101  BaseVecT operator* (BaseVecT vec);
102  BaseVecT operator* (BaseVecT *vec);
103 
105 
106 private:
107  ValueType w, x, y, z;
108 
109 };
110 
111 } // namespace lvr2
112 
113 template<typename BaseVecT>
114 inline ostream& operator<<(ostream& os, const lvr2::Quaternion<BaseVecT> q){
115 
116  return os << "Quaternion: " << q.W() << " " << q.X() << " " << q.Y() << " " << q.Z() << endl;
117 
118 }
119 
120 #include "Quaternion.tcc"
121 
122 #endif
123 
ValueType X() const
Definition: Quaternion.hpp:91
ValueType Y() const
Definition: Quaternion.hpp:92
A 4x4 matrix class implementation for use with the provided vertex types.
Definition: Matrix4.hpp:64
Quaternion(const Quaternion< BaseVecT > &o)
Definition: Quaternion.hpp:70
ValueType Z() const
Definition: Quaternion.hpp:93
ValueType W() const
Definition: Quaternion.hpp:94
boost::optional< MatrixT > getMatrix(const HighFive::Group &g, const std::string &datasetName)
__kf_device__ Vec3f operator*(const Mat3f &m, const Vec3f &v)
Definition: device.hpp:74
typename BaseVecT::CoordType ValueType
Definition: Quaternion.hpp:66


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:09