Engine
quaternion.h
1 #ifndef QUATERNION_H
2 #define QUATERNION_H
3 #include <Eigen/Dense>
4 #include <vector3G.h>
5 #include <iostream>
9 struct Quaternion
10 {
11  GLfloat r; // real part of quaternion
12  Vector3Gf im; // imaginary part of quaternion
13 
14  Quaternion();
15 
20  Quaternion(GLfloat angle, Vector3Gf axis);
21 
25  Quaternion(Vector3Gf axis);
26 
30  GLfloat squaredNorm() const;
31 
35  GLfloat norm() const;
36 
40  void normalize();
41 
45  Quaternion conjugate() const;
46 
50  Quaternion inv() const;
51 
52  Eigen::Matrix<GLfloat,3,3> toRotationMatrix();
53 
54  Quaternion operator+(const Quaternion& q) const;
55 
56  Quaternion operator-(const Quaternion& q) const;
57 
58  Quaternion operator*(const Quaternion& q) const;
59 
60  friend Quaternion operator*(const Quaternion q, const GLfloat& s);
61 
62  friend Quaternion operator*(const GLfloat& s,const Quaternion q);
63 
64  Quaternion operator/(const GLfloat& s) const;
65 
66  Quaternion operator/(const Quaternion& q) const;
67 
68  friend std::ostream& operator<<(std::ostream& os, const Quaternion& q);
69 };
70 
71 #endif
data structure reprenseting a Quaternion.
Definition: quaternion.h:9
GLfloat norm() const
Definition: quaternion.cpp:27
Quaternion conjugate() const
Definition: quaternion.cpp:37
void normalize()
Definition: quaternion.cpp:32
GLfloat squaredNorm() const
Definition: quaternion.cpp:22
Quaternion inv() const
Definition: quaternion.cpp:45