-
Notifications
You must be signed in to change notification settings - Fork 13
/
mathutils.hpp
74 lines (63 loc) · 1.43 KB
/
mathutils.hpp
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
#ifndef MATHUTILS_HPP
#define MATHUTILS_HPP
template <typename T>
T deg2rad(T val) {
return val / 180.0 * 3.1415926;
}
template <typename T>
T rad2deg(T val) {
return val / 3.1415926 * 180.0;
}
#if 0
namespace glm {
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> dEulerAngleX(T const & angleX);
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> dEulerAngleY(T const & angleY);
template <typename T>
GLM_FUNC_DECL tmat4x4<T, defaultp> dEulerAngleZ(T const & angleZ);
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> dEulerAngleX
(
T const & angleX
)
{
T cosX = glm::cos(angleX);
T sinX = glm::sin(angleX);
return tmat4x4<T, defaultp>(
T(1), T(0), T(0), T(0),
T(0),-sinX, cosX, T(0),
T(0),-cosX,-sinX, T(0),
T(0), T(0), T(0), T(1));
}
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> dEulerAngleY
(
T const & angleY
)
{
T cosY = glm::cos(angleY);
T sinY = glm::sin(angleY);
return tmat4x4<T, defaultp>(
-sinY, T(0), -cosY, T(0),
T(0), T(1), T(0), T(0),
cosY, T(0), -sinY, T(0),
T(0), T(0), T(0), T(1));
}
template <typename T>
GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> dEulerAngleZ
(
T const & angleZ
)
{
T cosZ = glm::cos(angleZ);
T sinZ = glm::sin(angleZ);
return tmat4x4<T, defaultp>(
-sinZ, cosZ, T(0), T(0),
-cosZ, -sinZ, T(0), T(0),
T(0), T(0), T(1), T(0),
T(0), T(0), T(0), T(1));
}
} // namespace glm
#endif
#endif // MATHUTILS_HPP