You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My understanding of 3x3 and up matrix determinates is that alternate the sign of each sub determinate based on which row you choose (in row 1 and 3 it would be + - + and row 2 it would be - + -).
Mostly this issue is a question trying to understand the code and the math behind it, and also why the calculation in the determinate method is different from what is in the inverse method.
The text was updated successfully, but these errors were encountered:
You are right in that both Matrix4f.determinant() and Matrix4f.invert() would need to effectively do the same computations. And they indeed do. It's just that the calculations done in Matrix4f.invert() have been massively reshuffled and reorganized to make full use of variables to hold common sub-expressions that are computed at least twice. This gave a huge performance boost compared to a naive implementation of Matrix4f.invert() where you'd simply once call determinant() and then do all computations for the individual matrix elements.
However, both the determinant and the inverse matrix elements share many common sub-expressions that need not be computed multiple times, so I spend literally hours refactoring it to have as few arithmetic operations and as many reuses of variables for common sub-expressions as possible.
The fact that you do not see the common alternating + - patterns in the determinant is that this has also been restructured/reshuffled to "look nicer". Note that + (a * b - c * d) is equal to - (c * d - a * b). This is all there is to it, really.
And both methods should do what they are supposed to do.
I was looking around the Matrix4f code and found that the determinate function has a different calculation from what is used in the inverse function.
Specifically, the Matrix4f.determinate() uses plus after each of the calculations but Matrix4f.invertGeneric() does the normal + - + - pattern of determinates.
I'm curious which is correct, or are they both correct for their specific circumstance?
Also I'd like to note that Matrix4f.determinate3x3() and Matrix3.determinate() also keep the sign constant.
My understanding of 3x3 and up matrix determinates is that alternate the sign of each sub determinate based on which row you choose (in row 1 and 3 it would be + - + and row 2 it would be - + -).
Mostly this issue is a question trying to understand the code and the math behind it, and also why the calculation in the determinate method is different from what is in the inverse method.
The text was updated successfully, but these errors were encountered: