I'm trying to invert 4x4 matrices, I've seen some examples of calculating the determinant with a few dozens of calculations, this did not seem to work for me, I might've just messed up somewhere, but I've been trying to find another way to solve this, my answer was this:
public Matrix inverse()
{
double[] array = new double[]{
1/m[0], m[4], m[8], 0,
m[1], 1/m[5], m[9], 0,
m[2], m[6], 1/m[10], 0,
-m[12], -m[13], -m[14], 1/m[15]
};
return new Matrix(array);
}
Basicly what I do is, calculating the invert of all it's components, this has been working quite well, expect for number 15, the last number, it's been spewing out infinity for some reason, does anyone have a clue as to why? My only guess would be division by zero, but then the question, what is the inverse of a 0? Is the answer 0?
(Not sure if this is relevant, but my matrices are row-major)