26 #ifndef FIFE_UTIL_MATRIX_H 27 #define FIFE_UTIL_MATRIX_H 55 template <
typename U>
friend class Matrix;
57 memmove(
m, mat.m, 16*
sizeof(T));
66 T determinant =
m0*ret[0] +
m1*ret[4] +
m2*ret[8] +
m3*ret[12];
67 assert(determinant!=0 &&
"Singular matrix has no inverse");
76 for (
unsigned i = 0; i < 16; ++i)
114 T magSqr = x*x + y*y + z*z;
223 assert(ind > -1 && ind < 16);
227 assert(ind > -1 && ind < 16);
315 #define cofactor_maker(f1,mj1,mi1, f2,mj2,mi2, f3,mj3,mi3) \ 316 f1*(mj1*mi1-mj2*mi3) + f2*(mj2*mi2-mj3*mi1) + f3*(mj3*mi3-mj1*mi2) 371 T
m0,
m1,
m2,
m3,
m4,
m5,
m6,
m7,
m8,
m9,
m10,
m11,
m12,
m13,
m14,
m15;
382 std::ostream& operator<<(std::ostream& os, const Matrix<T>&
m) {
384 return os <<
"\n|" <<
m[0] <<
"," <<
m[4] <<
"," <<
m[8] <<
"," <<
m[12] <<
"|\n" << \
385 "|" <<
m[1] <<
"," <<
m[5] <<
"," <<
m[9] <<
"," <<
m[13] <<
"|\n" << \
386 "|" <<
m[2] <<
"," <<
m[6] <<
"," <<
m[10] <<
"," <<
m[14] <<
"|\n" << \
387 "|" <<
m[3] <<
"," <<
m[7] <<
"," <<
m[11] <<
"," <<
m[15] <<
"|\n";
Matrix & applyRotate(T angle, T x, T y, T z)
Matrix< T > & Rmult4by4(const Matrix< T > &mat)
this->Rmult4by4(temp) == [temp] X [*this]
#define cofactor_maker(f1, mj1, mi1, f2, mj2, mi2, f3, mj3, mi3)
Matrix< T > & mult4by4(const Matrix< T > &mat)
Minimal matrix class to assist in view 3d calculations.
Matrix< double > DoubleMatrix
Matrix & applyScale(T x, T y, T z)
Apply scale into this matrix.
PointType3D< T > operator*(const PointType3D< T > &vec)
Transform given point using this matrix.
Matrix< int32_t > IntMatrix
Matrix adjoint() const
Get the adjoint matrix.
Matrix & mult3by3(const Matrix &mat)
Apply the matrix dot product to this matrix.
Matrix inverse() const
Adjoint method inverse, constant time inversion implementation.
T & operator[](int32_t ind)
Direct access to the matrix elements, just remember they are in column major format!! ...
Matrix & loadRotate(T angle, T x, T y, T z)
Make this a rotation matrix.
Matrix & loadScale(T x, T y, T z=1)
Make this a scale matrix.
Matrix & operator/=(T val)
Divide this matrix by a scalar.
Matrix & loadTranslate(const T x, const T y, const T z)
Make this a translation matrix.
Matrix & applyTranslate(T x, T y, T z)
Apply translation into this matrix.