At work we are presenting a 3D model on a web page using three.js. We also show the Euler (Tait–Bryan) rotation angles for the camera. One problem is that these angles sometimes behave in a strange way; suddenly two of the angles can change sign and the third start run in the opposite direction (e.g. decrease instead of increase).
My question:
Is there any formula giving a continuous map from $SO(3)$ to the angles? More precisely, if $R(\hat z, \gamma) R(\hat y, \beta) R(\hat x, \alpha) \in SO(3)$ how should $\alpha, \beta, \gamma$ be modified (in a continuous way) when another small rotation $R(n, \theta)$ is applied? Here $R(n, \theta)$ denotes a rotation angle $\theta$ around an axis with direction $n \in S^2$ and $\hat x, \hat y, \hat z$ are the unit vectors in the $x, y, z$ directions.
What I have tried myself:
Using quaternions I have asserted
$$
e^{\frac12 (\gamma+\epsilon c) \mathbf k}
e^{\frac12 (\gamma+\epsilon b) \mathbf j}
e^{\frac12 (\gamma+\epsilon a) \mathbf i}
=
e^{\frac12 \epsilon \theta \mathbf n}
e^{\frac12 \gamma \mathbf k}
e^{\frac12 \beta \mathbf j}
e^{\frac12 \alpha \mathbf i}
$$
and expanded to first order in $\epsilon$. That worked quite fine, but I got a division by $\cos\beta$ resulting in a problem when $\cos\beta=0.$
Unfortunately no. There's no nonsingular three parameter chart on $SO(3)$.
The best way to do this is to use a quaternion representation of the attitude and work out how a "small" norm rotational quaternion modifies the rotation. There's some work on that in the attitude determination literature. See this paper.
What do you define $\mathbf{n}$ as? An arbitrary axis? I'm not sure that's right, but it could be; you'd have to look at first order BCH expansions.
There's a couple of standard ways for solving Euler angle problems on $SO(3)$. The first option is to create multiple sets of Euler angles and switch between the sets based on your current orientation. If you use this in feedback you need a bunch of logic around where the charts are patched together, so it gets messy. Otherwise you could transform the data to quaternions and set a fixed quaternion at the point where the Euler angles gimbal lock.