I am writing a python code to translate and rotate an object with respect to another object. Please take a look at the picture bellow:
The smiley face and the arrow have initial poses (position and orientation) as shown in the left picture. Then, the face rotates. I want the arrow to rotate and move to the pose shown on the right picture. I can imagine how to do that in 2D. However, I found it difficult to extend it to 3D.
So, the problem is as follows:
Given the initial and the current 3D pose of object x (say face) and the initial pose of object y (arrow), find a transformation T such that if we transform the initial pose of y using T, objects x and y keep their initial pose with respect to each other when the pose of object x changes.
The poses I get are quaternions, However, I have a python library which I can use to convert them to Euler angles and rotation matrices (and vice versa), so, that is not a problem.
Best Answer
Finally, I figured out how we can do that.
consider x_position and y_position are the initial 3D positions of x, and y respectively. And x_orientation and y_orientation are the initial orientations of x, and y respectively. x'_position and y'_position are the current position of x and y and x'_orientation , y'_orientation are the current orientations of x and y.
mat converts Euler angels or quaternion to rotation matrix. For position, basically, we translate y into x, rotate it using the rotation matrix we got from the rotation of x, and translate it back to its new position.