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

« back to all changes in this revision

Viewing changes to 3rd_party/glm/glm/core/type_mat4x4.inl

Merged trunk and fixed issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
///////////////////////////////////////////////////////////////////////////////////
2
 
/// OpenGL Mathematics (glm.g-truc.net)
3
 
///
4
 
/// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5
 
/// Permission is hereby granted, free of charge, to any person obtaining a copy
6
 
/// of this software and associated documentation files (the "Software"), to deal
7
 
/// in the Software without restriction, including without limitation the rights
8
 
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 
/// copies of the Software, and to permit persons to whom the Software is
10
 
/// furnished to do so, subject to the following conditions:
11
 
/// 
12
 
/// The above copyright notice and this permission notice shall be included in
13
 
/// all copies or substantial portions of the Software.
14
 
/// 
15
 
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
 
/// THE SOFTWARE.
22
 
///
23
 
/// @ref core
24
 
/// @file glm/core/type_mat4x4.inl
25
 
/// @date 2005-01-27 / 2011-06-15
26
 
/// @author Christophe Riccio
27
 
///////////////////////////////////////////////////////////////////////////////////
28
 
 
29
 
namespace glm{
30
 
namespace detail
31
 
{
32
 
    template <typename T>
33
 
    GLM_FUNC_QUALIFIER typename tmat4x4<T>::size_type tmat4x4<T>::length() const
34
 
    {
35
 
        return 4;
36
 
    }
37
 
 
38
 
        template <typename T>
39
 
        GLM_FUNC_QUALIFIER typename tmat4x4<T>::size_type tmat4x4<T>::col_size()
40
 
        {
41
 
                return 4;
42
 
        }
43
 
 
44
 
        template <typename T>
45
 
        GLM_FUNC_QUALIFIER typename tmat4x4<T>::size_type tmat4x4<T>::row_size()
46
 
        {
47
 
                return 4;
48
 
        }
49
 
 
50
 
        //////////////////////////////////////
51
 
        // Accesses
52
 
 
53
 
        template <typename T>
54
 
        GLM_FUNC_QUALIFIER typename tmat4x4<T>::col_type & 
55
 
        tmat4x4<T>::operator[]
56
 
        (
57
 
                size_type i
58
 
        )
59
 
        {
60
 
                assert(i < this->length());
61
 
                return this->value[i];
62
 
        }
63
 
 
64
 
        template <typename T>
65
 
        GLM_FUNC_QUALIFIER typename tmat4x4<T>::col_type const & 
66
 
        tmat4x4<T>::operator[]
67
 
        (
68
 
                size_type i
69
 
        ) const
70
 
        {
71
 
                assert(i < this->length());
72
 
                return this->value[i];
73
 
        }
74
 
 
75
 
    //////////////////////////////////////////////////////////////
76
 
    // Constructors
77
 
 
78
 
    template <typename T> 
79
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4()
80
 
    {
81
 
                value_type Zero(0);
82
 
                value_type One(1);
83
 
        this->value[0] = col_type(One, Zero, Zero, Zero);
84
 
        this->value[1] = col_type(Zero, One, Zero, Zero);
85
 
        this->value[2] = col_type(Zero, Zero, One, Zero);
86
 
        this->value[3] = col_type(Zero, Zero, Zero, One);
87
 
    }
88
 
 
89
 
    template <typename T> 
90
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
91
 
        (
92
 
                tmat4x4<T> const & m
93
 
        )
94
 
    {
95
 
        this->value[0] = m.value[0];
96
 
        this->value[1] = m.value[1];
97
 
        this->value[2] = m.value[2];
98
 
        this->value[3] = m.value[3];
99
 
    }
100
 
 
101
 
    template <typename T> 
102
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
103
 
        (
104
 
                ctor
105
 
        )
106
 
    {}
107
 
 
108
 
    template <typename T> 
109
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
110
 
        (
111
 
                value_type const & s
112
 
        )
113
 
    {
114
 
                value_type const Zero(0);
115
 
        this->value[0] = col_type(s, Zero, Zero, Zero);
116
 
        this->value[1] = col_type(Zero, s, Zero, Zero);
117
 
        this->value[2] = col_type(Zero, Zero, s, Zero);
118
 
        this->value[3] = col_type(Zero, Zero, Zero, s);
119
 
    }
120
 
 
121
 
    template <typename T> 
122
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
123
 
    (
124
 
        value_type const & x0, value_type const & y0, value_type const & z0, value_type const & w0,
125
 
        value_type const & x1, value_type const & y1, value_type const & z1, value_type const & w1,
126
 
        value_type const & x2, value_type const & y2, value_type const & z2, value_type const & w2,
127
 
        value_type const & x3, value_type const & y3, value_type const & z3, value_type const & w3
128
 
    )
129
 
    {
130
 
        this->value[0] = col_type(x0, y0, z0, w0);
131
 
        this->value[1] = col_type(x1, y1, z1, w1);
132
 
        this->value[2] = col_type(x2, y2, z2, w2);
133
 
        this->value[3] = col_type(x3, y3, z3, w3);
134
 
    }
135
 
 
136
 
    template <typename T> 
137
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
138
 
    (
139
 
        col_type const & v0, 
140
 
        col_type const & v1, 
141
 
        col_type const & v2,
142
 
        col_type const & v3
143
 
    )
144
 
    {
145
 
        this->value[0] = v0;
146
 
        this->value[1] = v1;
147
 
        this->value[2] = v2;
148
 
        this->value[3] = v3;
149
 
    }
150
 
 
151
 
    template <typename T> 
152
 
    template <typename U> 
153
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
154
 
        (
155
 
                tmat4x4<U> const & m
156
 
        )
157
 
    {
158
 
        this->value[0] = col_type(m[0]);
159
 
        this->value[1] = col_type(m[1]);
160
 
        this->value[2] = col_type(m[2]);
161
 
        this->value[3] = col_type(m[3]);
162
 
        }
163
 
 
164
 
        //////////////////////////////////////
165
 
        // Convertion constructors
166
 
        template <typename T> 
167
 
        template <typename U> 
168
 
        GLM_FUNC_DECL tmat4x4<T>::tmat4x4
169
 
        (
170
 
                U const & s
171
 
        )
172
 
        {
173
 
                GLM_STATIC_ASSERT(detail::type<U>::is_float || std::numeric_limits<U>::is_integer, "*mat4x4 constructor only takes float and integer types");
174
 
 
175
 
                value_type const Zero(0);
176
 
        this->value[0] = tvec4<T>(value_type(s), Zero, Zero, Zero);
177
 
        this->value[1] = tvec4<T>(Zero, value_type(s), Zero, Zero);
178
 
        this->value[2] = tvec4<T>(Zero, Zero, value_type(s), Zero);
179
 
        this->value[3] = tvec4<T>(Zero, Zero, Zero, value_type(s));
180
 
        }
181
 
        
182
 
        template <typename T> 
183
 
        template <
184
 
                typename X1, typename Y1, typename Z1, typename W1, 
185
 
                typename X2, typename Y2, typename Z2, typename W2, 
186
 
                typename X3, typename Y3, typename Z3, typename W3, 
187
 
                typename X4, typename Y4, typename Z4, typename W4>  
188
 
        GLM_FUNC_DECL tmat4x4<T>::tmat4x4
189
 
        (
190
 
                X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, 
191
 
                X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, 
192
 
                X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3, 
193
 
                X4 const & x4, Y4 const & y4, Z4 const & z4, W4 const & w4
194
 
        )               
195
 
        {
196
 
                GLM_STATIC_ASSERT(detail::type<X1>::is_float || std::numeric_limits<X1>::is_integer, "*mat4x4 constructor only takes float and integer types, 1st parameter type invalid.");
197
 
                GLM_STATIC_ASSERT(detail::type<Y1>::is_float || std::numeric_limits<Y1>::is_integer, "*mat4x4 constructor only takes float and integer types, 2nd parameter type invalid.");
198
 
                GLM_STATIC_ASSERT(detail::type<Z1>::is_float || std::numeric_limits<Z1>::is_integer, "*mat4x4 constructor only takes float and integer types, 3rd parameter type invalid.");
199
 
                GLM_STATIC_ASSERT(detail::type<W1>::is_float || std::numeric_limits<W1>::is_integer, "*mat4x4 constructor only takes float and integer types, 4th parameter type invalid.");
200
 
 
201
 
                GLM_STATIC_ASSERT(detail::type<X2>::is_float || std::numeric_limits<X2>::is_integer, "*mat4x4 constructor only takes float and integer types, 5th parameter type invalid.");
202
 
                GLM_STATIC_ASSERT(detail::type<Y2>::is_float || std::numeric_limits<Y2>::is_integer, "*mat4x4 constructor only takes float and integer types, 6th parameter type invalid.");
203
 
                GLM_STATIC_ASSERT(detail::type<Z2>::is_float || std::numeric_limits<Z2>::is_integer, "*mat4x4 constructor only takes float and integer types, 7th parameter type invalid.");
204
 
                GLM_STATIC_ASSERT(detail::type<W2>::is_float || std::numeric_limits<W2>::is_integer, "*mat4x4 constructor only takes float and integer types, 8th parameter type invalid.");
205
 
 
206
 
                GLM_STATIC_ASSERT(detail::type<X3>::is_float || std::numeric_limits<X3>::is_integer, "*mat4x4 constructor only takes float and integer types, 9th parameter type invalid.");
207
 
                GLM_STATIC_ASSERT(detail::type<Y3>::is_float || std::numeric_limits<Y3>::is_integer, "*mat4x4 constructor only takes float and integer types, 10th parameter type invalid.");
208
 
                GLM_STATIC_ASSERT(detail::type<Z3>::is_float || std::numeric_limits<Z3>::is_integer, "*mat4x4 constructor only takes float and integer types, 11th parameter type invalid.");
209
 
                GLM_STATIC_ASSERT(detail::type<W3>::is_float || std::numeric_limits<W3>::is_integer, "*mat4x4 constructor only takes float and integer types, 12th parameter type invalid.");
210
 
 
211
 
                GLM_STATIC_ASSERT(detail::type<X4>::is_float || std::numeric_limits<X4>::is_integer, "*mat4x4 constructor only takes float and integer types, 13th parameter type invalid.");
212
 
                GLM_STATIC_ASSERT(detail::type<Y4>::is_float || std::numeric_limits<Y4>::is_integer, "*mat4x4 constructor only takes float and integer types, 14th parameter type invalid.");
213
 
                GLM_STATIC_ASSERT(detail::type<Z4>::is_float || std::numeric_limits<Z4>::is_integer, "*mat4x4 constructor only takes float and integer types, 15th parameter type invalid.");
214
 
                GLM_STATIC_ASSERT(detail::type<W4>::is_float || std::numeric_limits<W4>::is_integer, "*mat4x4 constructor only takes float and integer types, 16th parameter type invalid.");
215
 
 
216
 
        this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1));
217
 
