-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuaternion.hpp
More file actions
86 lines (68 loc) · 2.3 KB
/
Quaternion.hpp
File metadata and controls
86 lines (68 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Quaternion.hpp
// Gabriel Ortega
//
//
#pragma once
#ifndef QUATERNION_H
#define QUATERNION_H
#ifndef MATRIX_H
#include "Matrix.hpp"
#endif
#ifdef _WINDLL
#define CGM_DLL __declspec(dllexport)
#else
#define CGM_DLL __declspec(dllimport)
#endif
namespace cliqCity
{
namespace graphicsMath
{
struct CGM_DLL Quaternion
{
union
{
struct
{
float x, y, z, w;
};
struct
{
Vector3 v;
float padding;
};
float pCols[4];
};
static Quaternion rollPitchYaw(const float& roll, const float& pitch, const float& yaw);
static Quaternion angleAxis(const float& angle, const Vector3& axis);
static Quaternion fromMatrix3(const Matrix3& mat);
Quaternion(const float& w, const float& x, const float& y, const float& z) : x(x), y(y), z(z), w(w) {};
Quaternion(const float& w, const Vector3& v) : Quaternion(w, v.x, v.y, v.z) {};
Quaternion(const Quaternion& quaternion) : Quaternion(quaternion.w, quaternion.v) {};
Quaternion(const float& v) : Quaternion(0.0f, 0.0f, 0.0f, 0.0f) {};
Quaternion() : Quaternion(1.0f, 0.0f, 0.0f, 0.0f) {};
Quaternion conjugate() const;
Quaternion inverse() const;
Matrix4 toMatrix4() const;
Matrix3 toMatrix3() const;
Vector3 toEuler() const;
void toAngleAxis(float* outAngle, Vector3* outAxis) const;
Quaternion& operator+=(const Quaternion& rhs);
Quaternion& operator*=(const Quaternion& rhs);
Quaternion& operator*=(const float& rhs);
Quaternion& operator/=(const float& rhs);
Quaternion& operator=(const Quaternion& rhs);
Quaternion operator-();
};
CGM_DLL Quaternion slerp(Quaternion q0, Quaternion q1, const float& t);
CGM_DLL bool operator==(const Quaternion& lhs, const Quaternion& rhs);
CGM_DLL bool operator!=(const Quaternion& lhs, const Quaternion& rhs);
CGM_DLL Quaternion operator+(const Quaternion& lhs, const Quaternion& rhs);
CGM_DLL Quaternion operator*(const Quaternion& lhs, const Quaternion& rhs);
CGM_DLL Vector3 operator*(const Vector3& lhs, const Quaternion& rhs);
CGM_DLL Vector3 operator*(const Quaternion& lhs, const Vector3& rhs);
CGM_DLL Quaternion operator*(const Quaternion& lhs, const float& rhs);
CGM_DLL Quaternion operator*(const float& lhs, const Quaternion& rhs);
CGM_DLL Quaternion operator/(const Quaternion& lhs, const float& rhs);
}
}
#endif