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);
73  Quaternion(ValueType x, ValueType y, ValueType z, ValueType w);
74  Quaternion(ValueType *vec, ValueType w);
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 
BaseVector.hpp
lvr2::Matrix4
A 4x4 matrix class implementation for use with the provided vertex types.
Definition: Matrix4.hpp:64
lvr2::Quaternion::X
ValueType X() const
Definition: Quaternion.hpp:91
lvr2::Quaternion::x
ValueType x
Definition: Quaternion.hpp:107
lvr2::Quaternion
Definition: Quaternion.hpp:64
lvr2::Quaternion::ValueType
typename BaseVecT::CoordType ValueType
Definition: Quaternion.hpp:66
lvr2::Quaternion::Quaternion
Quaternion(const Quaternion< BaseVecT > &o)
Definition: Quaternion.hpp:70
lvr2::Quaternion::w
ValueType w
Definition: Quaternion.hpp:107
lvr2::Quaternion::y
ValueType y
Definition: Quaternion.hpp:107
std
Definition: HalfEdge.hpp:124
std::operator<<
std::ostream & operator<<(std::ostream &os, const std::vector< std::string > &vec)
Definition: src/tools/lvr2_largescale_reconstruct/Options.cpp:43
Matrix4.hpp
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::hdf5util::getMatrix
boost::optional< MatrixT > getMatrix(const HighFive::Group &g, const std::string &datasetName)
lvr2::Quaternion::z
ValueType z
Definition: Quaternion.hpp:107
lvr2::Quaternion::W
ValueType W() const
Definition: Quaternion.hpp:94
lvr2::Quaternion::Z
ValueType Z() const
Definition: Quaternion.hpp:93
lvr2::Quaternion::Y
ValueType Y() const
Definition: Quaternion.hpp:92
kfusion::device::operator*
__kf_device__ Vec3f operator*(const Mat3f &m, const Vec3f &v)
Definition: device.hpp:74
Normal.hpp


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 Wed Mar 2 2022 00:37:24