-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathQuaternion.h
78 lines (60 loc) · 1.24 KB
/
Quaternion.h
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
#pragma once
#include "f4se/NITypes.h"
#include "utils.h"
#include "matrix.h"
namespace F4VRBody {
class Quaternion {
public:
Quaternion() {
// default to identity
w = 1.0;
x = 0.0;
y = 0.0;
z = 0.0;
}
Quaternion(float X, float Y, float Z, float W) : w(W), x(X), y(Y), z(Z) { };
Quaternion(float real, NiPoint3 v) {
w = real;
x = v.x;
y = v.y;
z = v.z;
}
~Quaternion() {};
void makeIdentity() {
w = 1.0;
x = 0.0;
y = 0.0;
z = 0.0;
}
Quaternion get() {
Quaternion q;
q.w = w;
q.x = x;
q.y = y;
q.z = z;
return q;
}
Quaternion conjugate();
float getMag();
Quaternion getNorm();
void normalize();
double dot(Quaternion q);
void setAngleAxis(float angle, NiPoint3 axis);
float getAngleFromAxisAngle(Quaternion target);
Matrix44 getRot();
void fromRot(NiMatrix43 rot);
void slerp(float interp, Quaternion target);
void vec2vec(NiPoint3 v1, NiPoint3 v2);
//overload
Quaternion operator* (const float& f) const;
Quaternion operator* (const Quaternion& qr) const;
Quaternion& operator*= (const float& f);
Quaternion& operator*= (const Quaternion& qr);
void operator= (const Quaternion& q);
public:
float w;
float x;
float y;
float z;
};
}