CSEngine
Loading...
Searching...
No Matches
CSE::Matrix4< T > Class Template Reference

Public Member Functions

 Matrix4 (const Matrix3< T > &m)
 
 Matrix4 (const T *m)
 
Matrix4 operator* (const Matrix4 &b) const
 
Vector4< T > operator* (const Vector4< T > &b) const
 
Matrix4operator*= (const Matrix4 &b)
 
Matrix4 Transposed () const
 
Matrix3< T > ToMat3 () const
 
const T * Pointer () const
 

Static Public Member Functions

static Matrix4< T > Identity ()
 
static Matrix4< T > Translate (T x, T y, T z)
 
static Matrix4< T > Scale (T s)
 
static Matrix4< T > Scale (T x, T y, T z)
 
static Matrix4< T > RotateZ (T degrees)
 
static Matrix4< T > RotateY (T degrees)
 
static Matrix4< T > RotateX (T degrees)
 
static Matrix4< T > Invert (Matrix4< T > m)
 
static Matrix4< T > Frustum (T tLeft, T tRight, T tBottom, T tTop, T tNear, T tFar)
 
static Matrix4< T > Perspective (T fovy, T aspect, T tNear, T tFar)
 
static Matrix4< T > Ortho (T xMin, T xMax, T yMin, T yMax, T zMin, T zMax)
 
static Matrix4< T > LookAt (const Vector3< T > &eye, const Vector3< T > &target, const Vector3< T > &up)
 

Public Attributes

vec4 x
 
vec4 y
 
vec4 z
 
vec4 w
 

Detailed Description

template<typename T>
class CSE::Matrix4< T >

Definition at line 97 of file Matrix.h.

Constructor & Destructor Documentation

◆ Matrix4() [1/3]

template<typename T >
CSE::Matrix4< T >::Matrix4 ( )
inline

Definition at line 105 of file Matrix.h.

105 {
106 MAT4_XX = 1;
107 MAT4_XY = 0;
108 MAT4_XZ = 0;
109 MAT4_XW = 0;
110 MAT4_YX = 0;
111 MAT4_YY = 1;
112 MAT4_YZ = 0;
113 MAT4_YW = 0;
114 MAT4_ZX = 0;
115 MAT4_ZY = 0;
116 MAT4_ZZ = 1;
117 MAT4_ZW = 0;
118 MAT4_WX = 0;
119 MAT4_WY = 0;
120 MAT4_WZ = 0;
121 MAT4_WW = 1;
122 }

◆ Matrix4() [2/3]

template<typename T >
CSE::Matrix4< T >::Matrix4 ( const Matrix3< T > &  m)
inlineexplicit

Definition at line 124 of file Matrix.h.

124 {
125 MAT4_XX = m.MAT4_XX;
126 MAT4_XY = m.MAT4_XY;
127 MAT4_XZ = m.MAT4_XZ;
128 MAT4_XW = 0;
129 MAT4_YX = m.MAT4_YX;
130 MAT4_YY = m.MAT4_YY;
131 MAT4_YZ = m.MAT4_YZ;
132 MAT4_YW = 0;
133 MAT4_ZX = m.MAT4_ZX;
134 MAT4_ZY = m.MAT4_ZY;
135 MAT4_ZZ = m.MAT4_ZZ;
136 MAT4_ZW = 0;
137 MAT4_WX = 0;
138 MAT4_WY = 0;
139 MAT4_WZ = 0;
140 MAT4_WW = 1;
141 }

◆ Matrix4() [3/3]

template<typename T >
CSE::Matrix4< T >::Matrix4 ( const T *  m)
inlineexplicit

Definition at line 143 of file Matrix.h.

143 {
144 MAT4_XX = m[0];
145 MAT4_XY = m[1];
146 MAT4_XZ = m[2];
147 MAT4_XW = m[3];
148 MAT4_YX = m[4];
149 MAT4_YY = m[5];
150 MAT4_YZ = m[6];
151 MAT4_YW = m[7];
152 MAT4_ZX = m[8];
153 MAT4_ZY = m[9];
154 MAT4_ZZ = m[10];
155 MAT4_ZW = m[11];
156 MAT4_WX = m[12];
157 MAT4_WY = m[13];
158 MAT4_WZ = m[14];
159 MAT4_WW = m[15];
160 }

