~mir-team/mir/in-process-egl+input-conglomeration

« back to all changes in this revision

Viewing changes to 3rd_party/glm/glm/gtx/euler_angles.inl

Merged trunk and fixed issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
///////////////////////////////////////////////////////////////////////////////////////////////////
9
 
 
10
 
namespace glm
11
 
{
12
 
        template <typename valType> 
13
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
14
 
        (
15
 
                valType const & angleX
16
 
        )
17
 
        {
18
 
                valType cosX = glm::cos(angleX);
19
 
                valType sinX = glm::sin(angleX);
20
 
        
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));
26
 
        }
27
 
 
28
 
        template <typename valType> 
29
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY
30
 
        (
31
 
                valType const & angleY
32
 
        )
33
 
        {
34
 
                valType cosY = glm::cos(angleY);
35
 
                valType sinY = glm::sin(angleY);
36
 
 
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));
42
 
        }
43
 
 
44
 
        template <typename valType> 
45
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ
46
 
        (
47
 
                valType const & angleZ
48
 
        )
49
 
        {
50
 
                valType cosZ = glm::cos(angleZ); 
51
 
                valType sinZ = glm::sin(angleZ);
52
 
 
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));
58
 
        }
59
 
 
60
 
        template <typename valType> 
61
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY
62
 
        (
63
 
                valType const & angleX, 
64
 
                valType const & angleY
65
 
        )
66
 
        {
67
 
                valType cosX = glm::cos(angleX);
68
 
                valType sinX = glm::sin(angleX);
69
 
                valType cosY = glm::cos(angleY);
70
 
                valType sinY = glm::sin(angleY);
71
 
 
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));
77
 
        }
78
 
 
79
 
        template <typename valType> 
80
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX
81
 
        (
82
 
                valType const & angleY, 
83
 
                valType const & angleX
84
 
        )
85
 
        {
86
 
                valType cosX = glm::cos(angleX); 
87
 
                valType sinX = glm::sin(angleX); 
88
 
                valType cosY = glm::cos(angleY); 
89
 
                valType sinY = glm::sin(angleY);
90
 
 
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));
96
 
        }
97
 
 
98
 
        template <typename valType> 
99
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXZ
100
 
        (
101
 
                valType const & angleX, 
102
 
                valType const & angleZ
103
 
        )
104
 
        {
105
 
                return eulerAngleX(angleX) * eulerAngleZ(angleZ);
106
 
        }
107
 
 
108
 
        template <typename valType> 
109
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZX
110
 
        (
111
 
                valType const & angleZ, 
112
 
                valType const & angleX
113
 
        )
114
 
        {
115
 
                return eulerAngleZ(angleZ) * eulerAngleX(angleX);
116
 
        }
117
 
 
118
 
        template <typename valType> 
119
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ
120
 
        (
121
 
                valType const & yaw, 
122
 
                valType const & pitch, 
123
 
                valType const & roll
124
 
        )
125
 
        {
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);
132
 
 
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);
150
 
                return Result;
151
 
        }
152
 
 
153
 
        template <typename valType> 
154
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll
155
 
        (
156
 
                valType const & yaw, 
157
 
                valType const & pitch, 
158
 
                valType const & roll
159
 
        )
160
 
        {
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);
167
 
 
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);
185
 
                return Result;
186
 
        }
187
 
 
188
 
        template <typename valType>
189
 
        GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2
190
 
        (
191
 
                valType const & angle
192
 
        )
193
 
        {
194
 
                valType c = glm::cos(angle);
195
 
                valType s = glm::sin(angle);
196
 
 
197
 
                detail::tmat2x2<valType> Result;
198
 
                Result[0][0] = c;
199
 
                Result[0][1] = s;
200
 
                Result[1][0] = -s;
201
 
                Result[1][1] = c;
202
 
                return Result;
203
 
        }
204
 
 
205
 
        template <typename valType>
206
 
        GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
207
 
        (
208
 
                valType const & angle
209
 
        )
210
 
        {
211
 
                valType c = glm::cos(angle);
212
 
                valType s = glm::sin(angle);
213
 
 
214
 
                detail::tmat3x3<valType> Result;
215
 
                Result[0][0] = c;
216
 
                Result[0][1] = s;
217
 
                Result[0][2] = 0.0f;
218
 
                Result[1][0] = -s;
219
 
                Result[1][1] = c;
220
 
                Result[1][2] = 0.0f;
221
 
                Result[2][0] = 0.0f;
222
 
                Result[2][1] = 0.0f;
223
 
                Result[2][2] = 1.0f;
224
 
                return Result;
225
 
        }
226
 
 
227
 
        template <typename valType>
228
 
        GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
229
 
        (
230
 
                detail::tvec3<valType> const & angles
231
 
        )
232
 
        {
233
 
                return detail::tmat3x3<valType>(yawPitchRoll(angles.x, angles.y, angles.z));
234
 
        }
235
 
 
236
 
        template <typename valType>
237
 
        GLM_FUNC_QUALIFIER detail::tmat4x4<valType> orientate4
238
 
        (
239
 
                detail::tvec3<valType> const & angles
240
 
        )
241
 
        {
242
 
                return yawPitchRoll(angles.z, angles.x, angles.y);
243
 
        }
244
 
}//namespace glm