Inverse rotation transformations I'm taking the 2-degree gibmle system and position its alignment point in a arbitrary position (denoted by the axes angles phi for the first degree, and theta for the second). How can I reverse the transformations I did (first rotation of the first axis by phi, then rotation of the seconds axis by theta) and get phi and theta from the resulted alignment point's position on the unit sphere?

If your alignment point happens to lie on either of the axes, you cannot undo the operations, because rotation about that axis will leave the alignment point in the same place, so a single "final position" leads to multiple possible input-rotations. 
Assuming that the axes start out perpendicular, with the first aligned with the $y$ axis and the second aligned with $x$, and the alignment point on the positive $z$ axis, it's not too difficult. The tricky part is deciding what "first" and "second" mean here. 
I mean that if you rotate in $y$, then the $x$-rotation axis remains fixed, but if you rotate in $x$, then the $y$-rotation axis will be moved.
In that case, a rotation by $\phi$ about $y$ moves $(0,0, 1)$ to $(\sin \phi, 0, \cos \phi)$; a further rotation about $x$ by $\theta$ moves the resulting point to 
$$
\begin{bmatrix}
1 & 0 & 0 \\
0 & \cos \theta & -\sin \theta \\
0 & \sin \theta & \cos \theta 
\end{bmatrix}  
\begin{bmatrix}
\sin \phi \\
0 \\
\cos \phi 
\end{bmatrix} =
\begin{bmatrix}
\sin \phi \\
-\sin \theta \cos \phi \\
\cos \theta \cos \phi
\end{bmatrix}  
$$
Given this location as an $xyz$-triple, how can you recover $\phi$ and $\theta$? Well,
let's assume that $\phi$ is restricted to $-90\deg < \phi < 90 \deg$. In that case, $\cos \phi > 0$, and 
$$
\theta = {\mathrm{atan2}}(-y, z)
$$
Now you can compute 
$$
u = -x / \sin \theta
$$
or
$$
u = z/ \cos \theta
$$
using whichever formula has a nonzero denominator. 
Finally, 
$$
\phi = \mathrm{atan2}(x, u).
$$
If you try to actually implement this, there's a good chance that one or both of your angle-directions will be opposite to mine, or that in your assembly the $y$-rotation comes first, etc. So you'll have to work through the analog of this using your conditions. But the main idea is that "atan2" is the solution. 
