Your attempt to write down the inverse of a 4x4 matrix is utterly wrong. There's absolutely no point trying to fix it since it can never work.
You ask what the result of 1/0
is. Well, that is division by zero and the result is not defined. There is no real number x
that satisfies 1/0 == x
. If there was then 1 == x*0 == 0
, a contradiction. On a computer, attempting to perform division by zero sometimes leads to an error, or sometimes results in a special floating point value Inf
being returned. The latter appears to be what happens in your environment.
I don't know why you rejected the determinant based code. Perhaps you found it tricky to implement. But that's just how it is. You aren't going to shortcut that complexity.