        this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2), value_type(w2));
218
 
        this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3), value_type(w3));
219
 
                this->value[3] = col_type(value_type(x4), value_type(y4), value_type(z4), value_type(w4));
220
 
        }
221
 
        
222
 
        template <typename T> 
223
 
        template <typename V1, typename V2, typename V3, typename V4> 
224
 
        GLM_FUNC_DECL tmat4x4<T>::tmat4x4
225
 
        (
226
 
                tvec4<V1> const & v1, 
227
 
                tvec4<V2> const & v2, 
228
 
                tvec4<V3> const & v3,
229
 
                tvec4<V4> const & v4
230
 
        )               
231
 
        {
232
 
                GLM_STATIC_ASSERT(detail::type<V1>::is_float || std::numeric_limits<V1>::is_integer, "*mat4x4 constructor only takes float and integer types, 1st parameter type invalid.");
233
 
                GLM_STATIC_ASSERT(detail::type<V2>::is_float || std::numeric_limits<V2>::is_integer, "*mat4x4 constructor only takes float and integer types, 2nd parameter type invalid.");
234
 
                GLM_STATIC_ASSERT(detail::type<V3>::is_float || std::numeric_limits<V3>::is_integer, "*mat4x4 constructor only takes float and integer types, 3rd parameter type invalid.");
235
 
                GLM_STATIC_ASSERT(detail::type<V4>::is_float || std::numeric_limits<V4>::is_integer, "*mat4x4 constructor only takes float and integer types, 4th parameter type invalid.");
236
 
 
237
 
        this->value[0] = col_type(v1);
238
 
        this->value[1] = col_type(v2);
239
 
        this->value[2] = col_type(v3);
240
 
                this->value[3] = col_type(v4);
241
 
        }
