5#ifndef NIRT_MATRIX_HPP_INCLUDED
6#define NIRT_MATRIX_HPP_INCLUDED
8#include <nirtcpp/core/engine/irrMath.hpp>
9#include <nirtcpp/core/engine/vector3d.hpp>
10#include <nirtcpp/core/engine/vector2d.hpp>
11#include <nirtcpp/core/engine/plane3d.hpp>
12#include <nirtcpp/core/engine/aabbox3d.hpp>
13#include <nirtcpp/core/engine/rect.hpp>
14#include <nirtcpp/core/engine/irrString.hpp>
26#if defined( USE_MATRIX_TEST_DEBUG )
31 MatrixTest () : ID(0), Calls(0) {}
36static MatrixTest MTest;
60 EM4CONST_INVERSE_TRANSPOSED
87#if defined ( USE_MATRIX_TEST )
99#if defined ( USE_MATRIX_TEST )
110#if defined ( USE_MATRIX_TEST )
122 inline CMatrix4<T>&
operator=(
const CMatrix4<T> &other);
125 inline CMatrix4<T>&
operator=(
const T& scalar);
131#if defined ( USE_MATRIX_TEST )
138 bool operator==(
const CMatrix4<T> &other)
const;
141 bool operator!=(
const CMatrix4<T> &other)
const;
144 CMatrix4<T>
operator+(
const CMatrix4<T>& other)
const;
147 CMatrix4<T>&
operator+=(
const CMatrix4<T>& other);
150 CMatrix4<T>
operator-(
const CMatrix4<T>& other)
const;
153 CMatrix4<T>&
operator-=(
const CMatrix4<T>& other);
157 inline CMatrix4<T>&
setbyproduct(
const CMatrix4<T>& other_a,
const CMatrix4<T>& other_b );
166 CMatrix4<T>
operator*(
const CMatrix4<T>& other)
const;
171 CMatrix4<T>&
operator*=(
const CMatrix4<T>& other);
174 CMatrix4<T>
operator*(
const T& scalar)
const;
241 CMatrix4<T>&
setScale(
const vector3d<T>& scale );
474#if defined ( USE_MATRIX_TEST )
478#if defined ( USE_MATRIX_TEST_DEBUG )
488#if defined ( USE_MATRIX_TEST )
491#if defined ( USE_MATRIX_TEST_DEBUG )
497 case EM4CONST_NOTHING:
500 case EM4CONST_IDENTITY:
501 case EM4CONST_INVERSE:
511#if defined ( USE_MATRIX_TEST )
514#if defined ( USE_MATRIX_TEST_DEBUG )
520 case EM4CONST_IDENTITY:
523 case EM4CONST_NOTHING:
528 case EM4CONST_TRANSPOSED:
529 other.getTransposed(*
this);
531 case EM4CONST_INVERSE:
532 if (!
other.getInverse(*
this))
533 std::fill_n(M, 16, 0);
535 case EM4CONST_INVERSE_TRANSPOSED:
536 if (!
other.getInverse(*
this))
537 std::fill_n(M, 16, 0);
539 *
this=getTransposed();
698#if defined ( USE_MATRIX_TEST )
700 if ( !
other.isIdentity() )
702 if ( this->isIdentity() )
704 return (*
this =
other);
709 return setbyproduct_nocheck(
temp,
other );
715 return setbyproduct_nocheck(
temp,
other );
747#if defined ( USE_MATRIX_TEST )
760#if defined ( USE_MATRIX_TEST )
777#if defined ( USE_MATRIX_TEST )
779 if ( this->isIdentity() )
781 if (
m2.isIdentity() )
826#if defined ( USE_MATRIX_TEST )
838#if defined ( USE_MATRIX_TEST )
850#if defined ( USE_MATRIX_TEST )
876 sqrtf(M[4] * M[4] + M[5] * M[5] + M[6] * M[6]),
877 sqrtf(M[8] * M[8] + M[9] * M[9] + M[10] * M[10]));
915 M[10] = (
T)(
cr*
cp );
916#if defined ( USE_MATRIX_TEST )
943 const f64 invC = core::reciprocal(
C);
960 if (X < 0.0) X += 360.0;
961 if (Y < 0.0) Y += 360.0;
962 if (Z < 0.0) Z += 360.0;
982 if (scale.Y<0 && scale.Z<0)
987 else if (scale.X<0 && scale.Z<0)
992 else if (scale.X<0 && scale.Y<0)
998 return getRotationDegrees(scale);
1013 M[0] = (
T)(
cp*
cy );
1014 M[4] = (
T)(
cp*
sy );
1022 M[9] = (
T)(
sr*
cp );
1026 M[10] = (
T)(
cr*
cp );
1027#if defined ( USE_MATRIX_TEST )
1039 const f64 t = 1.0 - c;
1061#if defined ( USE_MATRIX_TEST )
1073 std::fill_n(M, 16, 0);
1074 M[0] = M[5] = M[10] = M[15] = (
T)1;
1075#if defined ( USE_MATRIX_TEST )
1089#if defined ( USE_MATRIX_TEST )
1116#if defined ( USE_MATRIX_TEST )
1127 T dp=M[0] * M[4 ] + M[1] * M[5 ] + M[2 ] * M[6 ] + M[3 ] * M[7 ];
1130 dp = M[0] * M[8 ] + M[1] * M[9 ] + M[2 ] * M[10] + M[3 ] * M[11];
1133 dp = M[0] * M[12] + M[1] * M[13] + M[2 ] * M[14] + M[3 ] * M[15];
1136 dp = M[4] * M[8 ] + M[5] * M[9 ] + M[6 ] * M[10] + M[7 ] * M[11];
1139 dp = M[4] * M[12] + M[5] * M[13] + M[6 ] * M[14] + M[7 ] * M[15];
1142 dp = M[8] * M[12] + M[9] * M[13] + M[10] * M[14] + M[11] * M[15];
1156#if defined ( USE_MATRIX_TEST )
1160 if(
IR(M[0])!=F32_VALUE_1)
return false;
1161 if(
IR(M[1])!=0)
return false;
1162 if(
IR(M[2])!=0)
return false;
1163 if(
IR(M[3])!=0)
return false;
1165 if(
IR(M[4])!=0)
return false;
1166 if(
IR(M[5])!=F32_VALUE_1)
return false;
1167 if(
IR(M[6])!=0)
return false;
1168 if(
IR(M[7])!=0)
return false;
1170 if(
IR(M[8])!=0)
return false;
1171 if(
IR(M[9])!=0)
return false;
1172 if(
IR(M[10])!=F32_VALUE_1)
return false;
1173 if(
IR(M[11])!=0)
return false;
1175 if(
IR(M[12])!=0)
return false;
1176 if(
IR(M[13])!=0)
return false;
1177 if(
IR(M[13])!=0)
return false;
1178 if(
IR(M[15])!=F32_VALUE_1)
return false;
1180#if defined ( USE_MATRIX_TEST )
1200 out.X =
in.X*M[0] +
in.Y*M[4] +
in.Z*M[8];
1201 out.Y =
in.X*M[1] +
in.Y*M[5] +
in.Z*M[9];
1202 out.Z =
in.X*M[2] +
in.Y*M[6] +
in.Z*M[10];
1209 out[0] =
in.X*M[0] +
in.Y*M[4] +
in.Z*M[8];
1210 out[1] =
in.X*M[1] +
in.Y*M[5] +
in.Z*M[9];
1211 out[2] =
in.X*M[2] +
in.Y*M[6] +
in.Z*M[10];
1228 vector[0] =
vect.X*M[0] +
vect.Y*M[4] +
vect.Z*M[8] + M[12];
1229 vector[1] =
vect.X*M[1] +
vect.Y*M[5] +
vect.Z*M[9] + M[13];
1230 vector[2] =
vect.X*M[2] +
vect.Y*M[6] +
vect.Z*M[10] + M[14];
1232 vect.X =
static_cast<f32>(vector[0]);
1233 vect.Y =
static_cast<f32>(vector[1]);
1234 vect.Z =
static_cast<f32>(vector[2]);
1240 out.X =
in.X*M[0] +
in.Y*M[4] +
in.Z*M[8] + M[12];
1241 out.Y =
in.X*M[1] +
in.Y*M[5] +
in.Z*M[9] + M[13];
1242 out.Z =
in.X*M[2] +
in.Y*M[6] +
in.Z*M[10] + M[14];
1249 out[0] =
in.X*M[0] +
in.Y*M[4] +
in.Z*M[8] + M[12];
1250 out[1] =
in.X*M[1] +
in.Y*M[5] +
in.Z*M[9] + M[13];
1251 out[2] =
in.X*M[2] +
in.Y*M[6] +
in.Z*M[10] + M[14];
1252 out[3] =
in.X*M[3] +
in.Y*M[7] +
in.Z*M[11] + M[15];
1258 out[0] =
in[0]*M[0] +
in[1]*M[4] +
in[2]*M[8] + M[12];
1259 out[1] =
in[0]*M[1] +
in[1]*M[5] +
in[2]*M[9] + M[13];
1260 out[2] =
in[0]*M[2] +
in[1]*M[6] +
in[2]*M[10] + M[14];
1266 out[0] =
in[0]*M[0] +
in[1]*M[4] +
in[2]*M[8] +
in[3]*M[12];
1267 out[1] =
in[0]*M[1] +
in[1]*M[5] +
in[2]*M[9] +
in[3]*M[13];
1268 out[2] =
in[0]*M[2] +
in[1]*M[6] +
in[2]*M[10] +
in[3]*M[14];
1269 out[3] =
in[0]*M[3] +
in[1]*M[7] +
in[2]*M[11] +
in[3]*M[15];
1293 transformPlane(
out );
1302#if defined ( USE_MATRIX_TEST )
1316#if defined ( USE_MATRIX_TEST )
1333 for (
u32 i = 0; i < 3; ++i)
1335 for (
u32 j = 0;
j < 3; ++
j)
1410#if defined ( USE_MATRIX_TEST )
1411 if ( this->isIdentity() )
1419 f32 d = (
m[0] *
m[5] -
m[1] *
m[4]) * (
m[10] *
m[15] -
m[11] *
m[14]) -
1420 (
m[0] *
m[6] -
m[2] *
m[4]) * (
m[9] *
m[15] -
m[11] *
m[13]) +
1421 (
m[0] *
m[7] -
m[3] *
m[4]) * (
m[9] *
m[14] -
m[10] *
m[13]) +
1422 (
m[1] *
m[6] -
m[2] *
m[5]) * (
m[8] *
m[15] -
m[11] *
m[12]) -
1423 (
m[1] *
m[7] -
m[3] *
m[5]) * (
m[8] *
m[14] -
m[10] *
m[12]) +
1424 (
m[2] *
m[7] -
m[3] *
m[6]) * (
m[8] *
m[13] -
m[9] *
m[12]);
1429 d = core::reciprocal (
d );
1431 out[0] =
d * (
m[5] * (
m[10] *
m[15] -
m[11] *
m[14]) +
1432 m[6] * (
m[11] *
m[13] -
m[9] *
m[15]) +
1433 m[7] * (
m[9] *
m[14] -
m[10] *
m[13]));
1434 out[1] =
d * (
m[9] * (
m[2] *
m[15] -
m[3] *
m[14]) +
1435 m[10] * (
m[3] *
m[13] -
m[1] *
m[15]) +
1436 m[11] * (
m[1] *
m[14] -
m[2] *
m[13]));
1437 out[2] =
d * (
m[13] * (
m[2] *
m[7] -
m[3] *
m[6]) +
1438 m[14] * (
m[3] *
m[5] -
m[1] *
m[7]) +
1439 m[15] * (
m[1] *
m[6] -
m[2] *
m[5]));
1440 out[3] =
d * (
m[1] * (
m[7] *
m[10] -
m[6] *
m[11]) +
1441 m[2] * (
m[5] *
m[11] -
m[7] *
m[9]) +
1442 m[3] * (
m[6] *
m[9] -
m[5] *
m[10]));
1443 out[4] =
d * (
m[6] * (
m[8] *
m[15] -
m[11] *
m[12]) +
1444 m[7] * (
m[10] *
m[12] -
m[8] *
m[14]) +
1445 m[4] * (
m[11] *
m[14] -
m[10] *
m[15]));
1446 out[5] =
d * (
m[10] * (
m[0] *
m[15] -
m[3] *
m[12]) +
1447 m[11] * (
m[2] *
m[12] -
m[0] *
m[14]) +
1448 m[8] * (
m[3] *
m[14] -
m[2] *
m[15]));
1449 out[6] =
d * (
m[14] * (
m[0] *
m[7] -
m[3] *
m[4]) +
1450 m[15] * (
m[2] *
m[4] -
m[0] *
m[6]) +
1451 m[12] * (
m[3] *
m[6] -
m[2] *
m[7]));
1452 out[7] =
d * (
m[2] * (
m[7] *
m[8] -
m[4] *
m[11]) +
1453 m[3] * (
m[4] *
m[10] -
m[6] *
m[8]) +
1454 m[0] * (
m[6] *
m[11] -
m[7] *
m[10]));
1455 out[8] =
d * (
m[7] * (
m[8] *
m[13] -
m[9] *
m[12]) +
1456 m[4] * (
m[9] *
m[15] -
m[11] *
m[13]) +
1457 m[5] * (
m[11] *
m[12] -
m[8] *
m[15]));
1458 out[9] =
d * (
m[11] * (
m[0] *
m[13] -
m[1] *
m[12]) +
1459 m[8] * (
m[1] *
m[15] -
m[3] *
m[13]) +
1460 m[9] * (
m[3] *
m[12] -
m[0] *
m[15]));
1461 out[10] =
d * (
m[15] * (
m[0] *
m[5] -
m[1] *
m[4]) +
1462 m[12] * (
m[1] *
m[7] -
m[3] *
m[5]) +
1463 m[13] * (
m[3] *
m[4] -
m[0] *
m[7]));
1464 out[11] =
d * (
m[3] * (
m[5] *
m[8] -
m[4] *
m[9]) +
1465 m[0] * (
m[7] *
m[9] -
m[5] *
m[11]) +
1466 m[1] * (
m[4] *
m[11] -
m[7] *
m[8]));
1467 out[12] =
d * (
m[4] * (
m[10] *
m[13] -
m[9] *
m[14]) +
1468 m[5] * (
m[8] *
m[14] -
m[10] *
m[12]) +
1469 m[6] * (
m[9] *
m[12] -
m[8] *
m[13]));
1470 out[13] =
d * (
m[8] * (
m[2] *
m[13] -
m[1] *
m[14]) +
1471 m[9] * (
m[0] *
m[14] -
m[2] *
m[12]) +
1472 m[10] * (
m[1] *
m[12] -
m[0] *
m[13]));
1473 out[14] =
d * (
m[12] * (
m[2] *
m[5] -
m[1] *
m[6]) +
1474 m[13] * (
m[0] *
m[6] -
m[2] *
m[4]) +
1475 m[14] * (
m[1] *
m[4] -
m[0] *
m[5]));
1476 out[15] =
d * (
m[0] * (
m[5] *
m[10] -
m[6] *
m[9]) +
1477 m[1] * (
m[6] *
m[8] -
m[4] *
m[10]) +
1478 m[2] * (
m[4] *
m[9] -
m[5] *
m[8]));
1480#if defined ( USE_MATRIX_TEST )
1507 out.M[12] = (
T)-(M[12]*M[0] + M[13]*M[1] + M[14]*M[2]);
1508 out.M[13] = (
T)-(M[12]*M[4] + M[13]*M[5] + M[14]*M[6]);
1509 out.M[14] = (
T)-(M[12]*M[8] + M[13]*M[9] + M[14]*M[10]);
1512#if defined ( USE_MATRIX_TEST )
1523#if defined ( USE_MATRIX_TEST )
1529 if (getInverse(
temp))
1544 std::copy_n(
other.M, 16, M);
1545#if defined ( USE_MATRIX_TEST )
1555 for (
s32 i = 0; i < 16; ++i)
1558#if defined ( USE_MATRIX_TEST )
1568#if defined ( USE_MATRIX_TEST )
1572 for (
s32 i = 0; i < 16; ++i)
1573 if (M[i] !=
other.M[i])
1583 return !(*
this ==
other);
1628#if defined ( USE_MATRIX_TEST )
1676#if defined ( USE_MATRIX_TEST )
1712#if defined ( USE_MATRIX_TEST )
1758#if defined ( USE_MATRIX_TEST )
1804#if defined ( USE_MATRIX_TEST )
1850#if defined ( USE_MATRIX_TEST )
1896#if defined ( USE_MATRIX_TEST )
1907 plane.Normal.normalize();
1929#if defined ( USE_MATRIX_TEST )
1943 zaxis.normalize_z();
1946 xaxis.normalize_x();
1965 M[12] = (
T)-
xaxis.dotProduct(position);
1966 M[13] = (
T)-
yaxis.dotProduct(position);
1967 M[14] = (
T)-
zaxis.dotProduct(position);
1969#if defined ( USE_MATRIX_TEST )
2006 M[12] = (
T)-
xaxis.dotProduct(position);
2007 M[13] = (
T)-
yaxis.dotProduct(position);
2008 M[14] = (
T)-
zaxis.dotProduct(position);
2010#if defined ( USE_MATRIX_TEST )
2023 for (
u32 i=0; i < 16; i += 4)
2025 mat.M[i+0] = (
T)(M[i+0] + ( b.M[i+0] - M[i+0] ) *
time);
2026 mat.M[i+1] = (
T)(M[i+1] + ( b.M[i+1] - M[i+1] ) *
time);
2027 mat.M[i+2] = (
T)(M[i+2] + ( b.M[i+2] - M[i+2] ) *
time);
2028 mat.M[i+3] = (
T)(M[i+3] + ( b.M[i+3] - M[i+3] ) *
time);
2039 getTransposed (
t );
2067#if defined ( USE_MATRIX_TEST )
2112 T ca = f.dotProduct(
t);
2116 M[0] =
vt.X * v.
X +
ca;
2117 M[5] =
vt.Y * v.
Y +
ca;
2118 M[10] =
vt.Z * v.
Z +
ca;
2177 M[0] =
static_cast<T>(
vt.X *
up.X +
ca);
2178 M[5] =
static_cast<T>(
vt.Y *
up.Y +
ca);
2179 M[10] =
static_cast<T>(
vt.Z *
up.Z +
ca);
2185 M[1] =
static_cast<T>(
vt.X -
vs.Z);
2186 M[2] =
static_cast<T>(
vt.Z +
vs.Y);
2189 M[4] =
static_cast<T>(
vt.X +
vs.Z);
2190 M[6] =
static_cast<T>(
vt.Y -
vs.X);
2193 M[8] =
static_cast<T>(
vt.Z -
vs.Y);
2194 M[9] =
static_cast<T>(
vt.Y +
vs.X);
2209#if defined ( USE_MATRIX_TEST )
2235 M[0] = (
T)(c * scale.
X);
2236 M[1] = (
T)(s * scale.
Y);
2240 M[4] = (
T)(-s * scale.
X);
2241 M[5] = (
T)(c * scale.
Y);
2254#if defined ( USE_MATRIX_TEST )
2273 M[8] = (
T)(0.5f * ( s - c) + 0.5f);
2274 M[9] = (
T)(-0.5f * ( s + c) + 0.5f);
2276#if defined ( USE_MATRIX_TEST )
2289#if defined ( USE_MATRIX_TEST )
2308#if defined ( USE_MATRIX_TEST )
2319#if defined ( USE_MATRIX_TEST )
2337 M[8] = (
T)(0.5f - 0.5f *
sx);
2338 M[9] = (
T)(0.5f - 0.5f *
sy);
2340#if defined ( USE_MATRIX_TEST )
2351 std::copy_n(data, 16, M);
2353#if defined ( USE_MATRIX_TEST )
2364#if defined ( USE_MATRIX_TEST )
2376#if defined ( USE_MATRIX_TEST )
2388#if defined ( USE_MATRIX_TEST )
2392 for (
s32 i = 0; i < 16; ++i)
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.hpp:49
CMatrix4< T > & operator+=(const CMatrix4< T > &other)
Add another matrix.
Definition matrix4.hpp:572
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.hpp:2203
vector3d< T > getTranslation() const
Gets the current translation.
Definition matrix4.hpp:814
CMatrix4< T > & setInverseRotationDegrees(const vector3d< T > &rotation)
Make an inverted rotation matrix from Euler angles.
Definition matrix4.hpp:887
CMatrix4< T > & setTranslation(const vector3d< T > &translation)
Set the translation of the current matrix. Will erase any previous values.
Definition matrix4.hpp:821
bool operator!=(const CMatrix4< T > &other) const
Returns true if other matrix is not equal to this matrix.
Definition matrix4.hpp:1581
CMatrix4< T > getTransposed() const
Gets transposed matrix.
Definition matrix4.hpp:2036
CMatrix4< T > & setInverseTranslation(const vector3d< T > &translation)
Set the inverse translation of the current matrix. Will erase any previous values.
Definition matrix4.hpp:833
void setDefinitelyIdentityMatrix(bool isDefinitelyIdentityMatrix)
Sets if the matrix is definitely identity matrix.
Definition matrix4.hpp:2362
void rotateVect(vector3df &vect) const
Transform (rotate/scale) a vector by the rotation part of this matrix.
Definition matrix4.hpp:1188
bool getInversePrimitive(CMatrix4< T > &out) const
Inverts a primitive matrix which only contains a translation and a rotation.
Definition matrix4.hpp:1490
CMatrix4< T > & buildCameraLookAtMatrixRH(const vector3df &position, const vector3df &target, const vector3df &upVector)
Builds a right-handed look-at matrix.
Definition matrix4.hpp:1978
void transformPlane(core::plane3d< f32 > &plane) const
Transforms a plane by this matrix.
Definition matrix4.hpp:1275
bool getInverse(CMatrix4< T > &out) const
Gets the inverse matrix of this one.
Definition matrix4.hpp:1404
CMatrix4< T > & setM(const T *data)
Sets all matrix data members at once.
Definition matrix4.hpp:2349
CMatrix4< T > & buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true)
Builds a right-handed perspective projection matrix.
Definition matrix4.hpp:1813
bool getDefinitelyIdentityMatrix() const
Gets if the matrix is definitely identity matrix.
Definition matrix4.hpp:2374
void translateVect(vector3df &vect) const
Translate a vector by the translation part of this matrix.
Definition matrix4.hpp:1395
bool operator==(const CMatrix4< T > &other) const
Returns true if other matrix is equal to this matrix.
Definition matrix4.hpp:1566
void transformBoxEx(core::aabbox3d< f32 > &box) const
Transforms a axis aligned bounding box.
Definition matrix4.hpp:1314
CMatrix4< T > & operator*=(const CMatrix4< T > &other)
Multiply by another matrix.
Definition matrix4.hpp:696
CMatrix4< T > & buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero=true)
Builds a right-handed perspective projection matrix based on a field of view.
Definition matrix4.hpp:1589
CMatrix4< T > & setScale(const T scale)
Set Scale.
Definition matrix4.hpp:244
void inverseRotateVect(vector3df &vect) const
Tranform (rotate/scale) a vector by the inverse of the rotation part this matrix.
Definition matrix4.hpp:1215
void transformVect(vector3df &vect) const
Transforms the vector by this matrix.
Definition matrix4.hpp:1224
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.hpp:1256
CMatrix4< T > & setTextureTranslateTransposed(f32 x, f32 y)
Set texture transformation translation, using a transposed representation.
Definition matrix4.hpp:2303
CMatrix4< T > & operator=(const CMatrix4< T > &other)
Sets this matrix equal to the other matrix.
Definition matrix4.hpp:1540
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.hpp:2152
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.hpp:723
core::vector3d< T > getScale() const
Get Scale.
Definition matrix4.hpp:863
CMatrix4< T > operator+(const CMatrix4< T > &other) const
Add another matrix.
Definition matrix4.hpp:546
CMatrix4< T > & setbyproduct(const CMatrix4< T > &other_a, const CMatrix4< T > &other_b)
set this matrix to the product of two matrices
Definition matrix4.hpp:758
CMatrix4< T > & setTextureScale(f32 sx, f32 sy)
Set texture transformation scale.
Definition matrix4.hpp:2315
CMatrix4< T > & buildRotateFromTo(const core::vector3df &from, const core::vector3df &to)
Builds a matrix that rotates from one vector to another.
Definition matrix4.hpp:2096
CMatrix4< T > & setInverseRotationRadians(const vector3d< T > &rotation)
Make an inverted rotation matrix from Euler angles.
Definition matrix4.hpp:1004
CMatrix4< T > & makeIdentity()
Set matrix to identity.
Definition matrix4.hpp:1071
bool makeInverse()
Calculates inverse of matrix. Slow.
Definition matrix4.hpp:1521
void multiplyWith1x4Matrix(T *matrix) const
Multiplies this matrix by a 1x4 matrix.
Definition matrix4.hpp:1365
CMatrix4< T > & setRotationRadians(const vector3d< T > &rotation)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
Definition matrix4.hpp:893
bool equals(const core::CMatrix4< T > &other, const T tolerance=(T) ROUNDING_ERROR_f64) const
Compare two matrices using the equal method.
Definition matrix4.hpp:2386
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.hpp:2227
void transformBox(core::aabbox3d< f32 > &box) const
Transforms a axis aligned bounding box.
Definition matrix4.hpp:1300
CMatrix4< T > & buildNDCToDCMatrix(const core::rect< s32 > &area, f32 zScale)
Builds a matrix which transforms a normalized Device Coordinate to Device Coordinates.
Definition matrix4.hpp:2075
CMatrix4< T > & setRotationDegrees(const vector3d< T > &rotation)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
Definition matrix4.hpp:881
T & operator[](u32 index)
Simple operator for linearly accessing every element of the matrix.
Definition matrix4.hpp:97
CMatrix4< T > & buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar, bool zClipFromZero=true)
Builds a left-handed perspective projection matrix based on a field of view.
Definition matrix4.hpp:1637
bool isIdentity_integer_base() const
Returns true if the matrix is the identity matrix.
Definition matrix4.hpp:1154
void transformVec4(T *out, const T *in) const
An alternate transform vector method, reading from and writing to an array of 4 floats.
Definition matrix4.hpp:1264
bool isOrthogonal() const
Returns true if the matrix is orthogonal.
Definition matrix4.hpp:1125
CMatrix4< T > & buildCameraLookAtMatrixLH(const vector3df &position, const vector3df &target, const vector3df &upVector)
Builds a left-handed look-at matrix.
Definition matrix4.hpp:1937
const T * pointer() const
Returns pointer to internal array.
Definition matrix4.hpp:128
T & operator()(const s32 row, const s32 col)
Simple operator for directly accessing every element of the matrix.
Definition matrix4.hpp:85
CMatrix4< T > & buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true)
Builds a left-handed perspective projection matrix.
Definition matrix4.hpp:1859
void getTextureScale(f32 &sx, f32 &sy) const
Get texture transformation scale.
Definition matrix4.hpp:2326
CMatrix4< T > & setRotationAxisRadians(const T &angle, const vector3d< T > &axis)
Make a rotation matrix from angle and axis, assuming left handed rotation.
Definition matrix4.hpp:1035
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.hpp:1685
const T & operator()(const s32 row, const s32 col) const
Simple operator for directly accessing every element of the matrix.
Definition matrix4.hpp:94
CMatrix4< T > & setScale(const vector3d< T > &scale)
Set Scale.
Definition matrix4.hpp:845
CMatrix4< T > operator-(const CMatrix4< T > &other) const
Subtract another matrix.
Definition matrix4.hpp:596
void getTextureTranslate(f32 &x, f32 &y) const
Get texture transformation translation.
Definition matrix4.hpp:2296
void inverseTranslateVect(vector3df &vect) const
Translate a vector by the inverse of the translation part of this matrix.
Definition matrix4.hpp:1387
const T & operator[](u32 index) const
Simple operator for linearly accessing every element of the matrix.
Definition matrix4.hpp:106
CMatrix4< T > & setTextureScaleCenter(f32 sx, f32 sy)
Set texture transformation scale, and recenter at (0.5,0.5)
Definition matrix4.hpp:2333
CMatrix4< T > operator*(const CMatrix4< T > &other) const
Multiply by another matrix.
Definition matrix4.hpp:775
CMatrix4< T > interpolate(const core::CMatrix4< T > &b, f32 time) const
Creates a new matrix as interpolated matrix from two other ones.
Definition matrix4.hpp:2019
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.hpp:1905
CMatrix4< T > & operator-=(const CMatrix4< T > &other)
Subtract another matrix.
Definition matrix4.hpp:622
CMatrix4< T > & setTextureRotationCenter(f32 radAngle)
Set texture transformation rotation.
Definition matrix4.hpp:2263
bool isIdentity() const
Returns true if the matrix is the identity matrix.
Definition matrix4.hpp:1087
CMatrix4< T > & buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true)
Builds a left-handed orthogonal projection matrix.
Definition matrix4.hpp:1721
CMatrix4< T > & buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero=true)
Builds a right-handed orthogonal projection matrix.
Definition matrix4.hpp:1767
eConstructor
Constructor Flags.
Definition matrix4.hpp:54
CMatrix4(eConstructor constructor=EM4CONST_IDENTITY)
Default constructor.
Definition matrix4.hpp:487
core::vector3d< T > getRotationDegrees() const
Returns the rotation, as set by setRotation().
Definition matrix4.hpp:969
CMatrix4(const T &r0c0, const T &r0c1, const T &r0c2, const T &r0c3, const T &r1c0, const T &r1c1, const T &r1c2, const T &r1c3, const T &r2c0, const T &r2c1, const T &r2c2, const T &r2c3, const T &r3c0, const T &r3c1, const T &r3c2, const T &r3c3)
Constructor with value initialization.
Definition matrix4.hpp:68
CMatrix4< T > & setTextureTranslate(f32 x, f32 y)
Set texture transformation translation.
Definition matrix4.hpp:2284
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
vector3d< T > MinEdge
The near edge.
Definition aabbox3d.hpp:354
vector3d< T > MaxEdge
The far edge.
Definition aabbox3d.hpp:357
void repair()
Repairs the box.
Definition aabbox3d.hpp:180
aabbox3d()
Default Constructor.
Definition aabbox3d.hpp:26
T Y
Y coordinate of vector.
Definition vector2d.hpp:395
T X
X coordinate of vector.
Definition vector2d.hpp:392
T Y
Y coordinate of the vector.
Definition vector3d.hpp:453
T X
X coordinate of the vector.
Definition vector3d.hpp:450
vector3d< T > & normalize()
Normalizes the vector.
Definition vector3d.hpp:178
T Z
Z coordinate of the vector.
Definition vector3d.hpp:456
const f64 RADTODEG64
64bit constant for converting from radians to degrees
Definition irrMath.hpp:81
vector3d< T > operator*(const S scalar, const vector3d< T > &vector)
Function multiplying a scalar and a vector component-wise.
Definition vector3d.hpp:494
bool iszero(const f64 a, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals zero, taking rounding errors into account
Definition irrMath.hpp:304
const f32 DEGTORAD
32bit Constant for converting from degrees to radians
Definition irrMath.hpp:72
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition irrMath.hpp:164
u32 IR(f32 x)
Definition irrMath.hpp:387
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
Definition irrMath.hpp:243
NIRTCPP_API const matrix4 IdentityMatrix
global const identity matrix
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
signed int s32
32 bit signed variable.
Definition irrTypes.hpp:72
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.hpp:64
double f64
64 bit floating point variable.
Definition irrTypes.hpp:114
float f32
32 bit floating point variable.
Definition irrTypes.hpp:110