1

I am attempting to create a script to convert between the output of one long program and the input of another, neither of which I can edit. The output of the first gives euler angles for rotation and the input of the other requires a 3 float versor. All the online information I have been able to find on how to convert from euler angles to quaternions give 4 numbers and I don't know which 3 are needed for a versor. Please help

  • 1
    see: https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles – Emilio Novati Nov 02 '15 at 15:29
  • I already looked there but it doesn't talk about versors specifically and that is where I am confused - it tells me how to get 4 numbers but I don't know which 3 I need – biophys_chem Nov 02 '15 at 15:32

1 Answers1

1

From this ref. we see how determine a unitary quaternion $z=a+b\mathbf{i}+c\mathbf{j}+c\mathbf{k}=a+\mathbf{v}$ that corresponds to three rotation around the coordinate axis (note that the quaternion depends on the order of the rotations not only from the angles).

We can write such unitary quaternion $z$ in polar form ( see: How can i express a quaternion in polar form?) as: $$ z= e^ {\mathbf{n} \theta} $$ where $$ \cos \theta=\dfrac{a}{|z|} \qquad \sin \theta=\dfrac{|\mathbf{v}|}{|z|} \qquad (1)$$ and $$ \mathbf{n}=\dfrac{\mathbf{v}}{|z|\sin \theta}=\dfrac{\mathbf{v}}{|\mathbf v|} \qquad (2)$$

Now a rotation of a vector $\vec u$ by an angle $2\theta$ around the axis oriented by the versor $\mathbf{n}$ is given by: $$ R_{\mathbf{n},2\theta} (\vec u)=e^ {\mathbf{n} \theta}\,\vec u\, e^ {-\mathbf{n} \theta} $$
So (2) gives the versor of the rotation an (1) the double angle.

Emilio Novati
  • 62,675