#### Archived

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

# Matrix Multiply Prob!

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

## 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 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

##### Share on other sites
Thank you! But I think I explained the prob wrong! I want to concate 5 matrixes to one! Is it the right way to use D3DXMatrixMultiply or do I have to do something special??

##### 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

##### 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 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 on other sites
Thanks! This was the way i tried it out the whole time which seemed also logic to me!

##### 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]

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633755
• Total Posts
3013706
×