242
 
 
243
 
        //////////////////////////////////////
244
 
        // Matrix convertion constructors
245
 
    template <typename T> 
246
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
247
 
        (
248
 
                tmat2x2<T> const & m
249
 
        )
250
 
    {
251
 
        this->value[0] = col_type(m[0], detail::tvec2<T>(0));
252
 
        this->value[1] = col_type(m[1], detail::tvec2<T>(0));
253
 
        this->value[2] = col_type(value_type(0));
254
 
        this->value[3] = col_type(value_type(0), value_type(0), value_type(0), value_type(1));
255
 
    }
256
 
 
257
 
    template <typename T> 
258
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
259
 
        (
260
 
                tmat3x3<T> const & m
261
 
        )
262
 
    {
263
 
        this->value[0] = col_type(m[0], value_type(0));
264
 
        this->value[1] = col_type(m[1], value_type(0));
265
 
        this->value[2] = col_type(m[2], value_type(0));
266
 
        this->value[3] = col_type(value_type(0), value_type(0), value_type(0), value_type(1));
267
 
    }
268
 
 
269
 
        template <typename T> 
270
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
271
 
        (
272
 
                tmat2x3<T> const & m
273
 
        )
274
 
    {
275
 
        this->value[0] = col_type(m[0], value_type(0));
276
 
        this->value[1] = col_type(m[1], value_type(0));
277
 
        this->value[2] = col_type(value_type(0));
278
 
        this->value[3] = col_type(value_type(0), value_type(0), value_type(0), value_type(1));
279
 
    }
280
 
 
281
 
    template <typename T> 
282
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
283
 
        (
284
 
                tmat3x2<T> const & m
285
 
        )
286
 
    {
287
 
        this->value[0] = col_type(m[0], detail::tvec2<T>(0));
288
 
        this->value[1] = col_type(m[1], detail::tvec2<T>(0));
289
 
        this->value[2] = col_type(m[2], detail::tvec2<T>(0));
290
 
        this->value[3] = col_type(value_type(0), value_type(0), value_type(0), value_type(1));
291
 
    }
292
 
 
293
 
    template <typename T> 
294
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
295
 
        (
296
 
                tmat2x4<T> const & m
297
 
        )
298
 
    {
299
 
        this->value[0] = m[0];
300
 
        this->value[1] = m[1];
301
 
        this->value[2] = col_type(T(0));
302
 
        this->value[3] = col_type(T(0), T(0), T(0), T(1));
303
 
    }
304
 
 
305
 
    template <typename T> 
306
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
307
 
        (
308
 
                tmat4x2<T> const & m
309
 
        )
310
 
    {
311
 
        this->value[0] = col_type(m[0], detail::tvec2<T>(0));
312
 
        this->value[1] = col_type(m[1], detail::tvec2<T>(0));
313
 
        this->value[2] = col_type(T(0));
314
 
        this->value[3] = col_type(T(0), T(0), T(0), T(1));
315
 
    }
316
 
 
317
 
    template <typename T> 
318
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
319
 
        (
320
 
                tmat3x4<T> const & m
321
 
        )
322
 
    {
323
 
        this->value[0] = m[0];
324
 
        this->value[1] = m[1];
325
 
        this->value[2] = m[2];
326
 
        this->value[3] = col_type(T(0), T(0), T(0), T(1));
327
 
    }
328
 
 
329
 
    template <typename T> 
330
 
    GLM_FUNC_QUALIFIER tmat4x4<T>::tmat4x4
331
 
        (
332
 
                tmat4x3<T> const & m
333
 
        )
334
 
    {
335
 
        this->value[0] = col_type(m[0], T(0));
336
 
        this->value[1] = col_type(m[1], T(0));
337
 
        this->value[2] = col_type(m[2], T(0));
338
 
        this->value[3] = col_type(m[3], T(1));
339
 
    }
340
 
 
341
 
    //////////////////////////////////////////////////////////////
342
 
    // Operators
343
 
 
344
 
    template <typename T> 
345
 
    GLM_FUNC_QUALIFIER tmat4x4<T>& tmat4x4<T>::operator= 
