Extract the angle of rotation from a unit quaternion Sorry for boring you my friends before the spring vacation. I am haunted by a simple problem of how to extract rotation angle from a unit quaternion.
Suppose $a$ is a unit quaternion which takes the form of:
$$a = \left( \cos \left(\frac{\phi}{2} \right),\sin \left(\frac{\phi}{2}\right)\cdot \overrightarrow{n}\right)$$
$\phi$ is the angle of rotation and $\overrightarrow{n}$ is the axis of rotation.
I have seen in the books, the popular approach to extract the angle of rotation is via the inverse function of $sin$ or $cos$, but the result of inverse function remains valid and unique when the rotation is positive and small. Thus, I wonder if there is another approach in which the extracted angle could be extended in both directions (positive or negative) and in the scope of large rotation.
Thank you in advance for taking a look and giving a hint. 
 A: This answer is mostly a compilation of the comments by crbah and SZN, but It's easier to see here. I almost had overlooked the comment.
The answer from the comments
$\phi = 2 \cdot \tan^{-1}\left(\frac{\sin{\left(\frac{\phi}{2}\right)}}{\cos{\left(\frac{\phi}{2}\right)}}\right)$
Reasoning
This is enough because $\phi$ has by definition only a range $\phi\in[0,\pi]$. If the angle were larger, we could use a rotation in the opposite direction instead. I believe this would be simply done by inverting the signs of all elements of the rotation axis $\vec{n}$ in your definition $$a = \left( \cos \left(\frac{\phi}{2} \right),\sin \left(\frac{\phi}{2}\right)\cdot \overrightarrow{n}\right)$$
$\cos{\left(\phi\right)}$ is only ambiguous if the angle $\phi$ is allowed to be negative, so I think it should be enough to use $\cos^{-1}{ \left(\cos{\left(\frac{\phi}{2}\right)}\right)}$ though. I don't know, that seems confusing to me, because $\tan^{-1} \in\left]-\frac{\pi}{2},\frac{\pi}{2}\right[$ while $\cos^{-1}\in\left[-\frac{\pi}{2},\frac{\pi}{2}\right]$.
My answer
It seems to me that we lose information when we use only one trigonometric function. I believe however that we could simply look at the signs of the sine and cosine to determine in which quadrant the angle should be.
If the sign of $\sin{\left(\frac{\phi}{2}\right)}$ is positive, we use $\phi=2\cdot cos^{-1}{\left(\cos{\frac{\phi}{2}}\right)}$ and if the sign of the sine is negative, we take the negative of this $\phi$ instead. (You can think about this by picturing the unit circle.)
