Matrix multiplication order complication

Started by
4 comments, last by Kest 17 years, 7 months ago
I'm getting a bit stuck. I can't quite remember the exact details of how this works. What I want to do is.. 1. Record the state of something (A) 2. Change the state 3. Record the new state (B) 4. Calculate the difference between the old and new states (C = B - A) 5. Change another object's state (D) in the same way (D += C) Is this correct? 4. C = B * Inverted(A); 5. D *= C; Or this? 4. C = Inverted(A) * B; 5. D *= C; edit: Sorry, here's an english version.. 4. Diff = NewState * Inverted(OldState); 5. AnotherState *= Diff; Or this? 4. Diff = Inverted(OldState) * NewState; 5. AnotherState *= Diff; Or neither? I seem to have several locations in my math that appear to be doing this one way, and other routines that use the other. I'm having trouble understanding the difference. Thanks for any help.
Advertisement
Is it that I need to multiply on the same side? So for example, if I remove the old original state on the right side..

4. Diff = NewState * Inverted(OldState);

I would need to inject that change into AnotherState by having AnotherState on the same side as the inverted OldState?

5. AnotherState = Diff * AnotherState;

If so, then this would also be the same result as above..?

4. Diff = Inverted(OldState) * NewState;
5. AnotherState = AnotherState * Diff;

Is this correct? Thanks again for any info.
I assume these states are represented by transform matrices. If so, are your matrices constructed with the basis vectors in the rows or columns?

Also, what type of transforms do the matrices represent?
First, check out my article on matrix layout and conventions.

Second, what "inverse(A)" gives you is a matrix that "undoes" the transformation of A, and puts the operand back in the "identity" space. The operation B then "re-does" the B transformation, to end up in B space.

If you use row vertices on the left, then the correct math is:

Combined = Inverse(A) * B;

If you use column vectors on the right, then the correct math is:

B * Inverse(A) = Combined;

enum Bool { True, False, FileNotFound };
Quote:Original post by jyk
I assume these states are represented by transform matrices. If so, are your matrices constructed with the basis vectors in the rows or columns?

Also, what type of transforms do the matrices represent?

I'm not sure of the correct terms, but the first three floats of each row represent the vectors. The data is normally viewed as..
X(11,12,13),14,Y(21,22,23),24,Z(31,32,33),34T(41,42,43),44
The matrices represent rotation and/or translation.
Quote:Original post by hplus0603
Second, what "inverse(A)" gives you is a matrix that "undoes" the transformation of A, and puts the operand back in the "identity" space. The operation B then "re-does" the B transformation, to end up in B space.

I have the same trouble associating this explaination with order..

undoA + redoB != redoB + undoA

This is what I'm seeing in my head..

A = Rotate 90
B = Rotate 45
Inverse(A) = Rotate -90

Rotate -90 * Rotate 45 == Rotate -45
and
Rotate 45 * Rotate -90 == Rotate -45

But this isn't the case. Is it because of the order changing the relationship between translation and rotation? So that if the multiplication order is swapped, the translation ends up getting rotated in the result?

This topic is closed to new replies.

Advertisement