346
 
        (
347
 
                tmat4x4<T> const & m
348
 
        )
349
 
    {
350
 
        //memcpy could be faster
351
 
        //memcpy(&this->value, &m.value, 16 * sizeof(valType));
352
 
        this->value[0] = m[0];
353
 
        this->value[1] = m[1];
354
 
        this->value[2] = m[2];
355
 
        this->value[3] = m[3];
356
 
        return *this;
357
 
    }
358
 
 
359
 
    template <typename T> 
360
 
        template <typename U> 
361
 
    GLM_FUNC_QUALIFIER tmat4x4<T>& tmat4x4<T>::operator= 
362
 
        (
363
 
                tmat4x4<U> const & m
364
 
        )
365
 
    {
366
 
        //memcpy could be faster
367
 
        //memcpy(&this->value, &m.value, 16 * sizeof(valType));
368
 
        this->value[0] = m[0];
369
 
        this->value[1] = m[1];
370
 
        this->value[2] = m[2];
371
 
        this->value[3] = m[3];
372
 
        return *this;
373
 
    }
374
 
 
375
 
    template <typename T> 
376
 
        template <typename U> 
377
 
    GLM_FUNC_QUALIFIER tmat4x4<T>& tmat4x4<T>::operator+= 
378
 
        (
379
 
                U const & s
380
 
        )
381
 
    {
382
 
        this->value[0] += s;
383
 
        this->value[1] += s;
384
 
        this->value[2] += s;
385
 
        this->value[3] += s;
386
 
        return *this;
387
 
    }
388
 
 
389
 
    template <typename T> 
390
 
        template <typename U> 
391
 
    GLM_FUNC_QUALIFIER tmat4x4<T>& tmat4x4<T>::operator+= 
392
 
        (
393
 
                tmat4x4<U> const & m
394
 
        )
395
 
    {
396
 
        this->value[0] += m[0];
397
 
        this->value[1] += m[1];
398
 
        this->value[2] += m[2];
399
 
        this->value[3] += m[3];
400
 
        return *this;
401
 
    }
402
 
 
403
 
    template <typename T> 
404
 
        template <typename U> 
405
 
    GLM_FUNC_QUALIFIER tmat4x4<T> & tmat4x4<T>::operator-= 
406
 
        (
407
 
                U const & s
408
 
        )
409
 
    {
410
 
        this->value[0] -= s;
411
 
        this->value[1] -= s;
412
 
        this->value[2] -= s;
413
 
        this->value[3] -= s;
414
 
        return *this;
415
 
    }
416
 
 
417
 
    template <typename T> 
418
 
        template <typename U>
419
 
    GLM_FUNC_QUALIFIER tmat4x4<T> & tmat4x4<T>::operator-= 
420
 
        (
421
 
                tmat4x4<U> const & m
422
 
        )
423
 
    {
424
 
        this->value[0] -= m[0];
425
 
        this->value[1] -= m[1];
426
 
        this->value[2] -= m[2];
427
 
        this->value[3] -= m[3];
428
 
        return *this;
429
 
    }
430
 
 
431
 
    template <typename T> 
432
 
        template <typename U>
433
 
    GLM_FUNC_QUALIFIER tmat4x4<T> & tmat4x4<T>::operator*= 
434
 
        (
435
 
                U const & s
436
 
        )
437
 
    {
438
 
        this->value[0] *= s;
439
 
        this->value[1] *= s;
440
 
        this->value[2] *= s;
441
 
        this->value[3] *= s;
442
 
        return *this;
443
 
    }
444
 
 
445
 
    template <typename T> 
446
 
        template <typename U>
447
 
    GLM_FUNC_QUALIFIER tmat4x4<T> & tmat4x4<T>::operator*= 
448
 
        (
449
 
                tmat4x4<U> const & m
450
 
        )
451
 
    {
452
 
        return (*this = *this * m);
453
 
    }
454
 
 
455
 
    template <typename T> 
456
 
        template <typename U>
457
 
    GLM_FUNC_QUALIFIER tmat4x4<T> & tmat4x4<T>::operator/= 
458
 
        (
459
 
                U const & s
460
 
        )
461
 
    {
462
 
        this->value[0] /= s;
463
 
        this->value[1] /= s;
464
 
        this->value[2] /= s;
465
 
        this->value[3] /= s;
466
 
        return *this;
467
 
    }
468
 
 
469
 
    template <typename T> 
470
 
        template <typename U>
471
 
    GLM_FUNC_QUALIFIER tmat4x4<T> & tmat4x4<T>::operator/= 
472
 
        (
473
 
                tmat4x4<U> const & m
474
 
        )
475
 
    {
476
 
        return (*this = *this / m);
477
 
    }
478
 
 
479
 
    template <typename T> 
480
 
    GLM_FUNC_QUALIFIER tmat4x4<T> & tmat4x4<T>::operator++ ()
481
 
    {
482
 
        ++this->value[0];
483
 
        ++this->value[1];
484
 
        ++this->value[2];
485
 
        ++this->value[3];
486
 
        return *this;
487
 
    }
488
 
 
489
 
    template <typename T> 
490
 
    GLM_FUNC_QUALIFIER tmat4x4<T> & tmat4x4<T>::operator-- ()
491
 
    {
492
 
        --this->value[0];
493
 
        --this->value[1];
494
 
        --this->value[2];
495
 
        --this->value[3];
496
 
        return *this;
497
 
    }
498
 
 
499
 
    template <typename T> 
500
 
    GLM_FUNC_QUALIFIER tmat4x4<T> tmat4x4<T>::_inverse() const
