add maths functions

This commit is contained in:
Ian Curtis 2016-03-22 13:47:28 +00:00
parent 93f6b01e0b
commit e7eb912eaa
2 changed files with 16 additions and 0 deletions

View file

@ -1017,4 +1017,19 @@ bool CNew3D::ClockWiseWinding()
}
}
float CNew3D::Determinant3x3(const float m[16]) {
/*
| A B C |
M = | D E F |
| G H I |
then the determinant is calculated as follows:
det M = A * (EI - HF) - B * (DI - GF) + C * (DH - GE)
*/
return m[0] * ((m[5] * m[10]) - (m[6] * m[9])) - m[4] * ((m[1] * m[10]) - (m[2] * m[9])) + m[8] * ((m[1] * m[6]) - (m[2] * m[5]));
}
} // New3D

View file

@ -172,6 +172,7 @@ private:
enum class AlphaType{ none, poly, texture };
void RenderScene(int priority, bool alpha);
bool ClockWiseWinding(); // calculate winding with current matrix
float Determinant3x3(const float m[16]);
/*
* Data