Member Function Documentation

◆ Frustum()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::Frustum ( tLeft,
tRight,
tBottom,
tTop,
tNear,
tFar 
)
inlinestatic

Definition at line 529 of file Matrix.h.

529 {
530 T a = 2 * tNear / (tRight - tLeft);
531 T b = 2 * tNear / (tTop - tBottom);
532 T c = (tRight + tLeft) / (tRight - tLeft);
533 T d = (tTop + tBottom) / (tTop - tBottom);
534 T e = -(tFar + tNear) / (tFar - tNear);
535 T f = -2 * tFar * tNear / (tFar - tNear);
536 Matrix4 m;
537 m.MAT4_XX = a;
538 m.MAT4_XY = 0;
539 m.MAT4_XZ = 0;
540 m.MAT4_XW = 0;
541 m.MAT4_YX = 0;
542 m.MAT4_YY = b;
543 m.MAT4_YZ = 0;
544 m.MAT4_YW = 0;
545 m.MAT4_ZX = c;
546 m.MAT4_ZY = d;
547 m.MAT4_ZZ = e;
548 m.MAT4_ZW = -1;
549 m.MAT4_WX = 0;
550 m.MAT4_WY = 0;
551 m.MAT4_WZ = f;
552 m.MAT4_WW = 1;
553 return m;
554 }

◆ Identity()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::Identity ( )
inlinestatic

Definition at line 238 of file Matrix.h.

238 {
239 return Matrix4();
240 }

◆ Invert()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::Invert ( Matrix4< T >  m)
inlinestatic

Definition at line 381 of file Matrix.h.

