rayzor
diff src/vmathmat.h @ 12:d94a69933a71
lots of stuff, can't remember
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 12 Apr 2014 23:28:24 +0300 |
parents | a826bf0fb169 |
children | 964f8ea5f095 |
line diff
1.1 --- a/src/vmathmat.h Thu Apr 10 08:42:33 2014 +0300 1.2 +++ b/src/vmathmat.h Sat Apr 12 23:28:24 2014 +0300 1.3 @@ -38,6 +38,12 @@ 1.4 1.5 float *operator [](int idx) { return m[idx]; } 1.6 const float *operator [](int idx) const { return m[idx]; } 1.7 + 1.8 + void transpose(); 1.9 + 1.10 + float determinant() const; 1.11 + Matrix4x4 adjoint() const; 1.12 + Matrix4x4 inverse() const; 1.13 }; 1.14 1.15 inline Matrix4x4 operator *(const Matrix4x4 &a, const Matrix4x4 &b) 1.16 @@ -52,6 +58,18 @@ 1.17 return res; 1.18 } 1.19 1.20 +inline Matrix4x4 operator *(const Matrix4x4 &mat, float scalar) 1.21 +{ 1.22 + Matrix4x4 res; 1.23 + 1.24 + for(int i=0; i<4; i++) { 1.25 + for(int j=0; j<4; j++) { 1.26 + res.m[i][j] = mat.m[i][j] * scalar; 1.27 + } 1.28 + } 1.29 + return res; 1.30 +} 1.31 + 1.32 inline void Matrix4x4::set_identity() 1.33 { 1.34 m[0][0] = m[1][1] = m[2][2] = m[3][3] = 1.0; 1.35 @@ -112,5 +130,4 @@ 1.36 *this = *this * m; 1.37 } 1.38 1.39 - 1.40 #endif // VMATH_MATRIX_H_