# how to get rotation vector from 2 positions

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

## Recommended Posts

hi, i rotate p(x,y,z) around z-axis by an angle of rz; then around x-axis by rx; then around y-axis (BVH channel's order) by ry. Finally, i get p1(x1,y1,z1). Question: given p and p1, what's the formula to calculate the rotation vector r(rz, rx, ry)? thank!

##### Share on other sites
So essentially you have two vectors and you're trying to find out to rotation around each axis. Well, the answer is not as clean cut as you might think because there are a large number of ways you can do this. For example, you can get a rotation around each axis in the order of X, Y, Z. But if you get it in the order of Z, X, Y, it will still be valid but your values will be different. Same in the order of Y, X, Z, and so on.

Take a look at these links, they might help:
http://www.euclideanspace.com/maths/geometry/rotations/axisAngle/index.htm
http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/index.htm
http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToEuler/index.htm

##### Share on other sites
thanks a lot! not easy to get direct answer huh..

##### Share on other sites

A direct answer to this will be difficult to find, since in general rotations aren't expressed as a vector with angles around the axes (called Euler angles). The main problem with what you're asking is that an infinite number of possible angle combinations (counting Mod2Pi ones) will rotate p to p1, all but one of which you probably don't want.

Perhaps there is some way to get the angles you want, but I don't know of it. If you're looking for some arbitrary angles, you could find them by projecting p1 and p onto the appropriate planes and solving with some basic trigonometry. To get the rotation around the z axis for example, you would take the xy components of p1 (a 2D vector) and find its angle with the xy components of p. Rinse and repeat for the other axes.

I don't know if that works for you, but in any case you might want to take a look the rotation representations and conversions RealMarkP proposed. Matrices and quaternions are typically more useful (and stable) than euler angles.

##### Share on other sites
thanks a lot! i think i can use mathematica to solve a equation R(rx)R(ry)R(rz)P1=P2, where R is rotation matrix. mathematica should solve all the possible rx,ry,rz for me.

1. 1
2. 2
3. 3
Rutin
13
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633697
• Total Posts
3013405
×