501
 
    {
502
 
        // Calculate all mat2 determinants
503
 
        value_type SubFactor00 = this->value[2][2] * this->value[3][3] - this->value[3][2] * this->value[2][3];
504
 
        value_type SubFactor01 = this->value[2][1] * this->value[3][3] - this->value[3][1] * this->value[2][3];
505
 
        value_type SubFactor02 = this->value[2][1] * this->value[3][2] - this->value[3][1] * this->value[2][2];
506
 
        value_type SubFactor03 = this->value[2][0] * this->value[3][3] - this->value[3][0] * this->value[2][3];
507
 
        value_type SubFactor04 = this->value[2][0] * this->value[3][2] - this->value[3][0] * this->value[2][2];
508
 
        value_type SubFactor05 = this->value[2][0] * this->value[3][1] - this->value[3][0] * this->value[2][1];
509
 
        value_type SubFactor06 = this->value[1][2] * this->value[3][3] - this->value[3][2] * this->value[1][3];
510
 
        value_type SubFactor07 = this->value[1][1] * this->value[3][3] - this->value[3][1] * this->value[1][3];
511
 
        value_type SubFactor08 = this->value[1][1] * this->value[3][2] - this->value[3][1] * this->value[1][2];
512
 
        value_type SubFactor09 = this->value[1][0] * this->value[3][3] - this->value[3][0] * this->value[1][3];
513
 
        value_type SubFactor10 = this->value[1][0] * this->value[3][2] - this->value[3][0] * this->value[1][2];
514
 
        value_type SubFactor11 = this->value[1][1] * this->value[3][3] - this->value[3][1] * this->value[1][3];
515
 
        value_type SubFactor12 = this->value[1][0] * this->value[3][1] - this->value[3][0] * this->value[1][1];
516
 
        value_type SubFactor13 = this->value[1][2] * this->value[2][3] - this->value[2][2] * this->value[1][3];
517
 
        value_type SubFactor14 = this->value[1][1] * this->value[2][3] - this->value[2][1] * this->value[1][3];
518
 
        value_type SubFactor15 = this->value[1][1] * this->value[2][2] - this->value[2][1] * this->value[1][2];
519
 
        value_type SubFactor16 = this->value[1][0] * this->value[2][3] - this->value[2][0] * this->value[1][3];
520
 
        value_type SubFactor17 = this->value[1][0] * this->value[2][2] - this->value[2][0] * this->value[1][2];
521
 
        value_type SubFactor18 = this->value[1][0] * this->value[2][1] - this->value[2][0] * this->value[1][1];
522
 
/*
523
 
        tmat4x4<T> Inverse(
524
 
            + (this->value[1][1] * SubFactor00 - this->value[1][2] * SubFactor01 + this->value[1][3] * SubFactor02),
525
 
            - (this->value[1][0] * SubFactor00 - this->value[1][2] * SubFactor03 + this->value[1][3] * SubFactor04),
526
 
            + (this->value[1][0] * SubFactor01 - this->value[1][1] * SubFactor03 + this->value[1][3] * SubFactor05),
527
 
            - (this->value[1][0] * SubFactor02 - this->value[1][1] * SubFactor04 + this->value[1][2] * SubFactor05),
528
 
 
529
 
            - (this->value[0][1] * SubFactor00 - this->value[0][2] * SubFactor01 + this->value[0][3] * SubFactor02),
530
 
            + (this->value[0][0] * SubFactor00 - this->value[0][2] * SubFactor03 + this->value[0][3] * SubFactor04),
531
 
            - (this->value[0][0] * SubFactor01 - this->value[0][1] * SubFactor03 + this->value[0][3] * SubFactor05),
532
 
            + (this->value[0][0] * SubFactor02 - this->value[0][1] * SubFactor04 + this->value[0][2] * SubFactor05),
533
 
 
534
 
            + (this->value[0][1] * SubFactor06 - this->value[0][2] * SubFactor07 + this->value[0][3] * SubFactor08),
535
 
            - (this->value[0][0] * SubFactor06 - this->value[0][2] * SubFactor09 + this->value[0][3] * SubFactor10),
536
 
            + (this->value[0][0] * SubFactor11 - this->value[0][1] * SubFactor09 + this->value[0][3] * SubFactor12),
537
 
            - (this->value[0][0] * SubFactor08 - this->value[0][1] * SubFactor10 + this->value[0][2] * SubFactor12),
538
 
 
539
 
            - (this->value[0][1] * SubFactor13 - this->value[0][2] * SubFactor14 + this->value[0][3] * SubFactor15),
540
 
            + (this->value[0][0] * SubFactor13 - this->value[0][2] * SubFactor16 + this->value[0][3] * SubFactor17),
541
 
            - (this->value[0][0] * SubFactor14 - this->value[0][1] * SubFactor16 + this->value[0][3] * SubFactor18),
542
 
            + (this->value[0][0] * SubFactor15 - this->value[0][1] * SubFactor17 + this->value[0][2] * SubFactor18));
543
 
*/
544
 
        tmat4x4<T> Inverse(
545
 
            + this->value[1][1] * SubFactor00 - this->value[1][2] * SubFactor01 + this->value[1][3] * SubFactor02,
546
 
            - this->value[1][0] * SubFactor00 + this->value[1][2] * SubFactor03 - this->value[1][3] * SubFactor04,
547
 
            + this->value[1][0] * SubFactor01 - this->value[1][1] * SubFactor03 + this->value[1][3] * SubFactor05,
548
 
            - this->value[1][0] * SubFactor02 + this->value[1][1] * SubFactor04 - this->value[1][2] * SubFactor05,
549
 
 
550
 
            - this->value[0][1] * SubFactor00 + this->value[0][2] * SubFactor01 - this->value[0][3] * SubFactor02,
551
 
            + this->value[0][0] * SubFactor00 - this->value[0][2] * SubFactor03 + this->value[0][3] * SubFactor04,
552
 
            - this->value[0][0] * SubFactor01 + this->value[0][1] * SubFactor03 - this->value[0][3] * SubFactor05,
553
 
            + this->value[0][0] * SubFactor02 - this->value[0][1] * SubFactor04 + this->value[0][2] * SubFactor05,
554
 
 
555
 
            + this->value[0][1] * SubFactor06 - this->value[0][2] * SubFactor07 + this->value[0][3] * SubFactor08,
556
 
            - this->value[0][0] * SubFactor06 + this->value[0][2] * SubFactor09 - this->value[0][3] * SubFactor10,
557
 
            + this->value[0][0] * SubFactor11 - this->value[0][1] * SubFactor09 + this->value[0][3] * SubFactor12,
558
 
            - this->value[0][0] * SubFactor08 + this->value[0][1] * SubFactor10 - this->value[0][2] * SubFactor12,
559
 
 
560
 
            - this->value[0][1] * SubFactor13 + this->value[0][2] * SubFactor14 - this->value[0][3] * SubFactor15,
561
 
            + this->value[0][0] * SubFactor13 - this->value[0][2] * SubFactor16 + this->value[0][3] * SubFactor17,
562
 
            - this->value[0][0] * SubFactor14 + this->value[0][1] * SubFactor16 - this->value[0][3] * SubFactor18,
563
 
            + this->value[0][0] * SubFactor15 - this->value[0][1] * SubFactor17 + this->value[0][2] * SubFactor18);
564
 
 
565
 
        value_type Determinant = 
566
 
                        + this->value[0][0] * Inverse[0][0] 
567
 
                        + this->value[0][1] * Inverse[1][0] 
568
 
                        + this->value[0][2] * Inverse[2][0] 
569
 
                        + this->value[0][3] * Inverse[3][0];
570
 
 
571
 
        Inverse /= Determinant;
572
 
        return Inverse;
573
 
    }
