Euler angles between two 3d vectors

tomyake picture tomyake · Feb 26, 2013 · Viewed 40.6k times · Source

How do you find the 3 euler angles between 2 3D vectors? When I have one Vector and I want to get its rotation, this link can be usually used: Calculate rotations to look at a 3D point?

But how do I do it when calculating them according to one another?

Answer

Ali picture Ali · Feb 27, 2013

As others have already pointed out, your question should be revised. Let's call your vectors a and b. I assume that length(a)==length(b) > 0 otherwise I cannot answer the question.


Calculate the cross product of your vectors v = a x b; v gives the axis of rotation. By computing the dot product, you can get the cosine of the angle you should rotate with cos(angle)=dot(a,b)/(length(a)length(b)), and with acos you can uniquely determine the angle (@Archie thanks for pointing out my earlier mistake). At this point you have the axis angle representation of your rotation.

The remaining work is to convert this representation to the representation you are looking for: Euler angles. Conversion Axis-Angle to Euler is a way to do it, as you have found it. You have to handle the degenerate case when v = [ 0, 0, 0], that is, when the angle is either 0 or 180 degrees.


I personally don't like Euler angles, they screw up the stability of your app and they are not appropriate for interpolation, see also