PDA

View Full Version : Translating Position A in relation to position B



paul_g_griffiths
01-31-2017, 02:46 PM
I have 3 matrix4.



glm::mat4 A;
glm::mat4 B;
glm::mat4 C;

I have the title to this thread wrong. It should be:
I wish to translate and rotate A to C and B gets translated and rotated with it as in this diagram. How to get B? This is 3D, x, y & z. Any ideas?

https://s29.postimg.org/deucwv607/translation.jpg

BBeck1
02-02-2017, 03:25 AM
I didn't see your drawing the first time I read this post and didn't know what you meant.

If B is a child of A then it's simply a matter of setting A = C. If it is not a child of A, then you could temporarily make it one. I believe that would involve subtracting A's position from B so that B is relative to A position-wise. Orientation would stay the same. Then B = (C * B) after A = C. That would rotate A and since B is a child of A rotate B as well.