574
 
 
575
 
        // Binary operators
576
 
    template <typename T> 
577
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator+ 
578
 
        (
579
 
                tmat4x4<T> const & m, 
580
 
                typename tmat4x4<T>::value_type const & s
581
 
        )
582
 
    {
583
 
        return tmat4x4<T>(
584
 
            m[0] + s,
585
 
            m[1] + s,
586
 
            m[2] + s,
587
 
            m[3] + s);
588
 
    }
589
 
 
590
 
    template <typename T> 
591
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator+ 
592
 
        (
593
 
                typename tmat4x4<T>::value_type const & s, 
594
 
                tmat4x4<T> const & m
595
 
        )
596
 
    {
597
 
        return tmat4x4<T>(
598
 
            m[0] + s,
599
 
            m[1] + s,
600
 
            m[2] + s,
601
 
            m[3] + s);
602
 
    }
603
 
 
604
 
    template <typename T> 
605
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator+ 
606
 
        (
607
 
                tmat4x4<T> const & m1, 
608
 
                tmat4x4<T> const & m2
609
 
        )
610
 
    {
611
 
        return tmat4x4<T>(
612
 
            m1[0] + m2[0],
613
 
            m1[1] + m2[1],
614
 
            m1[2] + m2[2],
615
 
            m1[3] + m2[3]);
616
 
    }
617
 
    
618
 
    template <typename T> 
619
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator- 
620
 
        (
621
 
                tmat4x4<T> const & m, 
622
 
                typename tmat4x4<T>::value_type const & s
623
 
        )
624
 
    {
625
 
        return tmat4x4<T>(
626
 
            m[0] - s,
627
 
            m[1] - s,
628
 
            m[2] - s,
629
 
            m[3] - s);
630
 
    }
631
 
 
632
 
    template <typename T> 
633
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator- 
634
 
        (
635
 
                typename tmat4x4<T>::value_type const & s, 
636
 
                tmat4x4<T> const & m
637
 
        )
638
 
    {
639
 
        return tmat4x4<T>(
640
 
            s - m[0],
641
 
            s - m[1],
642
 
            s - m[2],
643
 
            s - m[3]);
644
 
    }
645
 
 
646
 
    template <typename T> 
647
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator- 
648
 
        (
649
 
                tmat4x4<T> const & m1, 
650
 
                tmat4x4<T> const & m2
651
 
        )
652
 
    {
653
 
        return tmat4x4<T>(
654
 
            m1[0] - m2[0],
655
 
            m1[1] - m2[1],
656
 
            m1[2] - m2[2],
657
 
            m1[3] - m2[3]);
658
 
    }
659
 
 
660
 
    template <typename T> 
661
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator* 
662
 
        (
663
 
                tmat4x4<T> const & m, 
664
 
                typename tmat4x4<T>::value_type const  & s
665
 
        )
666
 
    {
667
 
        return tmat4x4<T>(
668
 
            m[0] * s,
669
 
            m[1] * s,
670
 
            m[2] * s,
671
 
            m[3] * s);
672
 
    }
673
 
 
674
 
    template <typename T> 
675
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator* 
676
 
        (
677
 
                typename tmat4x4<T>::value_type const & s, 
678
 
                tmat4x4<T> const & m
679
 
        )
680
 
    {
681
 
        return tmat4x4<T>(
682
 
            m[0] * s,
683
 
            m[1] * s,
684
 
            m[2] * s,
685
 
            m[3] * s);
686
 
    }
