1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3
///////////////////////////////////////////////////////////////////////////////////////////////////
4
// Created : 2005-12-21
5
// Updated : 2007-08-14
6
// Licence : This source is under MIT License
7
// File : glm/gtx/euler_angles.inl
8
///////////////////////////////////////////////////////////////////////////////////////////////////
12
template <typename valType>
13
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
15
valType const & angleX
18
valType cosX = glm::cos(angleX);
19
valType sinX = glm::sin(angleX);
21
return detail::tmat4x4<valType>(
22
valType(1), valType(0), valType(0), valType(0),
23
valType(0), cosX, sinX, valType(0),
24
valType(0),-sinX, cosX, valType(0),
25
valType(0), valType(0), valType(0), valType(1));
28
template <typename valType>
29
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY
31
valType const & angleY
34
valType cosY = glm::cos(angleY);
35
valType sinY = glm::sin(angleY);
37
return detail::tmat4x4<valType>(
38
cosY, valType(0), sinY, valType(0),
39
valType(0), valType(1), valType(0), valType(0),
40
-sinY, valType(0), cosY, valType(0),
41
valType(0), valType(0), valType(0), valType(1));
44
template <typename valType>
45
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ
47
valType const & angleZ
50
valType cosZ = glm::cos(angleZ);
51
valType sinZ = glm::sin(angleZ);
53
return detail::tmat4x4<valType>(
54
cosZ, sinZ, valType(0), valType(0),
55
-sinZ, cosZ, valType(0), valType(0),
56
valType(0), valType(0), valType(1), valType(0),
57
valType(0), valType(0), valType(0), valType(1));
60
template <typename valType>
61
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY
63
valType const & angleX,
64
valType const & angleY
67
valType cosX = glm::cos(angleX);
68
valType sinX = glm::sin(angleX);
69
valType cosY = glm::cos(angleY);
70
valType sinY = glm::sin(angleY);
72
return detail::tmat4x4<valType>(
73
cosY, -sinX * sinY, cosX * sinY, valType(0),
74
valType(0), cosX, sinX, valType(0),
75
-sinY , -sinX * cosY, cosX * cosY, valType(0),
76
valType(0), valType(0), valType(0), valType(1));
79
template <typename valType>
80
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX
82
valType const & angleY,
83
valType const & angleX
86
valType cosX = glm::cos(angleX);
87
valType sinX = glm::sin(angleX);
88
valType cosY = glm::cos(angleY);
89
valType sinY = glm::sin(angleY);
91
return detail::tmat4x4<valType>(
92
cosY, valType(0), sinY, valType(0),
93
-sinX * sinY, cosX, sinX * cosY, valType(0),
94
-cosX * sinY, -sinX, cosX * cosY, valType(0),
95
valType(0), valType(0), valType(0), valType(1));
98
template <typename valType>
99
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXZ
101
valType const & angleX,
102
valType const & angleZ
105
return eulerAngleX(angleX) * eulerAngleZ(angleZ);
108
template <typename valType>
109
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZX
111
valType const & angleZ,
112
valType const & angleX
115
return eulerAngleZ(angleZ) * eulerAngleX(angleX);
118
template <typename valType>
119
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ
122
valType const & pitch,
126
valType tmp_ch = glm::cos(yaw);
127
valType tmp_sh = glm::sin(yaw);
128
valType tmp_cp = glm::cos(pitch);
129
valType tmp_sp = glm::sin(pitch);
130
valType tmp_cb = glm::cos(roll);
131
valType tmp_sb = glm::sin(roll);
133
detail::tmat4x4<valType> Result;
134
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
135
Result[0][1] = tmp_sb * tmp_cp;
136
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
137
Result[0][3] = valType(0);
138
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
139
Result[1][1] = tmp_cb * tmp_cp;
140
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
141
Result[1][3] = valType(0);
142
Result[2][0] = tmp_sh * tmp_cp;
143
Result[2][1] = -tmp_sp;
144
Result[2][2] = tmp_ch * tmp_cp;
145
Result[2][3] = valType(0);
146
Result[3][0] = valType(0);
147
Result[3][1] = valType(0);
148
Result[3][2] = valType(0);
149
Result[3][3] = valType(1);
153
template <typename valType>
154
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll
157
valType const & pitch,
161
valType tmp_ch = glm::cos(yaw);
162
valType tmp_sh = glm::sin(yaw);
163
valType tmp_cp = glm::cos(pitch);
164
valType tmp_sp = glm::sin(pitch);
165
valType tmp_cb = glm::cos(roll);
166
valType tmp_sb = glm::sin(roll);
168
detail::tmat4x4<valType> Result;
169
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
170
Result[0][1] = tmp_sb * tmp_cp;
171
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
172
Result[0][3] = valType(0);
173
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
174
Result[1][1] = tmp_cb * tmp_cp;
175
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
176
Result[1][3] = valType(0);
177
Result[2][0] = tmp_sh * tmp_cp;
178
Result[2][1] = -tmp_sp;
179
Result[2][2] = tmp_ch * tmp_cp;
180
Result[2][3] = valType(0);
181
Result[3][0] = valType(0);
182
Result[3][1] = valType(0);
183
Result[3][2] = valType(0);
184
Result[3][3] = valType(1);
188
template <typename valType>
189
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2
191
valType const & angle
194
valType c = glm::cos(angle);
195
valType s = glm::sin(angle);
197
detail::tmat2x2<valType> Result;
205
template <typename valType>
206
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
208
valType const & angle
211
valType c = glm::cos(angle);
212
valType s = glm::sin(angle);
214
detail::tmat3x3<valType> Result;
227
template <typename valType>
228
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
230
detail::tvec3<valType> const & angles
233
return detail::tmat3x3<valType>(yawPitchRoll(angles.x, angles.y, angles.z));
236
template <typename valType>
237
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> orientate4
239
detail::tvec3<valType> const & angles
242
return yawPitchRoll(angles.z, angles.x, angles.y);