381 {
382 Matrix4<T> inv;
383 T det;
384
385 inv.MAT4_XX = m.MAT4_YY * m.MAT4_ZZ * m.MAT4_WW -
386 m.MAT4_YY * m.MAT4_ZW * m.MAT4_WZ -
387 m.MAT4_ZY * m.MAT4_YZ * m.MAT4_WW +
388 m.MAT4_ZY * m.MAT4_YW * m.MAT4_WZ +
389 m.MAT4_WY * m.MAT4_YZ * m.MAT4_ZW -
390 m.MAT4_WY * m.MAT4_YW * m.MAT4_ZZ;
391
392 inv.MAT4_YX = -m.MAT4_YX * m.MAT4_ZZ * m.MAT4_WW +
393 m.MAT4_YX * m.MAT4_ZW * m.MAT4_WZ +
394 m.MAT4_ZX * m.MAT4_YZ * m.MAT4_WW -
395 m.MAT4_ZX * m.MAT4_YW * m.MAT4_WZ -
396 m.MAT4_WX * m.MAT4_YZ * m.MAT4_ZW +
397 m.MAT4_WX * m.MAT4_YW * m.MAT4_ZZ;
398
399 inv.MAT4_ZX = m.MAT4_YX * m.MAT4_ZY * m.MAT4_WW -
400 m.MAT4_YX * m.MAT4_ZW * m.MAT4_WY -
401 m.MAT4_ZX * m.MAT4_YY * m.MAT4_WW +
402 m.MAT4_ZX * m.MAT4_YW * m.MAT4_WY +
403 m.MAT4_WX * m.MAT4_YY * m.MAT4_ZW -
404 m.MAT4_WX * m.MAT4_YW * m.MAT4_ZY;
405
406 inv.MAT4_WX = -m.MAT4_YX * m.MAT4_ZY * m.MAT4_WZ +
407 m.MAT4_YX * m.MAT4_ZZ * m.MAT4_WY +
408 m.MAT4_ZX * m.MAT4_YY * m.MAT4_WZ -
409 m.MAT4_ZX * m.MAT4_YZ * m.MAT4_WY -
410 m.MAT4_WX * m.MAT4_YY * m.MAT4_ZZ +
411 m.MAT4_WX * m.MAT4_YZ * m.MAT4_ZY;
412
413 inv.MAT4_XY = -m.MAT4_XY * m.MAT4_ZZ * m.MAT4_WW +
414 m.MAT4_XY * m.MAT4_ZW * m.MAT4_WZ +
415 m.MAT4_ZY * m.MAT4_XZ * m.MAT4_WW -
416 m.MAT4_ZY * m.MAT4_XW * m.MAT4_WZ -
417 m.MAT4_WY * m.MAT4_XZ * m.MAT4_ZW +
418 m.MAT4_WY * m.MAT4_XW * m.MAT4_ZZ;
419
420 inv.MAT4_YY = m.MAT4_XX * m.MAT4_ZZ * m.MAT4_WW -
421 m.MAT4_XX * m.MAT4_ZW * m.MAT4_WZ -
422 m.MAT4_ZX * m.MAT4_XZ * m.MAT4_WW +
423 m.MAT4_ZX * m.MAT4_XW * m.MAT4_WZ +
424 m.MAT4_WX * m.MAT4_XZ * m.MAT4_ZW -
425 m.MAT4_WX * m.MAT4_XW * m.MAT4_ZZ;
426
427 inv.MAT4_ZY = -m.MAT4_XX * m.MAT4_ZY * m.MAT4_WW +
428 m.MAT4_XX * m.MAT4_ZW * m.MAT4_WY +
429 m.MAT4_ZX * m.MAT4_XY * m.MAT4_WW -
430 m.MAT4_ZX * m.MAT4_XW * m.MAT4_WY -
431 m.MAT4_WX * m.MAT4_XY * m.MAT4_ZW +
432 m.MAT4_WX * m.MAT4_XW * m.MAT4_ZY;
433
434 inv.MAT4_WY = m.MAT4_XX * m.MAT4_ZY * m.MAT4_WZ -
435 m.MAT4_XX * m.MAT4_ZZ * m.MAT4_WY -
436 m.MAT4_ZX * m.MAT4_XY * m.MAT4_WZ +
437 m.MAT4_ZX * m.MAT4_XZ * m.MAT4_WY +
438 m.MAT4_WX * m.MAT4_XY * m.MAT4_ZZ -
439 m.MAT4_WX * m.MAT4_XZ * m.MAT4_ZY;
440
441 inv.MAT4_XZ = m.MAT4_XY * m.MAT4_YZ * m.MAT4_WW -
442 m.MAT4_XY * m.MAT4_YW * m.MAT4_WZ -
443 m.MAT4_YY * m.MAT4_XZ * m.MAT4_WW +
444 m.MAT4_YY * m.MAT4_XW * m.MAT4_WZ +
445 m.MAT4_WY * m.MAT4_XZ * m.MAT4_YW -
446 m.MAT4_WY * m.MAT4_XW * m.MAT4_YZ;
447
448 inv.MAT4_YZ = -m.MAT4_XX * m.MAT4_YZ * m.MAT4_WW +
449 m.MAT4_XX * m.MAT4_YW * m.MAT4_WZ +
450 m.MAT4_YX * m.MAT4_XZ * m.MAT4_WW -
451 m.MAT4_YX * m.MAT4_XW * m.MAT4_WZ -
452 m.MAT4_WX * m.MAT4_XZ * m.MAT4_YW +
453 m.MAT4_WX * m.MAT4_XW * m.MAT4_YZ;
454
455 inv.MAT4_ZZ = m.MAT4_XX * m.MAT4_YY * m.MAT4_WW -
456 m.MAT4_XX * m.MAT4_YW * m.MAT4_WY -
457 m.MAT4_YX * m.MAT4_XY * m.MAT4_WW +
458 m.MAT4_YX * m.MAT4_XW * m.MAT4_WY +
459 m.MAT4_WX * m.MAT4_XY * m.MAT4_YW -
460 m.MAT4_WX * m.MAT4_XW * m.MAT4_YY;
461
462 inv.MAT4_WZ = -m.MAT4_XX * m.MAT4_YY * m.MAT4_WZ +
463 m.MAT4_XX * m.MAT4_YZ * m.MAT4_WY +
464 m.MAT4_YX * m.MAT4_XY * m.MAT4_WZ -
465 m.MAT4_YX * m.MAT4_XZ * m.MAT4_WY -
466 m.MAT4_WX * m.MAT4_XY * m.MAT4_YZ +
467 m.MAT4_WX * m.MAT4_XZ * m.MAT4_YY;
468
469 inv.MAT4_XW = -m.MAT4_XY * m.MAT4_YZ * m.MAT4_ZW +
470 m.MAT4_XY * m.MAT4_YW * m.MAT4_ZZ +
471 m.MAT4_YY * m.MAT4_XZ * m.MAT4_ZW -
472 m.MAT4_YY * m.MAT4_XW * m.MAT4_ZZ -
473 m.MAT4_ZY * m.MAT4_XZ * m.MAT4_YW +
474 m.MAT4_ZY * m.MAT4_XW * m.MAT4_YZ;
475
476 inv.MAT4_YW = m.MAT4_XX * m.MAT4_YZ * m.MAT4_ZW -
477 m.MAT4_XX * m.MAT4_YW * m.MAT4_ZZ -
478 m.MAT4_YX * m.MAT4_XZ * m.MAT4_ZW +
479 m.MAT4_YX * m.MAT4_XW * m.MAT4_ZZ +
480 m.MAT4_ZX * m.MAT4_XZ * m.MAT4_YW -
481 m.MAT4_ZX * m.MAT4_XW * m.MAT4_YZ;
482
483 inv.MAT4_ZW = -m.MAT4_XX * m.MAT4_YY * m.MAT4_ZW +
484 m.MAT4_XX * m.MAT4_YW * m.MAT4_ZY +
485 m.MAT4_YX * m.MAT4_XY * m.MAT4_ZW -
486 m.MAT4_YX * m.MAT4_XW * m.MAT4_ZY -
487 m.MAT4_ZX * m.MAT4_XY * m.MAT4_YW +
488 m.MAT4_ZX * m.MAT4_XW * m.MAT4_YY;
489
490 inv.MAT4_WW = m.MAT4_XX * m.MAT4_YY * m.MAT4_ZZ -
491 m.MAT4_XX * m.MAT4_YZ * m.MAT4_ZY -
492 m.MAT4_YX * m.MAT4_XY * m.MAT4_ZZ +
493 m.MAT4_YX * m.MAT4_XZ * m.MAT4_ZY +
494 m.MAT4_ZX * m.MAT4_XY * m.MAT4_YZ -
495 m.MAT4_ZX * m.MAT4_XZ * m.MAT4_YY;
496
497 det = m.MAT4_XX * inv.MAT4_XX + m.MAT4_XY * inv.MAT4_YX + m.MAT4_XZ * inv.MAT4_ZX + m.MAT4_XW * inv.MAT4_WX;
498
499 if (det == 0)
500 return Identity();
501
502 det = 1.0 / det;
503
504 Matrix4<T> invOut;
505
506 invOut.MAT4_XX = inv.MAT4_XX * det;
507 invOut.MAT4_XY = inv.MAT4_XY * det;
508 invOut.MAT4_XZ = inv.MAT4_XZ * det;
509 invOut.MAT4_XW = inv.MAT4_XW * det;
510
511 invOut.MAT4_YX = inv.MAT4_YX * det;
512 invOut.MAT4_YY = inv.MAT4_YY * det;
513 invOut.MAT4_YZ = inv.MAT4_YZ * det;
514 invOut.MAT4_YW = inv.MAT4_YW * det;
515
516 invOut.MAT4_ZX = inv.MAT4_ZX * det;
517 invOut.MAT4_ZY = inv.MAT4_ZY * det;
518 invOut.MAT4_ZZ = inv.MAT4_ZZ * det;
519 invOut.MAT4_ZW = inv.MAT4_ZW * det;
520
521 invOut.MAT4_WX = inv.MAT4_WX * det;
522 invOut.MAT4_WY = inv.MAT4_WY * det;
523 invOut.MAT4_WZ = inv.MAT4_WZ * det;
524 invOut.MAT4_WW = inv.MAT4_WW * det;
525
526 return invOut;
527 }