687
 
 
688
 
    template <typename T> 
689
 
    GLM_FUNC_QUALIFIER typename tmat4x4<T>::col_type operator* 
690
 
        (
691
 
                tmat4x4<T> const & m, 
692
 
                typename tmat4x4<T>::row_type const & v
693
 
        )
694
 
    {
695
 
        return typename tmat4x4<T>::col_type(
696
 
            m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w,
697
 
            m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w,
698
 
            m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z + m[3][2] * v.w,
699
 
            m[0][3] * v.x + m[1][3] * v.y + m[2][3] * v.z + m[3][3] * v.w);
700
 
    }
701
 
 
702
 
    template <typename T> 
703
 
    GLM_FUNC_QUALIFIER typename tmat4x4<T>::row_type operator* 
704
 
        (
705
 
                typename tmat4x4<T>::col_type const & v, 
706
 
                tmat4x4<T> const & m
707
 
        )
708
 
    {
709
 
        return typename tmat4x4<T>::row_type(
710
 
            m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] * v.w,
711
 
            m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] * v.w,
712
 
            m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] * v.w,
713
 
            m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] * v.w);
714
 
    }
715
 
 
716
 
        template <typename T>
717
 
        GLM_FUNC_QUALIFIER tmat2x4<T> operator* 
718
 
        (
719
 
                tmat4x4<T> const & m1, 
720
 
                tmat2x4<T> const & m2
721
 
        )
722
 
        {
723
 
                return tmat2x4<T>(
724
 
                        m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1] + m1[2][0] * m2[0][2] + m1[3][0] * m2[0][3],
725
 
                        m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1] + m1[2][1] * m2[0][2] + m1[3][1] * m2[0][3],
726
 
                        m1[0][2] * m2[0][0] + m1[1][2] * m2[0][1] + m1[2][2] * m2[0][2] + m1[3][2] * m2[0][3],
727
 
                        m1[0][3] * m2[0][0] + m1[1][3] * m2[0][1] + m1[2][3] * m2[0][2] + m1[3][3] * m2[0][3],
728
 
                        m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1] + m1[2][0] * m2[1][2] + m1[3][0] * m2[1][3],
729
 
                        m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1] + m1[2][1] * m2[1][2] + m1[3][1] * m2[1][3],
730
 
                        m1[0][2] * m2[1][0] + m1[1][2] * m2[1][1] + m1[2][2] * m2[1][2] + m1[3][2] * m2[1][3],
731
 
                        m1[0][3] * m2[1][0] + m1[1][3] * m2[1][1] + m1[2][3] * m2[1][2] + m1[3][3] * m2[1][3]);
732
 
        }
733
 
 
734
 
        template <typename T>
735
 
        GLM_FUNC_QUALIFIER tmat3x4<T> operator* 
736
 
        (
737
 
                tmat4x4<T> const & m1, 
738
 
                tmat3x4<T> const & m2
739
 
        )
740
 
        {
741
 
                return tmat3x4<T>(
742
 
                        m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1] + m1[2][0] * m2[0][2] + m1[3][0] * m2[0][3],
743
 
                        m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1] + m1[2][1] * m2[0][2] + m1[3][1] * m2[0][3],
744
 
                        m1[0][2] * m2[0][0] + m1[1][2] * m2[0][1] + m1[2][2] * m2[0][2] + m1[3][2] * m2[0][3],
745
 
                        m1[0][3] * m2[0][0] + m1[1][3] * m2[0][1] + m1[2][3] * m2[0][2] + m1[3][3] * m2[0][3],
746
 
                        m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1] + m1[2][0] * m2[1][2] + m1[3][0] * m2[1][3],
747
 
                        m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1] + m1[2][1] * m2[1][2] + m1[3][1] * m2[1][3],
748
 
                        m1[0][2] * m2[1][0] + m1[1][2] * m2[1][1] + m1[2][2] * m2[1][2] + m1[3][2] * m2[1][3],
749
 
                        m1[0][3] * m2[1][0] + m1[1][3] * m2[1][1] + m1[2][3] * m2[1][2] + m1[3][3] * m2[1][3],
750
 
                        m1[0][0] * m2[2][0] + m1[1][0] * m2[2][1] + m1[2][0] * m2[2][2] + m1[3][0] * m2[2][3],
751
 
                        m1[0][1] * m2[2][0] + m1[1][1] * m2[2][1] + m1[2][1] * m2[2][2] + m1[3][1] * m2[2][3],
752
 
                        m1[0][2] * m2[2][0] + m1[1][2] * m2[2][1] + m1[2][2] * m2[2][2] + m1[3][2] * m2[2][3],
753
 
                        m1[0][3] * m2[2][0] + m1[1][3] * m2[2][1] + m1[2][3] * m2[2][2] + m1[3][3] * m2[2][3]);
754
 
        }
755
 
 
756
 
    template <typename T> 
757
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator* 
758
 
        (
759
 
                tmat4x4<T> const & m1, 
760
 
                tmat4x4<T> const & m2
761
 
        )
