[Math] Converting quaternions to spherical angles

quaternionsspherical-geometry

Consider a situation where a beam is shot at a cube C from an arbitrary position P. The cube detects the angle of incidence relative to its $ x $ axis. The cube can be rotated and moved, and the orientation (rotation) of the cube is being tracked.

Below is an example in two dimensions. In the reference orientation, $ C_\text{ref} $, the angle of incidence is $ 0° $. The cube is then moved to an arbitrary position and rotated with an arbitrary quaternion rotation $ \mathbf{q} $. The measured angle of incidence is now $ \gamma $. By subtracting the rotation angle $ \beta $, the angle of incidence relative to the reference orientation is found to be $ \alpha $. ($ \alpha = \gamma – \beta $) In three dimensions, the same problem would also have an elevation angle.

enter image description here

My question is this: how do I convert the (three-dimensional) rotation from quaternions $ \mathbf{q}=(q_0,q_1,q_2,q_3) $ to spherical angles $ (\theta,\phi) $?

Best Answer

Any rotation in three-dimensions can be represented as a rotation by an angle $\theta$ about an axis determined by a unit vector $\hat{n}=(n_1,n_2,n_3)$ -- that is three parameters and not two as the OP indicates. Such a rotation can be represented by $$ \exp(\theta\ \sum_{j=1}^3 n_j \cdot T^j)\ , $$ where $(T^1,T^2,T^3)$ are a basis in the fundamental (three) representation of $so(3)$ and are given by the matrices $(T_{i})_{jk}=\epsilon_{ijk}$. The connection with quaternions that I know makes use of the isomorphism of the (complex) Lie algebras $so(3)$ and $su(2)$. We just replace $\mathbf{T}$ with the corresponding generators in the fundamental (two) dimensional representation of $su(2)$. A basis for this Lie algebra are given in terms of the Pauli matrices. Using the identification $$T^j \longleftrightarrow i\sigma^j/2\ ,$$ one obtains $$ \exp(\theta\ \sum_{j=1}^3n_j \tfrac{i\ \sigma^j}2)= \cos \tfrac{\theta}2 \mathbf{1} + i \sin \tfrac\theta2 \sum_{j=1}^3 n_j\ \sigma^j $$ where I have used a standard identity involving Pauli matrices. The right hand side is a quaternion, if you wish. Note that this is not a 1-1 map as group manifold of $SU(2)$ is a double cover of $SO(3)$.

Related Question