◆ LookAt()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::LookAt ( const Vector3< T > &  eye,
const Vector3< T > &  target,
const Vector3< T > &  up 
)
inlinestatic

Definition at line 596 of file Matrix.h.

598 {
599 Vector3<T> z = (eye - target).Normalized();
600 Vector3<T> x = up.Cross(z).Normalized();
601 Vector3<T> y = z.Cross(x).Normalized();
602
603 Matrix4<T> m;
604
605 m.MAT4_XX = x.x;
606 m.MAT4_XY = x.y;
607 m.MAT4_XZ = x.z;
608 m.MAT4_XW = 0;
609 m.MAT4_YX = y.x;
610 m.MAT4_YY = y.y;
611 m.MAT4_YZ = y.z;
612 m.MAT4_YW = 0;
613 m.MAT4_ZX = z.x;
614 m.MAT4_ZY = z.y;
615 m.MAT4_ZZ = z.z;
616 m.MAT4_ZW = 0;
617 m.MAT4_WX = 0;
618 m.MAT4_WY = 0;
619 m.MAT4_WZ = 0;
620 m.MAT4_WW = 1;
621
622 Vector4<T> eyePrime = m * Vector4<T>(-eye, 1);
623 m = m.Transposed();
624 m.w = eyePrime;
625 return m;
626 }

