Archived

This topic is now archived and is closed to further replies.

Matrix Multiply Prob!

This topic is 5613 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I my app I need to get 1 matrix out of a few lets say for instance 5 matrixes. All the time i tried it with multipliing with a Identity Matrix! But it did not work! Do you have any idea how to find a solution! By the way I used the D3DXMatrixMultiply function! Thanks

Share this post


Link to post
Share on other sites
Retrieving 1 matrix out of 5 already concatenated matrices is not easy. Basically, you need to know the other four. You find each of the other four matrices'' inverses and multiply them with the concatenated one. This will give you the one your looking for. It''s much easier however to just store the 5 matrices and retrieve them when needed. Is that the answer you needed?

---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org

Share this post


Link to post
Share on other sites
Nope, D3DXMatrixMultiply should work. Many problems come from the order of multiplication. Matrix multiplication is not commutative. I don''t know the situation you''re in, but if you''re trying to multiply transforms together, it can produce wierd results if not done right. If you think out the order first though, it makes sense. For example, if you want to rotate and translate an object and you want a world matrix for it, think it through. You don''t want to translate the object first becuase then when you rotate it, it will orbit around the world. Instead, you want to rotate it in local coords and then translate the matrix. D3DXMatrixMultiply just multiplies two matrices together so to do multiple ones, you need to call it multiple times and use the previous results as the matrix for the next call. Lol, Did that help?

---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org

Share this post


Link to post
Share on other sites
I tried it exactly the way you said! But it dosent work! In my app I need this for a mesh animation with frames! So i miltiplied the matrix of the mesh from the base frame to the frame the matrix is in! And it seems as if only the last two matrixes(top & 2nd level matrix) are conducted. Does anyone hav a solution!

Share this post


Link to post
Share on other sites
This should work:
MATRIX A,B,C,D,E,Result;

Result=MatrixMultiply(A,B);
Result=MatrixMultiply(Result,C);
Result=MatrixMultiply(Result,D);
Result=MatrixMultiply(Result,E);

This is pseudo-code notation. D3DXMatrixMultiply takes the result matrix as a parameter.
A,B,C,D,E are your frame matrices. "A" should be the parent.

Share this post


Link to post
Share on other sites
since D3DXMatrixMultiply returns a pointer, you can use it as a parameter eg
D3DXMatrixMultiply(A,D3DXMatrixMultiply(B,D3DXMatrixMultiply(C,D))

or should it be
D3DXMatrixMultiply(D3DXMatrixMultiply(D3DXMatrixMultiply(A,B),C),D)

given that i want to multiply in the order ABCD?

[edited by - walkingcarcass on July 31, 2002 7:36:34 AM]

Share this post


Link to post
Share on other sites