1
$\begingroup$

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:

object rotation with respect to another

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.

$\endgroup$
0
$\begingroup$

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.

y'_position = (x'_position - x_position) 
            - (y_position - x_position)
            + (y_position - x_position)*(x'_orientation - x_orientation)

y'_orientation = mat(x'_orientation - x_orientation)*mat(y_orientation)

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.