762
 
    {
763
 
                typename tmat4x4<T>::col_type const SrcA0 = m1[0];
764
 
                typename tmat4x4<T>::col_type const SrcA1 = m1[1];
765
 
                typename tmat4x4<T>::col_type const SrcA2 = m1[2];
766
 
                typename tmat4x4<T>::col_type const SrcA3 = m1[3];
767
 
 
768
 
                typename tmat4x4<T>::col_type const SrcB0 = m2[0];
769
 
                typename tmat4x4<T>::col_type const SrcB1 = m2[1];
770
 
                typename tmat4x4<T>::col_type const SrcB2 = m2[2];
771
 
                typename tmat4x4<T>::col_type const SrcB3 = m2[3];
772
 
 
773
 
        tmat4x4<T> Result(tmat4x4<T>::null);
774
 
                Result[0] = SrcA0 * SrcB0[0] + SrcA1 * SrcB0[1] + SrcA2 * SrcB0[2] + SrcA3 * SrcB0[3];
775
 
                Result[1] = SrcA0 * SrcB1[0] + SrcA1 * SrcB1[1] + SrcA2 * SrcB1[2] + SrcA3 * SrcB1[3];
776
 
                Result[2] = SrcA0 * SrcB2[0] + SrcA1 * SrcB2[1] + SrcA2 * SrcB2[2] + SrcA3 * SrcB2[3];
777
 
                Result[3] = SrcA0 * SrcB3[0] + SrcA1 * SrcB3[1] + SrcA2 * SrcB3[2] + SrcA3 * SrcB3[3];
778
 
        return Result;
779
 
    }
780
 
 
781
 
    template <typename T> 
782
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator/ 
783
 
        (
784
 
                tmat4x4<T> const & m, 
785
 
                typename tmat4x4<T>::value_type const & s
786
 
        )
787
 
    {
788
 
        return tmat4x4<T>(
789
 
            m[0] / s,
790
 
            m[1] / s,
791
 
            m[2] / s,
792
 
            m[3] / s);
793
 
    }
794
 
 
795
 
    template <typename T> 
796
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator/ 
797
 
        (
798
 
                typename tmat4x4<T>::value_type const & s, 
799
 
                tmat4x4<T> const & m
800
 
        )
801
 
    {
802
 
        return tmat4x4<T>(
803
 
            s / m[0],
804
 
            s / m[1],
805
 
            s / m[2],
806
 
            s / m[3]);
807
 
    }
808
 
 
809
 
    template <typename T> 
810
 
    GLM_FUNC_QUALIFIER typename tmat4x4<T>::col_type operator/ 
811
 
        (
812
 
                tmat4x4<T> const & m, 
813
 
                typename tmat4x4<T>::row_type const & v
814
 
        )
815
 
    {
816
 
        return m._inverse() * v;
817
 
    }
818
 
 
819
 
    template <typename T> 
820
 
    GLM_FUNC_QUALIFIER typename tmat4x4<T>::row_type operator/ 
821
 
        (
822
 
                typename tmat4x4<T>::col_type const & v, 
823
 
                tmat4x4<T> const & m
824
 
        )
825
 
    {
826
 
        return v * m._inverse();
827
 
    }
828
 
 
829
 
    template <typename T> 
830
 
    GLM_FUNC_QUALIFIER tmat4x4<T> operator/ 
831
 
        (
832
 
                tmat4x4<T> const & m1, 
833
 
                tmat4x4<T> const & m2
834
 
        )
835
 
    {
836
 
        return m1 * m2._inverse();
837
 
    }
838
 
 
839
 
        // Unary constant operators
840
 
    template <typename T> 
841
 
    GLM_FUNC_QUALIFIER tmat4x4<T> const operator- 
842
 
        (
843
 
                tmat4x4<T> const & m
844
 
        )
845
 
    {
846
 
        return tmat4x4<T>(
847
 
            -m[0], 
848
 
            -m[1],
849
 
            -m[2],
850
 
            -m[3]);
851
 
    }
852
 
 
853
 
    template <typename T> 
854
 
    GLM_FUNC_QUALIFIER tmat4x4<T> const operator++ 
855
 
        (
856
 
                tmat4x4<T> const & m, 
857
 
                int
858
 
        ) 
859
 
    {
860
 
        return tmat4x4<T>(
861
 
            m[0] + typename tmat4x4<T>::value_type(1),
862
 
            m[1] + typename tmat4x4<T>::value_type(1),
863
 
            m[2] + typename tmat4x4<T>::value_type(1),
864
 
            m[3] + typename tmat4x4<T>::value_type(1));
865
 
    }
866
 
 
867
 
    template <typename T> 
868
 
    GLM_FUNC_QUALIFIER tmat4x4<T> const operator-- 
869
 
        (
870
 
                tmat4x4<T> const & m, 
871
 
                int
872
 
        ) 
873
 
    {
874
 
        return tmat4x4<T>(
875
 
            m[0] - typename tmat4x4<T>::value_type(1),
876
 
            m[1] - typename tmat4x4<T>::value_type(1),
877
 
            m[2] - typename tmat4x4<T>::value_type(1),
878
 
            m[3] - typename tmat4x4<T>::value_type(1));
879
 
    }
880
 
 
881
 
        //////////////////////////////////////
882
 
        // Boolean operators
883
 
 
884
 
        template <typename T> 
885
 
        GLM_FUNC_QUALIFIER bool operator==
886
 
        (
887
 
                tmat4x4<T> const & m1, 
888
 
                tmat4x4<T> const & m2
889
 
        )
890
 
        {
891
 
                return (m1[0] == m2[0]) && (m1[1] == m2[1]) && (m1[2] == m2[2]) && (m1[3] == m2[3]);
892
 
        }
893
 
 
894
 
        template <typename T> 
895
 
        GLM_FUNC_QUALIFIER bool operator!=
896
 
        (
897
 
                tmat4x4<T> const & m1, 
898
 
                tmat4x4<T> const & m2
899
 
        )
900
 
        {
901
 
                return (m1[0] != m2[0]) || (m1[1] != m2[1]) || (m1[2] != m2[2]) || (m1[3] != m2[3]);
902
 
        }
903
 
 
904
 
} //namespace detail
905
 
} //namespace glm