-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.cpp
More file actions
33 lines (26 loc) · 697 Bytes
/
math.cpp
File metadata and controls
33 lines (26 loc) · 697 Bytes
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
#include "math.h"
void decomposeTransformationXYZ(const mat4& m, vec3* translation, vec3* euler) {
// Translation
*translation = vec3(m[3]);
// Euler
euler->y = asin(m[0][2]);
if (cos(euler->y) > 0.0001f) {
euler->z = atan2(-m[0][1], m[0][0]);
euler->x = atan2(-m[1][2], m[2][2]);
}
else {
euler->z = 0.0f;
euler->x = atan2(m[1][0], m[1][1]);
}
}
void decomposeTransformationZYX(const mat4& m, vec3* translation, vec3* euler) {
// Translation
*translation = vec3(m[3]);
// Euler
}
//void createTransformation(vec3 translation, vec3 eulerXYZ) {
// glm::euler
//}
//mat4 eulerToRotationXYZ(vec3 euler) {
// return mat4(vec4(cos(euler.y)*cos(euler.z), cos(euler.x)*sin
//}