5#ifndef __IRR_MATRIX_H_INCLUDED__
6#define __IRR_MATRIX_H_INCLUDED__
24#if defined( USE_MATRIX_TEST_DEBUG )
28 MatrixTest () : ID(0), Calls(0) {}
33static MatrixTest MTest;
57 EM4CONST_INVERSE_TRANSPOSED
71#if defined ( USE_MATRIX_TEST )
72 definitelyIdentityMatrix=
false;
74 return M[ (row << 2) + col ];
78 const T&
operator()(
const s32 row,
const s32 col)
const {
return M[ (row << 2) + col]; }
83#if defined ( USE_MATRIX_TEST )
84 definitelyIdentityMatrix=
false;
102#if defined ( USE_MATRIX_TEST )
103 definitelyIdentityMatrix=
false;
404#if defined ( USE_MATRIX_TEST )
406 mutable u32 definitelyIdentityMatrix;
408#if defined ( USE_MATRIX_TEST_DEBUG )
418#if defined ( USE_MATRIX_TEST )
419 : definitelyIdentityMatrix(BIT_UNTESTED)
421#if defined ( USE_MATRIX_TEST_DEBUG )
422 ,id ( MTest.ID++), calls ( 0 )
425 switch ( constructor )
427 case EM4CONST_NOTHING:
430 case EM4CONST_IDENTITY:
431 case EM4CONST_INVERSE:
441#if defined ( USE_MATRIX_TEST )
442 : definitelyIdentityMatrix(BIT_UNTESTED)
444#if defined ( USE_MATRIX_TEST_DEBUG )
445 ,id ( MTest.ID++), calls ( 0 )
448 switch ( constructor )
450 case EM4CONST_IDENTITY:
453 case EM4CONST_NOTHING:
458 case EM4CONST_TRANSPOSED:
461 case EM4CONST_INVERSE:
463 memset(M, 0, 16*
sizeof(T));
465 case EM4CONST_INVERSE_TRANSPOSED:
467 memset(M, 0, 16*
sizeof(T));
480 temp[0] = M[0]+other[0];
481 temp[1] = M[1]+other[1];
482 temp[2] = M[2]+other[2];
483 temp[3] = M[3]+other[3];
484 temp[4] = M[4]+other[4];
485 temp[5] = M[5]+other[5];
486 temp[6] = M[6]+other[6];
487 temp[7] = M[7]+other[7];
488 temp[8] = M[8]+other[8];
489 temp[9] = M[9]+other[9];
490 temp[10] = M[10]+other[10];
491 temp[11] = M[11]+other[11];
492 temp[12] = M[12]+other[12];
493 temp[13] = M[13]+other[13];
494 temp[14] = M[14]+other[14];
495 temp[15] = M[15]+other[15];
530 temp[0] = M[0]-other[0];
531 temp[1] = M[1]-other[1];
532 temp[2] = M[2]-other[2];
533 temp[3] = M[3]-other[3];
534 temp[4] = M[4]-other[4];
535 temp[5] = M[5]-other[5];
536 temp[6] = M[6]-other[6];
537 temp[7] = M[7]-other[7];
538 temp[8] = M[8]-other[8];
539 temp[9] = M[9]-other[9];
540 temp[10] = M[10]-other[10];
541 temp[11] = M[11]-other[11];
542 temp[12] = M[12]-other[12];
543 temp[13] = M[13]-other[13];
544 temp[14] = M[14]-other[14];
545 temp[15] = M[15]-other[15];
580 temp[0] = M[0]*scalar;
581 temp[1] = M[1]*scalar;
582 temp[2] = M[2]*scalar;
583 temp[3] = M[3]*scalar;
584 temp[4] = M[4]*scalar;
585 temp[5] = M[5]*scalar;
586 temp[6] = M[6]*scalar;
587 temp[7] = M[7]*scalar;
588 temp[8] = M[8]*scalar;
589 temp[9] = M[9]*scalar;
590 temp[10] = M[10]*scalar;
591 temp[11] = M[11]*scalar;
592 temp[12] = M[12]*scalar;
593 temp[13] = M[13]*scalar;
594 temp[14] = M[14]*scalar;
595 temp[15] = M[15]*scalar;
628#if defined ( USE_MATRIX_TEST )
634 return (*
this = other);
655 const T *m1 = other_a.M;
656 const T *m2 = other_b.M;
658 M[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3];
659 M[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3];
660 M[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3];
661 M[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3];
663 M[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7];
664 M[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7];
665 M[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7];
666 M[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7];
668 M[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11];
669 M[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11];
670 M[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11];
671 M[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11];
673 M[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15];
674 M[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15];
675 M[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15];
676 M[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15];
677#if defined ( USE_MATRIX_TEST )
678 definitelyIdentityMatrix=
false;
690#if defined ( USE_MATRIX_TEST )
692 return (*
this = other_b);
695 return (*
this = other_a);
707#if defined ( USE_MATRIX_TEST )
711 if ( m2.isIdentity() )
718 const T *m2 = matrix2.M;
721 m3[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3];
722 m3[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3];
723 m3[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3];
724 m3[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3];
726 m3[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7];
727 m3[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7];
728 m3[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7];
729 m3[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7];
731 m3[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11];
732 m3[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11];
733 m3[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11];
734 m3[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11];
736 m3[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15];
737 m3[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15];
738 m3[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15];
739 m3[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15];
756 M[12] = translation.
X;
757 M[13] = translation.
Y;
758 M[14] = translation.
Z;
759#if defined ( USE_MATRIX_TEST )
760 definitelyIdentityMatrix=
false;
768 M[12] = -translation.
X;
769 M[13] = -translation.
Y;
770 M[14] = -translation.
Z;
771#if defined ( USE_MATRIX_TEST )
772 definitelyIdentityMatrix=
false;
783#if defined ( USE_MATRIX_TEST )
784 definitelyIdentityMatrix=
false;
810 return vector3d<T>(sqrtf(M[0] * M[0] + M[1] * M[1] + M[2] * M[2]),
811 sqrtf(M[4] * M[4] + M[5] * M[5] + M[6] * M[6]),
812 sqrtf(M[8] * M[8] + M[9] * M[9] + M[10] * M[10]));
830 const f64 cr = cos( rotation.
X );
831 const f64 sr = sin( rotation.
X );
832 const f64 cp = cos( rotation.
Y );
833 const f64 sp = sin( rotation.
Y );
834 const f64 cy = cos( rotation.
Z );
835 const f64 sy = sin( rotation.
Z );
841 const f64 srsp = sr*sp;
842 const f64 crsp = cr*sp;
844 M[4] = (T)( srsp*cy-cr*sy );
845 M[5] = (T)( srsp*sy+cr*cy );
848 M[8] = (T)( crsp*cy+sr*sy );
849 M[9] = (T)( crsp*sy-sr*cy );
850 M[10] = (T)( cr*cp );
851#if defined ( USE_MATRIX_TEST )
852 definitelyIdentityMatrix=
false;
868 if (scale.
Y<0 && scale.
Z<0)
873 else if (scale.
X<0 && scale.
Z<0)
878 else if (scale.
X<0 && scale.
Y<0)
883 const core::vector3d<f64> invScale(core::reciprocal(scale.
X),core::reciprocal(scale.
Y),core::reciprocal(scale.
Z));
886 const f64 C = cos(Y);
889 f64 rotx, roty, X, Z;
893 const f64 invC = core::reciprocal(C);
894 rotx = mat[10] * invC * invScale.
Z;
895 roty = mat[6] * invC * invScale.
Y;
897 rotx = mat[0] * invC * invScale.
X;
898 roty = mat[1] * invC * invScale.
X;
904 rotx = mat[5] * invScale.
Y;
905 roty = -mat[4] * invScale.
Y;
910 if (X < 0.0) X += 360.0;
911 if (Y < 0.0) Y += 360.0;
912 if (Z < 0.0) Z += 360.0;
922 f64 cr = cos( rotation.
X );
923 f64 sr = sin( rotation.
X );
924 f64 cp = cos( rotation.
Y );
925 f64 sp = sin( rotation.
Y );
926 f64 cy = cos( rotation.
Z );
927 f64 sy = sin( rotation.
Z );
936 M[1] = (T)( srsp*cy-cr*sy );
937 M[5] = (T)( srsp*sy+cr*cy );
940 M[2] = (T)( crsp*cy+sr*sy );
941 M[6] = (T)( crsp*sy-sr*cy );
942 M[10] = (T)( cr*cp );
943#if defined ( USE_MATRIX_TEST )
944 definitelyIdentityMatrix=
false;
953 const f64 c = cos(angle);
954 const f64 s = sin(angle);
955 const f64 t = 1.0 - c;
957 const f64 tx = t * axis.
X;
958 const f64 ty = t * axis.
Y;
959 const f64 tz = t * axis.
Z;
961 const f64 sx = s * axis.
X;
962 const f64 sy = s * axis.
Y;
963 const f64 sz = s * axis.
Z;
965 M[0] = (T)(tx * axis.
X + c);
966 M[1] = (T)(tx * axis.
Y + sz);
967 M[2] = (T)(tx * axis.
Z - sy);
969 M[4] = (T)(ty * axis.
X - sz);
970 M[5] = (T)(ty * axis.
Y + c);
971 M[6] = (T)(ty * axis.
Z + sx);
973 M[8] = (T)(tz * axis.
X + sy);
974 M[9] = (T)(tz * axis.
Y - sx);
975 M[10] = (T)(tz * axis.
Z + c);
977#if defined ( USE_MATRIX_TEST )
978 definitelyIdentityMatrix=
false;
989 memset(M, 0, 16*
sizeof(T));
990 M[0] = M[5] = M[10] = M[15] = (T)1;
991#if defined ( USE_MATRIX_TEST )
992 definitelyIdentityMatrix=
true;
1005#if defined ( USE_MATRIX_TEST )
1006 if (definitelyIdentityMatrix)
1032#if defined ( USE_MATRIX_TEST )
1033 definitelyIdentityMatrix=
true;
1043 T dp=M[0] * M[4 ] + M[1] * M[5 ] + M[2 ] * M[6 ] + M[3 ] * M[7 ];
1046 dp = M[0] * M[8 ] + M[1] * M[9 ] + M[2 ] * M[10] + M[3 ] * M[11];
1049 dp = M[0] * M[12] + M[1] * M[13] + M[2 ] * M[14] + M[3 ] * M[15];
1052 dp = M[4] * M[8 ] + M[5] * M[9 ] + M[6 ] * M[10] + M[7 ] * M[11];
1055 dp = M[4] * M[12] + M[5] * M[13] + M[6 ] * M[14] + M[7 ] * M[15];
1058 dp = M[8] * M[12] + M[9] * M[13] + M[10] * M[14] + M[11] * M[15];
1072#if defined ( USE_MATRIX_TEST )
1073 if (definitelyIdentityMatrix)
1076 if(
IR(M[0])!=F32_VALUE_1)
return false;
1077 if(
IR(M[1])!=0)
return false;
1078 if(
IR(M[2])!=0)
return false;
1079 if(
IR(M[3])!=0)
return false;
1081 if(
IR(M[4])!=0)
return false;
1082 if(
IR(M[5])!=F32_VALUE_1)
return false;
1083 if(
IR(M[6])!=0)
return false;
1084 if(
IR(M[7])!=0)
return false;
1086 if(
IR(M[8])!=0)
return false;
1087 if(
IR(M[9])!=0)
return false;
1088 if(
IR(M[10])!=F32_VALUE_1)
return false;
1089 if(
IR(M[11])!=0)
return false;
1091 if(
IR(M[12])!=0)
return false;
1092 if(
IR(M[13])!=0)
return false;
1093 if(
IR(M[13])!=0)
return false;
1094 if(
IR(M[15])!=F32_VALUE_1)
return false;
1096#if defined ( USE_MATRIX_TEST )
1097 definitelyIdentityMatrix=
true;
1107 vect.
X = tmp.
X*M[0] + tmp.
Y*M[4] + tmp.
Z*M[8];
1108 vect.
Y = tmp.
X*M[1] + tmp.
Y*M[5] + tmp.
Z*M[9];
1109 vect.
Z = tmp.
X*M[2] + tmp.
Y*M[6] + tmp.
Z*M[10];
1116 out.X = in.
X*M[0] + in.
Y*M[4] + in.
Z*M[8];
1117 out.Y = in.
X*M[1] + in.
Y*M[5] + in.
Z*M[9];
1118 out.Z = in.
X*M[2] + in.
Y*M[6] + in.
Z*M[10];
1125 out[0] = in.
X*M[0] + in.
Y*M[4] + in.
Z*M[8];
1126 out[1] = in.
X*M[1] + in.
Y*M[5] + in.
Z*M[9];
1127 out[2] = in.
X*M[2] + in.
Y*M[6] + in.
Z*M[10];
1134 vect.
X = tmp.
X*M[0] + tmp.
Y*M[1] + tmp.
Z*M[2];
1135 vect.
Y = tmp.
X*M[4] + tmp.
Y*M[5] + tmp.
Z*M[6];
1136 vect.
Z = tmp.
X*M[8] + tmp.
Y*M[9] + tmp.
Z*M[10];
1144 vector[0] = vect.
X*M[0] + vect.
Y*M[4] + vect.
Z*M[8] + M[12];
1145 vector[1] = vect.
X*M[1] + vect.
Y*M[5] + vect.
Z*M[9] + M[13];
1146 vector[2] = vect.
X*M[2] + vect.
Y*M[6] + vect.
Z*M[10] + M[14];
1156 out.X = in.
X*M[0] + in.
Y*M[4] + in.
Z*M[8] + M[12];
1157 out.Y = in.
X*M[1] + in.
Y*M[5] + in.
Z*M[9] + M[13];
1158 out.Z = in.
X*M[2] + in.
Y*M[6] + in.
Z*M[10] + M[14];
1165 out[0] = in.
X*M[0] + in.
Y*M[4] + in.
Z*M[8] + M[12];
1166 out[1] = in.
X*M[1] + in.
Y*M[5] + in.
Z*M[9] + M[13];
1167 out[2] = in.
X*M[2] + in.
Y*M[6] + in.
Z*M[10] + M[14];
1168 out[3] = in.
X*M[3] + in.
Y*M[7] + in.
Z*M[11] + M[15];
1174 out[0] = in[0]*M[0] + in[1]*M[4] + in[2]*M[8] + M[12];
1175 out[1] = in[0]*M[1] + in[1]*M[5] + in[2]*M[9] + M[13];
1176 out[2] = in[0]*M[2] + in[1]*M[6] + in[2]*M[10] + M[14];
1189 CMatrix4<T> transposedInverse(*
this, EM4CONST_INVERSE_TRANSPOSED);
1193 plane.setPlane(member, normal);
1208#if defined ( USE_MATRIX_TEST )
1222#if defined ( USE_MATRIX_TEST )
1233 Bmin[0] = Bmax[0] = M[12];
1234 Bmin[1] = Bmax[1] = M[13];
1235 Bmin[2] = Bmax[2] = M[14];
1237 for (
u32 i = 0; i < 3; ++i)
1239 for (
u32 j = 0; j < 3; ++j)
1241 float t = M[(j << 2) + i];
1243 const f32 a = t * Amin[j];
1244 const f32 b = t * Amax[j];
1286 matrix[0] = M[0]*mat[0] + M[4]*mat[1] + M[8]*mat[2] + M[12]*mat[3];
1287 matrix[1] = M[1]*mat[0] + M[5]*mat[1] + M[9]*mat[2] + M[13]*mat[3];
1288 matrix[2] = M[2]*mat[0] + M[6]*mat[1] + M[10]*mat[2] + M[14]*mat[3];
1289 matrix[3] = M[3]*mat[0] + M[7]*mat[1] + M[11]*mat[2] + M[15]*mat[3];
1295 vect.
X = vect.
X-M[12];
1296 vect.
Y = vect.
Y-M[13];
1297 vect.
Z = vect.
Z-M[14];
1303 vect.
X = vect.
X+M[12];
1304 vect.
Y = vect.
Y+M[13];
1305 vect.
Z = vect.
Z+M[14];
1316#if defined ( USE_MATRIX_TEST )
1324 #define m(x,y) M[(x << 2) + y]
1325 #define out(x,y) out.M[(x << 2) + y]
1327 f32 d = (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) -
1328 (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) +
1329 (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1)) +
1330 (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1)) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) -
1331 (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) +
1332 (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0));
1337 d = core::reciprocal ( d );
1339 out(0, 0) = d * (m(1, 1) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) +
1340 m(1, 2) * (m(2, 3) * m(3, 1) - m(2, 1) * m(3, 3)) +
1341 m(1, 3) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1)));
1342 out(0, 1) = d * (m(2, 1) * (m(0, 2) * m(3, 3) - m(0, 3) * m(3, 2)) +
1343 m(2, 2) * (m(0, 3) * m(3, 1) - m(0, 1) * m(3, 3)) +
1344 m(2, 3) * (m(0, 1) * m(3, 2) - m(0, 2) * m(3, 1)));
1345 out(0, 2) = d * (m(3, 1) * (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) +
1346 m(3, 2) * (m(0, 3) * m(1, 1) - m(0, 1) * m(1, 3)) +
1347 m(3, 3) * (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1)));
1348 out(0, 3) = d * (m(0, 1) * (m(1, 3) * m(2, 2) - m(1, 2) * m(2, 3)) +
1349 m(0, 2) * (m(1, 1) * m(2, 3) - m(1, 3) * m(2, 1)) +
1350 m(0, 3) * (m(1, 2) * m(2, 1) - m(1, 1) * m(2, 2)));
1351 out(1, 0) = d * (m(1, 2) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) +
1352 m(1, 3) * (m(2, 2) * m(3, 0) - m(2, 0) * m(3, 2)) +
1353 m(1, 0) * (m(2, 3) * m(3, 2) - m(2, 2) * m(3, 3)));
1354 out(1, 1) = d * (m(2, 2) * (m(0, 0) * m(3, 3) - m(0, 3) * m(3, 0)) +
1355 m(2, 3) * (m(0, 2) * m(3, 0) - m(0, 0) * m(3, 2)) +
1356 m(2, 0) * (m(0, 3) * m(3, 2) - m(0, 2) * m(3, 3)));
1357 out(1, 2) = d * (m(3, 2) * (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) +
1358 m(3, 3) * (m(0, 2) * m(1, 0) - m(0, 0) * m(1, 2)) +
1359 m(3, 0) * (m(0, 3) * m(1, 2) - m(0, 2) * m(1, 3)));
1360 out(1, 3) = d * (m(0, 2) * (m(1, 3) * m(2, 0) - m(1, 0) * m(2, 3)) +
1361 m(0, 3) * (m(1, 0) * m(2, 2) - m(1, 2) * m(2, 0)) +
1362 m(0, 0) * (m(1, 2) * m(2, 3) - m(1, 3) * m(2, 2)));
1363 out(2, 0) = d * (m(1, 3) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0)) +
1364 m(1, 0) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) +
1365 m(1, 1) * (m(2, 3) * m(3, 0) - m(2, 0) * m(3, 3)));
1366 out(2, 1) = d * (m(2, 3) * (m(0, 0) * m(3, 1) - m(0, 1) * m(3, 0)) +
1367 m(2, 0) * (m(0, 1) * m(3, 3) - m(0, 3) * m(3, 1)) +
1368 m(2, 1) * (m(0, 3) * m(3, 0) - m(0, 0) * m(3, 3)));
1369 out(2, 2) = d * (m(3, 3) * (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) +
1370 m(3, 0) * (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) +
1371 m(3, 1) * (m(0, 3) * m(1, 0) - m(0, 0) * m(1, 3)));
1372 out(2, 3) = d * (m(0, 3) * (m(1, 1) * m(2, 0) - m(1, 0) * m(2, 1)) +
1373 m(0, 0) * (m(1, 3) * m(2, 1) - m(1, 1) * m(2, 3)) +
1374 m(0, 1) * (m(1, 0) * m(2, 3) - m(1, 3) * m(2, 0)));
1375 out(3, 0) = d * (m(1, 0) * (m(2, 2) * m(3, 1) - m(2, 1) * m(3, 2)) +
1376 m(1, 1) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) +
1377 m(1, 2) * (m(2, 1) * m(3, 0) - m(2, 0) * m(3, 1)));
1378 out(3, 1) = d * (m(2, 0) * (m(0, 2) * m(3, 1) - m(0, 1) * m(3, 2)) +
1379 m(2, 1) * (m(0, 0) * m(3, 2) - m(0, 2) * m(3, 0)) +
1380 m(2, 2) * (m(0, 1) * m(3, 0) - m(0, 0) * m(3, 1)));
1381 out(3, 2) = d * (m(3, 0) * (m(0, 2) * m(1, 1) - m(0, 1) * m(1, 2)) +
1382 m(3, 1) * (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) +
1383 m(3, 2) * (m(0, 1) * m(1, 0) - m(0, 0) * m(1, 1)));
1384 out(3, 3) = d * (m(0, 0) * (m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1)) +
1385 m(0, 1) * (m(1, 2) * m(2, 0) - m(1, 0) * m(2, 2)) +
1386 m(0, 2) * (m(1, 0) * m(2, 1) - m(1, 1) * m(2, 0)));
1391#if defined ( USE_MATRIX_TEST )
1392 out.definitelyIdentityMatrix = definitelyIdentityMatrix;
1418 out.M[12] = (T)-(M[12]*M[0] + M[13]*M[1] + M[14]*M[2]);
1419 out.M[13] = (T)-(M[12]*M[4] + M[13]*M[5] + M[14]*M[6]);
1420 out.M[14] = (T)-(M[12]*M[8] + M[13]*M[9] + M[14]*M[10]);
1423#if defined ( USE_MATRIX_TEST )
1424 out.definitelyIdentityMatrix = definitelyIdentityMatrix;
1434#if defined ( USE_MATRIX_TEST )
1435 if (definitelyIdentityMatrix)
1455 memcpy(M, other.M, 16*
sizeof(T));
1456#if defined ( USE_MATRIX_TEST )
1457 definitelyIdentityMatrix=other.definitelyIdentityMatrix;
1466 for (
s32 i = 0; i < 16; ++i)
1469#if defined ( USE_MATRIX_TEST )
1470 definitelyIdentityMatrix=
false;
1479#if defined ( USE_MATRIX_TEST )
1480 if (definitelyIdentityMatrix && other.definitelyIdentityMatrix)
1483 for (
s32 i = 0; i < 16; ++i)
1484 if (M[i] != other.M[i])
1494 return !(*
this == other);
1501 f32 fieldOfViewRadians,
f32 aspectRatio,
f32 zNear,
f32 zFar)
1503 const f64 h = reciprocal(tan(fieldOfViewRadians*0.5));
1504 _IRR_DEBUG_BREAK_IF(aspectRatio==0.f);
1505 const T w =
static_cast<T
>(h / aspectRatio);
1507 _IRR_DEBUG_BREAK_IF(zNear==zFar);
1520 M[10] = (T)(zFar/(zNear-zFar));
1526 M[14] = (T)(zNear*zFar/(zNear-zFar));
1530#if defined ( USE_MATRIX_TEST )
1531 definitelyIdentityMatrix=
false;
1540 f32 fieldOfViewRadians,
f32 aspectRatio,
f32 zNear,
f32 zFar)
1542 const f64 h = reciprocal(tan(fieldOfViewRadians*0.5));
1543 _IRR_DEBUG_BREAK_IF(aspectRatio==0.f);
1544 const T w =
static_cast<T
>(h / aspectRatio);
1546 _IRR_DEBUG_BREAK_IF(zNear==zFar);
1559 M[10] = (T)(zFar/(zFar-zNear));
1564 M[14] = (T)(-zNear*zFar/(zFar-zNear));
1567#if defined ( USE_MATRIX_TEST )
1568 definitelyIdentityMatrix=
false;
1577 f32 fieldOfViewRadians,
f32 aspectRatio,
f32 zNear,
f32 epsilon)
1579 const f64 h = reciprocal(tan(fieldOfViewRadians*0.5));
1580 _IRR_DEBUG_BREAK_IF(aspectRatio==0.f);
1581 const T w =
static_cast<T
>(h / aspectRatio);
1595 M[10] = (T)(1.f-epsilon);
1600 M[14] = (T)(zNear*(epsilon-1.f));
1603#if defined ( USE_MATRIX_TEST )
1604 definitelyIdentityMatrix=
false;
1613 f32 widthOfViewVolume,
f32 heightOfViewVolume,
f32 zNear,
f32 zFar)
1615 _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f);
1616 _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f);
1617 _IRR_DEBUG_BREAK_IF(zNear==zFar);
1618 M[0] = (T)(2/widthOfViewVolume);
1624 M[5] = (T)(2/heightOfViewVolume);
1630 M[10] = (T)(1/(zFar-zNear));
1635 M[14] = (T)(zNear/(zNear-zFar));
1638#if defined ( USE_MATRIX_TEST )
1639 definitelyIdentityMatrix=
false;
1648 f32 widthOfViewVolume,
f32 heightOfViewVolume,
f32 zNear,
f32 zFar)
1650 _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f);
1651 _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f);
1652 _IRR_DEBUG_BREAK_IF(zNear==zFar);
1653 M[0] = (T)(2/widthOfViewVolume);
1659 M[5] = (T)(2/heightOfViewVolume);
1665 M[10] = (T)(1/(zNear-zFar));
1670 M[14] = (T)(zNear/(zNear-zFar));
1673#if defined ( USE_MATRIX_TEST )
1674 definitelyIdentityMatrix=
false;
1683 f32 widthOfViewVolume,
f32 heightOfViewVolume,
f32 zNear,
f32 zFar)
1685 _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f);
1686 _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f);
1687 _IRR_DEBUG_BREAK_IF(zNear==zFar);
1688 M[0] = (T)(2*zNear/widthOfViewVolume);
1694 M[5] = (T)(2*zNear/heightOfViewVolume);
1700 M[10] = (T)(zFar/(zNear-zFar));
1705 M[14] = (T)(zNear*zFar/(zNear-zFar));
1708#if defined ( USE_MATRIX_TEST )
1709 definitelyIdentityMatrix=
false;
1718 f32 widthOfViewVolume,
f32 heightOfViewVolume,
f32 zNear,
f32 zFar)
1720 _IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f);
1721 _IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f);
1722 _IRR_DEBUG_BREAK_IF(zNear==zFar);
1723 M[0] = (T)(2*zNear/widthOfViewVolume);
1729 M[5] = (T)(2*zNear/heightOfViewVolume);
1735 M[10] = (T)(zFar/(zFar-zNear));
1740 M[14] = (T)(zNear*zFar/(zNear-zFar));
1742#if defined ( USE_MATRIX_TEST )
1743 definitelyIdentityMatrix=
false;
1756 M[ 0] = (T)(-plane.
Normal.
X * light.
X + d);
1757 M[ 1] = (T)(-plane.
Normal.
X * light.
Y);
1758 M[ 2] = (T)(-plane.
Normal.
X * light.
Z);
1759 M[ 3] = (T)(-plane.
Normal.
X * point);
1761 M[ 4] = (T)(-plane.
Normal.
Y * light.
X);
1762 M[ 5] = (T)(-plane.
Normal.
Y * light.
Y + d);
1763 M[ 6] = (T)(-plane.
Normal.
Y * light.
Z);
1764 M[ 7] = (T)(-plane.
Normal.
Y * point);
1766 M[ 8] = (T)(-plane.
Normal.
Z * light.
X);
1767 M[ 9] = (T)(-plane.
Normal.
Z * light.
Y);
1768 M[10] = (T)(-plane.
Normal.
Z * light.
Z + d);
1769 M[11] = (T)(-plane.
Normal.
Z * point);
1771 M[12] = (T)(-plane.
D * light.
X);
1772 M[13] = (T)(-plane.
D * light.
Y);
1773 M[14] = (T)(-plane.
D * light.
Z);
1774 M[15] = (T)(-plane.
D * point + d);
1775#if defined ( USE_MATRIX_TEST )
1776 definitelyIdentityMatrix=
false;
1815#if defined ( USE_MATRIX_TEST )
1816 definitelyIdentityMatrix=
false;
1856#if defined ( USE_MATRIX_TEST )
1857 definitelyIdentityMatrix=
false;
1869 for (
u32 i=0; i < 16; i += 4)
1871 mat.M[i+0] = (T)(M[i+0] + ( b.M[i+0] - M[i+0] ) * time);
1872 mat.M[i+1] = (T)(M[i+1] + ( b.M[i+1] - M[i+1] ) * time);
1873 mat.M[i+2] = (T)(M[i+2] + ( b.M[i+2] - M[i+2] ) * time);
1874 mat.M[i+3] = (T)(M[i+3] + ( b.M[i+3] - M[i+3] ) * time);
1913#if defined ( USE_MATRIX_TEST )
1914 o.definitelyIdentityMatrix=definitelyIdentityMatrix;
1923 const f32 scaleX = (viewport.
getWidth() - 0.75f ) * 0.5f;
1924 const f32 scaleY = -(viewport.
getHeight() - 0.75f ) * 0.5f;
1962 M[0] = vt.
X * v.
X + ca;
1963 M[5] = vt.
Y * v.
Y + ca;
1964 M[10] = vt.
Z * v.
Z + ca;
2023 M[0] =
static_cast<T
>(vt.
X * up.
X + ca);
2024 M[5] =
static_cast<T
>(vt.
Y * up.
Y + ca);
2025 M[10] =
static_cast<T
>(vt.
Z * up.
Z + ca);
2031 M[1] =
static_cast<T
>(vt.
X - vs.
Z);
2032 M[2] =
static_cast<T
>(vt.
Z + vs.
Y);
2035 M[4] =
static_cast<T
>(vt.
X + vs.
Z);
2036 M[6] =
static_cast<T
>(vt.
Y - vs.
X);
2039 M[8] =
static_cast<T
>(vt.
Z - vs.
Y);
2040 M[9] =
static_cast<T
>(vt.
Y + vs.
X);
2051 M[12] = -M[0]*center.
X - M[4]*center.
Y - M[8]*center.
Z + (center.
X - translation.
X );
2052 M[13] = -M[1]*center.
X - M[5]*center.
Y - M[9]*center.
Z + (center.
Y - translation.
Y );
2053 M[14] = -M[2]*center.
X - M[6]*center.
Y - M[10]*center.
Z + (center.
Z - translation.
Z );
2055#if defined ( USE_MATRIX_TEST )
2056 definitelyIdentityMatrix=
false;
2078 const f32 c = cosf(rotateRad);
2079 const f32 s = sinf(rotateRad);
2081 M[0] = (T)(c * scale.
X);
2082 M[1] = (T)(s * scale.
Y);
2086 M[4] = (T)(-s * scale.
X);
2087 M[5] = (T)(c * scale.
Y);
2091 M[8] = (T)(c * scale.
X * rotatecenter.
X + -s * rotatecenter.
Y + translate.
X);
2092 M[9] = (T)(s * scale.
Y * rotatecenter.
X + c * rotatecenter.
Y + translate.
Y);
2100#if defined ( USE_MATRIX_TEST )
2101 definitelyIdentityMatrix=
false;
2111 const f32 c = cosf(rotateRad);
2112 const f32 s = sinf(rotateRad);
2119 M[8] = (T)(0.5f * ( s - c) + 0.5f);
2120 M[9] = (T)(-0.5f * ( s + c) + 0.5f);
2122#if defined ( USE_MATRIX_TEST )
2123 definitelyIdentityMatrix = definitelyIdentityMatrix && (rotateRad==0.0f);
2135#if defined ( USE_MATRIX_TEST )
2136 definitelyIdentityMatrix = definitelyIdentityMatrix && (x==0.0f) && (y==0.0f);
2148#if defined ( USE_MATRIX_TEST )
2149 definitelyIdentityMatrix = definitelyIdentityMatrix && (x==0.0f) && (y==0.0f) ;
2159#if defined ( USE_MATRIX_TEST )
2160 definitelyIdentityMatrix = definitelyIdentityMatrix && (sx==1.0f) && (sy==1.0f);
2171 M[8] = (T)(0.5f - 0.5f * sx);
2172 M[9] = (T)(0.5f - 0.5f * sy);
2174#if defined ( USE_MATRIX_TEST )
2175 definitelyIdentityMatrix = definitelyIdentityMatrix && (sx==1.0f) && (sy==1.0f);
2185 memcpy(M,data, 16*
sizeof(T));
2187#if defined ( USE_MATRIX_TEST )
2188 definitelyIdentityMatrix=
false;
2198#if defined ( USE_MATRIX_TEST )
2199 definitelyIdentityMatrix = isDefinitelyIdentityMatrix;
2208#if defined ( USE_MATRIX_TEST )
2209 return definitelyIdentityMatrix;
2220#if defined ( USE_MATRIX_TEST )
2221 if (definitelyIdentityMatrix && other.definitelyIdentityMatrix)
2224 for (
s32 i = 0; i < 16; ++i)
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.h:46
bool isIdentity() const
Returns true if the matrix is the identity matrix.
Definition matrix4.h:1003
CMatrix4< T > & setRotationRadians(const vector3d< T > &rotation)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
Definition matrix4.h:828
CMatrix4< T > & setScale(const T scale)
Set Scale.
Definition matrix4.h:196
T & operator()(const s32 row, const s32 col)
Simple operator for directly accessing every element of the matrix.
Definition matrix4.h:69
CMatrix4< T > operator*(const T &scalar) const
Multiply by scalar.
Definition matrix4.h:576
T & operator[](u32 index)
Simple operator for linearly accessing every element of the matrix.
Definition matrix4.h:81
CMatrix4< T > & buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar)
Builds a left-handed perspective projection matrix based on a field of view.
Definition matrix4.h:1539
CMatrix4< T > & setInverseRotationRadians(const vector3d< T > &rotation)
Make an inverted rotation matrix from Euler angles.
Definition matrix4.h:920
void transformVect(T *out, const core::vector3df &in) const
An alternate transform vector method, writing into an array of 4 floats.
Definition matrix4.h:1163
void multiplyWith1x4Matrix(T *matrix) const
Multiplies this matrix by a 1x4 matrix.
Definition matrix4.h:1271
void getTransposed(CMatrix4< T > &dest) const
Gets transposed matrix.
Definition matrix4.h:1892
CMatrix4< T > & operator-=(const CMatrix4< T > &other)
Subtract another matrix.
Definition matrix4.h:552
CMatrix4< T > & setInverseTranslation(const vector3d< T > &translation)
Set the inverse translation of the current matrix. Will erase any previous values.
Definition matrix4.h:766
core::vector3d< T > getScale() const
Get Scale.
Definition matrix4.h:798
const T & operator[](u32 index) const
Simple operator for linearly accessing every element of the matrix.
Definition matrix4.h:90
CMatrix4< T > & setTextureTranslate(f32 x, f32 y)
Set texture transformation translation.
Definition matrix4.h:2130
CMatrix4< T > & setRotationAxisRadians(const T &angle, const vector3d< T > &axis)
Make a rotation matrix from angle and axis, assuming left handed rotation.
Definition matrix4.h:951
void transformBoxEx(core::aabbox3d< f32 > &box) const
Transforms a axis aligned bounding box.
Definition matrix4.h:1220
bool getInverse(CMatrix4< T > &out) const
Gets the inversed matrix of this one.
Definition matrix4.h:1310
CMatrix4< T > interpolate(const core::CMatrix4< T > &b, f32 time) const
Creates a new matrix as interpolated matrix from two other ones.
Definition matrix4.h:1865
CMatrix4< T > & buildProjectionMatrixPerspectiveFovInfinityLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 epsilon=0)
Builds a left-handed perspective projection matrix based on a field of view, with far plane at infini...
Definition matrix4.h:1576
bool makeInverse()
Calculates inverse of matrix. Slow.
Definition matrix4.h:1432
CMatrix4< T > & setTextureRotationCenter(f32 radAngle)
Set texture transformation rotation.
Definition matrix4.h:2109
void rotateVect(vector3df &vect) const
Rotate a vector by the rotation part of this matrix.
Definition matrix4.h:1104
CMatrix4< T > & makeIdentity()
Set matrix to identity.
Definition matrix4.h:987
CMatrix4< T > & setScale(const vector3d< T > &scale)
Set Scale.
Definition matrix4.h:778
CMatrix4< T > & operator=(const CMatrix4< T > &other)
Sets this matrix equal to the other matrix.
Definition matrix4.h:1451
CMatrix4< T > & buildRotateFromTo(const core::vector3df &from, const core::vector3df &to)
Builds a matrix that rotates from one vector to another.
Definition matrix4.h:1942
void transformBox(core::aabbox3d< f32 > &box) const
Transforms a axis aligned bounding box.
Definition matrix4.h:1206
void transformVect(vector3df &out, const vector3df &in) const
Transforms input vector by this matrix and stores result in output vector.
Definition matrix4.h:1154
void transformVect(vector3df &vect) const
Transforms the vector by this matrix.
Definition matrix4.h:1140
CMatrix4< T > & setbyproduct_nocheck(const CMatrix4< T > &other_a, const CMatrix4< T > &other_b)
Set this matrix to the product of two matrices.
Definition matrix4.h:653
vector3d< T > getTranslation() const
Gets the current translation.
Definition matrix4.h:747
CMatrix4< T > & buildShadowMatrix(const core::vector3df &light, core::plane3df plane, f32 point=1.0f)
Builds a matrix that flattens geometry into a plane.
Definition matrix4.h:1751
bool operator!=(const CMatrix4< T > &other) const
Returns true if other matrix is not equal to this matrix.
Definition matrix4.h:1492
CMatrix4< T > & buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar)
Builds a right-handed perspective projection matrix based on a field of view.
Definition matrix4.h:1500
const T & operator()(const s32 row, const s32 col) const
Simple operator for directly accessing every element of the matrix.
Definition matrix4.h:78
CMatrix4< T > & buildCameraLookAtMatrixRH(const vector3df &position, const vector3df &target, const vector3df &upVector)
Builds a right-handed look-at matrix.
Definition matrix4.h:1824
CMatrix4< T > & buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
Builds a right-handed perspective projection matrix.
Definition matrix4.h:1682
const T * pointer() const
Returns pointer to internal array.
Definition matrix4.h:99
bool isOrthogonal() const
Returns true if the matrix is orthogonal.
Definition matrix4.h:1041
CMatrix4< T > getTransposed() const
Gets transposed matrix.
Definition matrix4.h:1882
void inverseTranslateVect(vector3df &vect) const
Translate a vector by the inverse of the translation part of this matrix.
Definition matrix4.h:1293
CMatrix4< T > & buildCameraLookAtMatrixLH(const vector3df &position, const vector3df &target, const vector3df &upVector)
Builds a left-handed look-at matrix.
Definition matrix4.h:1783
eConstructor
Constructor Flags.
Definition matrix4.h:51
CMatrix4< T > & setTextureTranslateTransposed(f32 x, f32 y)
Set texture transformation translation, using a transposed representation.
Definition matrix4.h:2143
void setRotationCenter(const core::vector3df ¢er, const core::vector3df &translate)
Builds a combined matrix which translates to a center before rotation and translates from origin afte...
Definition matrix4.h:2049
CMatrix4< T > & buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
Builds a left-handed perspective projection matrix.
Definition matrix4.h:1717
CMatrix4< T > & setbyproduct(const CMatrix4< T > &other_a, const CMatrix4< T > &other_b)
set this matrix to the product of two matrices
Definition matrix4.h:688
void setDefinitelyIdentityMatrix(bool isDefinitelyIdentityMatrix)
Sets if the matrix is definitely identity matrix.
Definition matrix4.h:2196
CMatrix4< T > & buildNDCToDCMatrix(const core::rect< s32 > &area, f32 zScale)
Builds a matrix which transforms a normalized Device Coordinate to Device Coordinates.
Definition matrix4.h:1921
CMatrix4< T > & setRotationDegrees(const vector3d< T > &rotation)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
Definition matrix4.h:816
void rotateVect(core::vector3df &out, const core::vector3df &in) const
An alternate transform vector method, writing into a second vector.
Definition matrix4.h:1114
CMatrix4< T > & operator=(const T &scalar)
Sets all elements of this matrix to the value.
Definition matrix4.h:1464
void transformPlane(core::plane3d< f32 > &plane) const
Transforms a plane by this matrix.
Definition matrix4.h:1182
bool getInversePrimitive(CMatrix4< T > &out) const
Inverts a primitive matrix which only contains a translation and a rotation.
Definition matrix4.h:1401
CMatrix4< T > operator-(const CMatrix4< T > &other) const
Subtract another matrix.
Definition matrix4.h:526
void transformVec3(T *out, const T *in) const
An alternate transform vector method, reading from and writing to an array of 3 floats.
Definition matrix4.h:1172
void transformPlane(const core::plane3d< f32 > &in, core::plane3d< f32 > &out) const
Transforms a plane by this matrix.
Definition matrix4.h:1198
bool operator==(const CMatrix4< T > &other) const
Returns true if other matrix is equal to this matrix.
Definition matrix4.h:1477
bool equals(const core::CMatrix4< T > &other, const T tolerance=(T) ROUNDING_ERROR_f64) const
Compare two matrices using the equal method.
Definition matrix4.h:2218
CMatrix4< T > & setTranslation(const vector3d< T > &translation)
Set the translation of the current matrix. Will erase any previous values.
Definition matrix4.h:754
void translateVect(vector3df &vect) const
Translate a vector by the translation part of this matrix.
Definition matrix4.h:1301
CMatrix4< T > & operator*=(const CMatrix4< T > &other)
Multiply by another matrix.
Definition matrix4.h:626
CMatrix4< T > operator+(const CMatrix4< T > &other) const
Add another matrix.
Definition matrix4.h:476
CMatrix4(const CMatrix4< T > &other, eConstructor constructor=EM4CONST_COPY)
Copy constructor.
Definition matrix4.h:440
void rotateVect(T *out, const core::vector3df &in) const
An alternate transform vector method, writing into an array of 3 floats.
Definition matrix4.h:1123
void buildAxisAlignedBillboard(const core::vector3df &camPos, const core::vector3df ¢er, const core::vector3df &translation, const core::vector3df &axis, const core::vector3df &from)
Builds a matrix which rotates a source vector to a look vector over an arbitrary axis.
Definition matrix4.h:1998
core::vector3d< T > getRotationDegrees() const
Returns the rotation, as set by setRotation().
Definition matrix4.h:863
bool isIdentity_integer_base() const
Returns true if the matrix is the identity matrix.
Definition matrix4.h:1070
CMatrix4< T > & setTextureScaleCenter(f32 sx, f32 sy)
Set texture transformation scale, and recenter at (0.5,0.5).
Definition matrix4.h:2167
CMatrix4< T > & buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
Builds a left-handed orthogonal projection matrix.
Definition matrix4.h:1612
CMatrix4< T > & setM(const T *data)
Sets all matrix data members at once.
Definition matrix4.h:2183
CMatrix4< T > & operator*=(const T &scalar)
Multiply by scalar.
Definition matrix4.h:602
CMatrix4< T > & buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
Builds a right-handed orthogonal projection matrix.
Definition matrix4.h:1647
CMatrix4< T > & setTextureScale(f32 sx, f32 sy)
Set texture transformation scale.
Definition matrix4.h:2155
void inverseRotateVect(vector3df &vect) const
Rotate a vector by the inverse of the rotation part of this matrix.
Definition matrix4.h:1131
CMatrix4< T > operator*(const CMatrix4< T > &other) const
Multiply by another matrix.
Definition matrix4.h:705
bool getDefinitelyIdentityMatrix() const
Gets if the matrix is definitely identity matrix.
Definition matrix4.h:2206
CMatrix4(eConstructor constructor=EM4CONST_IDENTITY)
Default constructor.
Definition matrix4.h:417
CMatrix4< T > & operator+=(const CMatrix4< T > &other)
Add another matrix.
Definition matrix4.h:502
CMatrix4< T > & buildTextureTransform(f32 rotateRad, const core::vector2df &rotatecenter, const core::vector2df &translate, const core::vector2df &scale)
Set to a texture transformation matrix with the given parameters.
Definition matrix4.h:2073
CMatrix4< T > & setInverseRotationDegrees(const vector3d< T > &rotation)
Make an inverted rotation matrix from Euler angles.
Definition matrix4.h:822
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
vector3d< T > MaxEdge
The far edge.
Definition aabbox3d.h:347
vector3d< T > MinEdge
The near edge.
Definition aabbox3d.h:344
void repair()
Repairs the box.
Definition aabbox3d.h:180
Template plane class with some intersection testing methods.
Definition plane3d.h:34
vector3d< T > getMemberPoint() const
Gets a member point of the plane.
Definition plane3d.h:155
vector3d< T > Normal
Normal vector of the plane.
Definition plane3d.h:228
T D
Distance from origin.
Definition plane3d.h:231
Rectangle template.
Definition rect.h:27
position2d< T > LowerRightCorner
Lower right corner.
Definition rect.h:267
position2d< T > UpperLeftCorner
Upper left corner.
Definition rect.h:265
T getHeight() const
Get height of rectangle.
Definition rect.h:190
T getWidth() const
Get width of rectangle.
Definition rect.h:184
T X
X coordinate of vector.
Definition vector2d.h:316
T Y
Y coordinate of vector.
Definition vector2d.h:319
3d vector template class with lots of operators and methods.
Definition vector3d.h:23
vector3d< T > crossProduct(const vector3d< T > &p) const
Calculates the cross product with another vector.
Definition vector3d.h:147
T X
X coordinate of the vector.
Definition vector3d.h:408
vector3d< T > & normalize()
Normalizes the vector.
Definition vector3d.h:168
T Z
Z coordinate of the vector.
Definition vector3d.h:414
T dotProduct(const vector3d< T > &other) const
Get the dot product with another vector.
Definition vector3d.h:125
T Y
Y coordinate of the vector.
Definition vector3d.h:411
Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace.
Definition aabbox3d.h:15
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition vector2d.h:323
const f32 DEGTORAD
32bit Constant for converting from degrees to radians
Definition irrMath.h:74
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition irrMath.h:166
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
bool equals(const f64 a, const f64 b, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals b, taking possible rounding errors into account
Definition irrMath.h:185
IRRLICHT_API const matrix4 IdentityMatrix
global const identity matrix
plane3d< f32 > plane3df
Typedef for a f32 3d plane.
Definition plane3d.h:236
const f64 RADTODEG64
64bit constant for converting from radians to degrees
Definition irrMath.h:83
bool iszero(const f64 a, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals zero, taking rounding errors into account
Definition irrMath.h:270
u32 IR(f32 x)
Definition irrMath.h:353
Everything in the Irrlicht Engine can be found in this namespace.
Definition Skylicht.h:33
float f32
32 bit floating point variable.
Definition irrTypes.h:104
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
double f64
64 bit floating point variable.
Definition irrTypes.h:108
signed int s32
32 bit signed variable.
Definition irrTypes.h:66