◆ operator*() [1/2]

template<typename T >
Matrix4 CSE::Matrix4< T >::operator* ( const Matrix4< T > &  b) const
inline

Definition at line 164 of file Matrix.h.

164 {
165 Matrix4 m;
166 m.MAT4_XX = MAT4_XX * b.MAT4_XX + MAT4_XY * b.MAT4_YX + MAT4_XZ * b.MAT4_ZX + MAT4_XW * b.MAT4_WX;
167 m.MAT4_XY = MAT4_XX * b.MAT4_XY + MAT4_XY * b.MAT4_YY + MAT4_XZ * b.MAT4_ZY + MAT4_XW * b.MAT4_WY;
168 m.MAT4_XZ = MAT4_XX * b.MAT4_XZ + MAT4_XY * b.MAT4_YZ + MAT4_XZ * b.MAT4_ZZ + MAT4_XW * b.MAT4_WZ;
169 m.MAT4_XW = MAT4_XX * b.MAT4_XW + MAT4_XY * b.MAT4_YW + MAT4_XZ * b.MAT4_ZW + MAT4_XW * b.MAT4_WW;
170 m.MAT4_YX = MAT4_YX * b.MAT4_XX + MAT4_YY * b.MAT4_YX + MAT4_YZ * b.MAT4_ZX + MAT4_YW * b.MAT4_WX;
171 m.MAT4_YY = MAT4_YX * b.MAT4_XY + MAT4_YY * b.MAT4_YY + MAT4_YZ * b.MAT4_ZY + MAT4_YW * b.MAT4_WY;
172 m.MAT4_YZ = MAT4_YX * b.MAT4_XZ + MAT4_YY * b.MAT4_YZ + MAT4_YZ * b.MAT4_ZZ + MAT4_YW * b.MAT4_WZ;
173 m.MAT4_YW = MAT4_YX * b.MAT4_XW + MAT4_YY * b.MAT4_YW + MAT4_YZ * b.MAT4_ZW + MAT4_YW * b.MAT4_WW;
174 m.MAT4_ZX = MAT4_ZX * b.MAT4_XX + MAT4_ZY * b.MAT4_YX + MAT4_ZZ * b.MAT4_ZX + MAT4_ZW * b.MAT4_WX;
175 m.MAT4_ZY = MAT4_ZX * b.MAT4_XY + MAT4_ZY * b.MAT4_YY + MAT4_ZZ * b.MAT4_ZY + MAT4_ZW * b.MAT4_WY;
176 m.MAT4_ZZ = MAT4_ZX * b.MAT4_XZ + MAT4_ZY * b.MAT4_YZ + MAT4_ZZ * b.MAT4_ZZ + MAT4_ZW * b.MAT4_WZ;
177 m.MAT4_ZW = MAT4_ZX * b.MAT4_XW + MAT4_ZY * b.MAT4_YW + MAT4_ZZ * b.MAT4_ZW + MAT4_ZW * b.MAT4_WW;
178 m.MAT4_WX = MAT4_WX * b.MAT4_XX + MAT4_WY * b.MAT4_YX + MAT4_WZ * b.MAT4_ZX + MAT4_WW * b.MAT4_WX;
179 m.MAT4_WY = MAT4_WX * b.MAT4_XY + MAT4_WY * b.MAT4_YY + MAT4_WZ * b.MAT4_ZY + MAT4_WW * b.MAT4_WY;
180 m.MAT4_WZ = MAT4_WX * b.MAT4_XZ + MAT4_WY * b.MAT4_YZ + MAT4_WZ * b.MAT4_ZZ + MAT4_WW * b.MAT4_WZ;
181 m.MAT4_WW = MAT4_WX * b.MAT4_XW + MAT4_WY * b.MAT4_YW + MAT4_WZ * b.MAT4_ZW + MAT4_WW * b.MAT4_WW;
182 return m;
183 }

