I have a globe in 3D Euclidean space with the center of the globe at the origin, only the globe is tilted off axis by $\phi$ degrees so it doesn't rotate around the z-axis anymore, but an arbitrary one determined by $\phi$.
Is it possible to do the equivalent of spinning the globe around its tilted axis by $\theta$ degrees using rotations relative to the 3 coordinate axes? How would I relate $\phi$ and $\theta$ with rotations $\alpha$, $\beta$ and $\gamma$ around the x, y, and z-coordinate axes, respectively?
Edit
I've tried figuring this out with some spherical trig. Here's a little diagram I made:
In this scenario I want to revolve a body like the sun along a path ("Sun arc") around an arbitrary axis ("Sun axis"). It looks to me like angles $A$ and $B$ are always $\frac{\pi}{2}$, $C$ is $\frac{\pi}{2}-\phi$, angle $a$ and $b$ are my $\theta$, and that just leaves to solve for angle $c$, which I think ends up just being $c=\sin^{-1}(\sin\theta\sin\phi)$ by spherical law of sines. So basically my rotations around the coordinate axes should be $x=0, y=\theta, z=\sin^{-1}(\sin\theta\sin\phi)$. This doesn't seem quite right however, when I use it for my sun animation. The rotation is close, but just not quite right for some reason, so I must have something off here.
If anyone is curious about what I'm actually doing, here is an animation of the sun and stars I'm making:
The sun and stars should be rotating around the same axis so they move together, however you can see from the animation this isn't quite the case. For the sun movement, I am able to specify azimuth and elevation angles, and I'm considering its path the source of truth (its easier for me to understand its rotation axis). For the star background, I have to rotate a large sphere with the stars printed on it, and I can only specify rotations around the coordinate axes for this. The key difficulty is that when I rotate around the x-axis for example, it does not change the coordinate system. Rotating around z after rotating around x still just rotates around the original z axis. Getting these to behave the same using different coordinate systems is proving very tricky!
Edit 2
I think I found a better way to frame this. So the usual way to do this would be to rotate the space up (around the x or y axis) and then rotate the space around the z axis. Using the usual rotation matrices, this would be $R_z(\gamma)R_x(\alpha)p$, where $p$ is a point in the space. I've realized what I'm actually trying to do is reverse the order of those transformations but achieve the same resulting $p$, so that I first rotate the space around x or y, and then around z. So I want $R_x(\alpha)R_z(\gamma)p$. The problem of course, is that to rotate around an arbitrary axis, $\gamma$ must now change with $\alpha$, where it could have stayed constant before. I need a way to compute the correct $\gamma$ from $\alpha$.


The axis of rotation is specified with respect to the stationary coordinate axes using two angles $\theta_A$ and $\phi_A$, which are the angular spherical coordinates of the unit vector along the axis. In particular, the axis is given by
$ n = (\sin \theta_A \cos \phi_A , \sin \theta_A \sin \phi_A, \cos \theta_A)$
Along with vector $n$ we need two other unit vectors, so that the set of these three vectors make up an orthonormal basis for $\mathbb{R}^3$. These two vectors can be conveniently chosen to be
$u_1 = (\cos \theta_A \cos \phi_A , \cos \theta_A \sin \phi_A, -\sin \theta_A) $
$ u_2 = ( - \sin \phi_A , \cos \phi_A , 0 ) $
Now the orthonormal set is the rotation matrix $R_1$ whose columns are $u_1, u_2 , n$, i.e.
$R_1 = [u_1, u_2, n ]$
A point $P \in \mathbb{R}^3 $ has an equivalent coordinate vector $Q$ in the $R_1$ coordinate system given by
$ P = R_1 Q $
In other words,
$Q = R_1^T P $
Now to rotate $P$ about the axis $n$ is to rotate $Q$ about the $z$-axis of the $R_1$ system. So if we rotate by an angle of $\theta$, then the image of $Q$ in the $R_1$ coordinate system will be
$Q' = R_z Q $
where $R_z = \begin{bmatrix} \cos \theta && - \sin \theta && 0 \\ \sin \theta && \cos \theta && 0 \\ 0 && 0 && 1 \end{bmatrix} $
And now we can obtain the image of $P$ as being
$P' = R_1 Q' = R_1 R_z Q = R_1 R_z R_1^T P $
This is all you need to rotate a point about a tilted axis.