Implemented Matrix2x3, bugfixes

This commit is contained in:
Kearwood Kip Gilbert
2018-03-28 15:42:56 -07:00
parent 20d341227d
commit d9808e03ba
6 changed files with 463 additions and 125 deletions

View File

@@ -137,15 +137,16 @@ void Matrix2::scale(float s) {
/* Replace matrix with its inverse */
bool Matrix2::invert() {
float det = 1.0f / (c[0] * c[3] + c[1] * c[2]);
float det = c[0] * c[3] - c[1] * c[2];
if (det == 0) {
return false;
}
float invdet = 1.0f / det;
float tmp = c[0];
c[0] = c[3] * invdet;
c[1] = -c[1] * invdet;
c[2] = -c[2] * invdet;
c[3] = c[0] * invdet;
c[3] = tmp * invdet;
return true;
}