Closed gecko0307 closed 10 years ago
The other possible way is to keep row-major order, but define two matrix multiplication operators: the ordinary one (*
) and "reverse" one (for example, tilda: ~
). Row-majors are still possible in OpenGL, since
trans(A) * trans(B) = trans(B * A)
So we have
A ~ B = trans(A) * trans(B)
as it actually is in the current opMul
implementation - it does column-by-row product instead of row-by-column.
Would that be all it takes? Either way, such operation should probably have a descriptive name rather than just use an arbitrary operator. My vote would still go to taking the leap (and aiming for GLSL-compatible semantics like I mentioned before), but please, if you decide not to change this, at least put a big warning somewhere in the class :) I could probably wrap my head around having to multiply in the reverse order, after all, if that's really all it takes.
OK, I decided to rewrite. This would be consistent with the principle of least surprise, after all.
Yo, if you want me to help with any code related to this, just point me to the line numbers
Thanks, I'm gonna do it myself :)
Would it be reasonable to start square bracket indexing in opIndex(i, j)
from 1 rather than 0? This would conform standard mathematical notation.
I don't think any other library in a C-style language does this, and neither should we :)
OK. The most part is ready, dlib.math.affine is on the go.
Just to make sure. With new matrix code, the unittest that you committed for #14 gives [0, 0, -0.577418, 1.41421]
as the resulting vector. Is this correct?
Can't guarantee it's correct, but it's the same value as given by the old matrix code which works for me. You swapped the matrices in the multiplication, right?
No. It turns out swapping is not needed. Nor was needed with the old code, due to "reversed" multiplication.
...to gain better compatibility with OpenGL and address multiplication-related issues mentioned in #14.