◆ operator*() [2/2]

template<typename T >
Vector4< T > CSE::Matrix4< T >::operator* ( const Vector4< T > &  b) const
inline

Definition at line 185 of file Matrix.h.

185 {
186 Vector4<T> v;
187 v.x = MAT4_XX * b.x + MAT4_XY * b.y + MAT4_XZ * b.z + MAT4_XW * b.w;
188 v.y = MAT4_YX * b.x + MAT4_YY * b.y + MAT4_YZ * b.z + MAT4_YW * b.w;
189 v.z = MAT4_ZX * b.x + MAT4_ZY * b.y + MAT4_ZZ * b.z + MAT4_ZW * b.w;
190 v.w = MAT4_WX * b.x + MAT4_WY * b.y + MAT4_WZ * b.z + MAT4_WW * b.w;
191 return v;
192 }

◆ operator*=()

template<typename T >
Matrix4 & CSE::Matrix4< T >::operator*= ( const Matrix4< T > &  b)
inline

Definition at line 194 of file Matrix.h.

194 {
195 Matrix4 m = *this * b;
196 return (*this = m);
197 }

◆ Ortho()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::Ortho ( xMin,
xMax,
yMin,
yMax,
zMin,
zMax 
)
inlinestatic

Definition at line 577 of file Matrix.h.

577 {
578 Matrix4 m;
579
580 T xDiff = xMax - xMin;
581 T yDiff = yMax - yMin;
582 T zDiff = zMax - zMin;
583
584 m.MAT4_XX = 2.0f / xDiff;
585 m.MAT4_YY = 2.0f / yDiff;
586 m.MAT4_ZZ = -2.0f / zDiff;
587
588 m.MAT4_WX = -(xMax + xMin) / xDiff;
589 m.MAT4_WY = -(yMax + yMin) / yDiff;
590 m.MAT4_WZ = -(zMax + zMin) / zDiff;
591 m.MAT4_WW = 1.0f;
592
593 return m;
594 }

◆ Perspective()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::Perspective ( fovy,
aspect,
tNear,
tFar 
)
inlinestatic

Definition at line 556 of file Matrix.h.

556 {
557 Matrix4 m;
558 // radians = (fovy / 2 * Pi / 180)
559 T radians = (T) (fovy * 0.008726644f);
560 T deltaZ = (T) (tFar - tNear);
561 // ref : https://twitter.com/SebAaltonen/status/1571792776802570240?s=20&t=XOYhRlj4BYe_1j8YP3LJJQ
562 T h = 1.0f / tan(radians);
563 T w = h / aspect;
564 T a = -tNear / deltaZ;
565 T b = (tNear * tFar) / deltaZ;
566
567 m.MAT4_XX = w;
568 m.MAT4_YY = h;
569 m.MAT4_ZZ = -a;
570 m.MAT4_ZW = -1.0f;
571 m.MAT4_WZ = -b;
572 m.MAT4_WW = 0.0f;
573
574 return m;
575 }

