# Convert quaternion to spherical coordinates

I have a vector in 3D space (red vector $r$) where the origin of the vector is placed at the origin of the coordinate system and the other edge of the vector is placed at the surface of a unit sphere. I rotate the vector around the origin of the coordinate system and using motion sensors, I capture the rotation in the form of a quaternion. I was wondering how can I calculate the spherical coordinate of the vector ($\theta$, $\phi$) using the quaternion ($q = \{q_w, q_x, q_y, q_z\}$).

One solution can be converting quaternion to Euler angles, then extracting cartesian/spherical coordinates from Euler angles. But I was wondering if is there any shortcut.

Cheers,

In general, if $r = r_x i + r_yj + r_z k$ is a "space" vector, it can be regarded as a pure quaternion (e.g. the $i,j,k$ are treated like the hypercomplex parts of the quaternion rather than just geometrically). Then you have $$r' = qrq^*$$ using quaternion multiplication. If you want spherical coordinates, you can transform the resulting cartesian vector into spherical.