# Difference between matrices

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

## Recommended Posts

Hello, My problem is as follows: I have two rotational matrices both stored in seperate 4x4 matrices which represent the rotation of two models. I wish to bring object B into the same frame as object A so I can preform collision detection without rotating object A. Is it possible to get the difference between these two matrices so that I can preform these calculations? My ideal answer would be in the form of a 3x3 rotational matrix which gives the rotation that would need to be applied to object B so it would be angled in relation to object A. Thanks in advance, Marx!

##### Share on other sites
Let's say you have vertex V in Frame A, and you want to take it to Frame B. You first need to "undo" Frame B, which would be B-1V (assuming B is also the rotation matrix associated with Frame B). You then need to take it into Frame A, which means multiplying again by A -- AB-1V. This assumes that Frame A and Frame B have the same direct parent frame (like canonical world space). If not, then you need to undo all the transformations on V up to the first common parent frame, and then perform all the transformations necessary to get to Frame B from that parent frame.

##### Share on other sites
Sorry, someone is being misunderstood here.

I have two objects A and B.
A is rotated by matA and B is rotated by matB.
Translations are also being applied but consider them seperate.

I'm trying to find the matrix matC that would rotate object B so that it is in the same relative position to A without rotating object A.

Normal math logic would make me think to simply subtract B from A and your left with the answer but with matrix math I'm not sure that will work.

Any ideas or am I misunderstanding you?

##### Share on other sites
So you have matA and matB, and you want to apply matC to object B such that you end up with the same relative location of B to A as if you rotated A by matA and B by matB.
Then matC is matA-1matB
Thusly matC rotates object B by matB then the inverse rotation you would have applied to object A.

where matA-1 symbolizes the inverse of matA.

##### Share on other sites
Thanks a million, I knew I was just missing something simple!

Thanks again!

1. 1
2. 2
Rutin
18
3. 3
khawk
15
4. 4
A4L
14
5. 5

• 10
• 13
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633745
• Total Posts
3013667
×