◆ Pointer()

template<typename T >
const T * CSE::Matrix4< T >::Pointer ( ) const
inline

Definition at line 234 of file Matrix.h.

234 {
235 return &MAT4_XX;
236 }

◆ RotateX()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::RotateX ( degrees)
inlinestatic

Definition at line 356 of file Matrix.h.

356 {
357 T radians = degrees * 3.14159f / 180.0f;
358 T s = std::sin(radians);
359 T c = std::cos(radians);
360
361 Matrix4 m;
362 m.MAT4_XX = 1;
363 m.MAT4_XY = 0;
364 m.MAT4_XZ = 0;
365 m.MAT4_XW = 0;
366 m.MAT4_YX = 0;
367 m.MAT4_YY = c;
368 m.MAT4_YZ = -s;
369 m.MAT4_YW = 0;
370 m.MAT4_ZX = 0;
371 m.MAT4_ZY = s;
372 m.MAT4_ZZ = c;
373 m.MAT4_ZW = 0;
374 m.MAT4_WX = 0;
375 m.MAT4_WY = 0;
376 m.MAT4_WZ = 0;
377 m.MAT4_WW = 1;
378 return m;
379 }

◆ RotateY()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::RotateY ( degrees)
inlinestatic

Definition at line 331 of file Matrix.h.

331 {
332 T radians = degrees * 3.14159f / 180.0f;
333 T s = std::sin(radians);
334 T c = std::cos(radians);
335
336 Matrix4 m;
337 m.MAT4_XX = c;
338 m.MAT4_XY = 0;
339 m.MAT4_XZ = s;
340 m.MAT4_XW = 0;
341 m.MAT4_YX = 0;
342 m.MAT4_YY = 1;
343 m.MAT4_YZ = 0;
344 m.MAT4_YW = 0;
345 m.MAT4_ZX = -s;
346 m.MAT4_ZY = 0;
347 m.MAT4_ZZ = c;
348 m.MAT4_ZW = 0;
349 m.MAT4_WX = 0;
350 m.MAT4_WY = 0;
351 m.MAT4_WZ = 0;
352 m.MAT4_WW = 1;
353 return m;
354 }

◆ RotateZ()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::RotateZ ( degrees)
inlinestatic

Definition at line 305 of file Matrix.h.

305 {
306 T radians = degrees * 3.14159f / 180.0f;
307 T s = std::sin(radians);
308 T c = std::cos(radians);
309
310 Matrix4 m;
311 m.MAT4_XX = c;
312 m.MAT4_XY = -s;
313 m.MAT4_XZ = 0;
314 m.MAT4_XW = 0;
315 m.MAT4_YX = s;
316 m.MAT4_YY = c;
317 m.MAT4_YZ = 0;
318 m.MAT4_YW = 0;
319 m.MAT4_ZX = 0;
320 m.MAT4_ZY = 0;
321 m.MAT4_ZZ = 1;
322 m.MAT4_ZW = 0;
323 m.MAT4_WX = 0;
324 m.MAT4_WY = 0;
325 m.MAT4_WZ = 0;
326 m.MAT4_WW = 1;
327 return m;
328 }

◆ Scale() [1/2]

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::Scale ( s)
inlinestatic

Definition at line 263 of file Matrix.h.

263 {
264 Matrix4 m;
265 m.MAT4_XX = s;
266 m.MAT4_XY = 0;
267 m.MAT4_XZ = 0;
268 m.MAT4_XW = 0;
269 m.MAT4_YX = 0;
270 m.MAT4_YY = s;
271 m.MAT4_YZ = 0;
272 m.MAT4_YW = 0;
273 m.MAT4_ZX = 0;
274 m.MAT4_ZY = 0;
275 m.MAT4_ZZ = s;
276 m.MAT4_ZW = 0;
277 m.MAT4_WX = 0;
278 m.MAT4_WY = 0;
279 m.MAT4_WZ = 0;
280 m.MAT4_WW = 1;
281 return m;
282 }

◆ Scale() [2/2]

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::Scale ( x,
y,
z 
)
inlinestatic

Definition at line 284 of file Matrix.h.

284 {
285 Matrix4 m;
286 m.MAT4_XX = x;
287 m.MAT4_XY = 0;
288 m.MAT4_XZ = 0;
289 m.MAT4_XW = 0;
290 m.MAT4_YX = 0;
291 m.MAT4_YY = y;
292 m.MAT4_YZ = 0;
293 m.MAT4_YW = 0;
294 m.MAT4_ZX = 0;
295 m.MAT4_ZY = 0;
296 m.MAT4_ZZ = z;
297 m.MAT4_ZW = 0;
298 m.MAT4_WX = 0;
299 m.MAT4_WY = 0;
300 m.MAT4_WZ = 0;
301 m.MAT4_WW = 1;
302 return m;
303 }

◆ ToMat3()

template<typename T >
Matrix3< T > CSE::Matrix4< T >::ToMat3 ( ) const
inline

Definition at line 220 of file Matrix.h.

220 {
221 Matrix3<T> m;
222 m.MAT3_XX = MAT4_XX;
223 m.MAT3_YX = MAT4_YX;
224 m.MAT3_ZX = MAT4_ZX;
225 m.MAT3_XY = MAT4_XY;
226 m.MAT3_YY = MAT4_YY;
227 m.MAT3_ZY = MAT4_ZY;
228 m.MAT3_XZ = MAT4_XZ;
229 m.MAT3_YZ = MAT4_YZ;
230 m.MAT3_ZZ = MAT4_ZZ;
231 return m;
232 }

◆ Translate()

template<typename T >
static Matrix4< T > CSE::Matrix4< T >::Translate ( x,
y,
z 
)
inlinestatic

Definition at line 242 of file Matrix.h.

242 {
243 Matrix4 m;
244 m.MAT4_XX = 1;
245 m.MAT4_XY = 0;
246 m.MAT4_XZ = 0;
247 m.MAT4_XW = 0;
248 m.MAT4_YX = 0;
249 m.MAT4_YY = 1;
250 m.MAT4_YZ = 0;
251 m.MAT4_YW = 0;
252 m.MAT4_ZX = 0;
253 m.MAT4_ZY = 0;
254 m.MAT4_ZZ = 1;
255 m.MAT4_ZW = 0;
256 m.MAT4_WX = x;
257 m.MAT4_WY = y;
258 m.MAT4_WZ = z;
259 m.MAT4_WW = 1;
260 return m;
261 }

◆ Transposed()

template<typename T >
Matrix4 CSE::Matrix4< T >::Transposed ( ) const
inline

Definition at line 199 of file Matrix.h.

199 {
200 Matrix4 m;
201 m.MAT4_XX = MAT4_XX;
202 m.MAT4_XY = MAT4_YX;
203 m.MAT4_XZ = MAT4_ZX;
204 m.MAT4_XW = MAT4_WX;
205 m.MAT4_YX = MAT4_XY;
206 m.MAT4_YY = MAT4_YY;
207 m.MAT4_YZ = MAT4_ZY;
208 m.MAT4_YW = MAT4_WY;
209 m.MAT4_ZX = MAT4_XZ;
210 m.MAT4_ZY = MAT4_YZ;
211 m.MAT4_ZZ = MAT4_ZZ;
212 m.MAT4_ZW = MAT4_WZ;
213 m.MAT4_WX = MAT4_XW;
214 m.MAT4_WY = MAT4_YW;
215 m.MAT4_WZ = MAT4_ZW;
216 m.MAT4_WW = MAT4_WW;
217 return m;
218 }

Member Data Documentation

◆ w

template<typename T >
vec4 CSE::Matrix4< T >::w

Definition at line 103 of file Matrix.h.

◆ x

template<typename T >
vec4 CSE::Matrix4< T >::x

Definition at line 100 of file Matrix.h.

◆ y

template<typename T >
vec4 CSE::Matrix4< T >::y

Definition at line 101 of file Matrix.h.

◆ z

template<typename T >
vec4 CSE::Matrix4< T >::z

Definition at line 102 of file Matrix.h.


The documentation for this class was generated from the following file: