# Rotating a point in spherical coordinates around Cartesian axis

If I have a point in spherical coordinates, and I rotate it around one of the Cartesian axes, what will be the new spherical coordinates for the point? Both spherical and Cartesian coordinate systems have the same origin. Rotation axes go through origin as in the image below.

I'm building a mechanical device that has a camera rotating around object, and camera's relative coordinates should remain same while object rotates. I've read Wikipedia pages about transformation matrices etc, but those goes way over my head.

• Rotate about $Z$ is extremely simple ;-). – Troy Woo Aug 22 '14 at 15:16
• If it's the $z$ axis it'll just be a translation in $\theta$. If it's in either $x$ or $y$ it'll be more difficult since spherical coordinates aren't so neat for that purpose. (I'm a fan of stereographic coordinates in that case, but that requires some legwork to get familiar with.) The straightest way might be the crudest: Figure out how to re-express your spherical coordinates relative to one of the other two axes, rotate easily in that coordinate system, and then work out the the spherical coordinates relative to $z$-axis. – Semiclassical Aug 22 '14 at 15:16
• Use the group of rotation on $\mathbb{R}^3$ – user343429 Jun 6 '16 at 19:23
• Beware that there is no mechanical device that allow you to rotate around the three axis independently, and your question is probably not the right one. Also the statement "camera's relative coordinates should remain same while object rotates" sounds very mysterious to me. – Yves Daoust Nov 15 '16 at 15:06

You can work with the rotation operators in $\mathbb{C}^2$. This method is well-known in quantum mechanics (rotation on the Bloch sphere).
I assume the following spherical coordinates system ($\theta$: colatitude, $\phi$: longitude):
Given the coordinate angles $(\theta, \phi)$, define a vector $Q(\theta, \phi)$ in $\mathbb{C}^2$ by $$Q(\theta, \phi) = \begin{pmatrix} \cos \frac{\theta}{2} \\ e^{i\phi}\sin\frac{\theta}{2}\end{pmatrix}.$$ Conversely, given a vector $\begin{pmatrix} z_1 \\ z_2 \end{pmatrix} \in \mathbb{C}^2$, define the coordinate angles $(\theta, \phi)$ by $$Q^{-1}\begin{pmatrix} z_1 \\ z_2 \end{pmatrix} = \left( 2\, \textrm{atan} \frac{\textrm{Mod}(z_2)}{\textrm{Mod}(z_1)}, \textrm{Arg}(z_2)-\textrm{Arg}(z_1)\right).$$
Then the rotation to the angle $\alpha$ around a Cartesian axis maps the coordinate angles $(\theta,\phi)$ to the coordinate angles $$(\theta', \phi') = (Q^{-1} \circ R_{\textrm{axis}}(\alpha) \circ Q)(\theta,\phi)$$ where the rotation operator $R_{\textrm{axis}}(\alpha)$ is, depending on the rotation axis: \begin{gather} R_x(\alpha) = \begin{pmatrix} \cos\frac{\alpha}{2} & -i\sin\frac{\alpha}{2} \\ -i\sin\frac{\alpha}{2} & \cos\frac{\alpha}{2} \end{pmatrix}, \\ R_y(\alpha) = \begin{pmatrix} \cos\frac{\alpha}{2} & -\sin\frac{\alpha}{2} \\ \sin\frac{\alpha}{2} & \cos\frac{\alpha}{2} \end{pmatrix}, \\ R_z(\alpha) = \begin{pmatrix} e^{-i\frac{\alpha}{2}} & 0 \\ 0 & e^{i\frac{\alpha}{2}} \end{pmatrix}. \end{gather}
Denote rotation matrix about an axis $\omega$ and rotation angle $\theta$ by $R_\omega(\theta)$. Then the Cartesian coordinate of a point can be represented by spherical coordinates in the following way: $$\left[\begin{array}{c} x\\ y\\ z \end{array}\right]=R_z(\theta)\cdot R_y(\varphi)\cdot rz,\quad z=\left[\begin{array}{c} 0\\ 0\\ 1 \end{array}\right]$$ Then rotate the point $p=(x,y,z)$ about the three coordinate axes is given by (note that $R_z(\sigma)\cdot z=z, \forall \sigma\in\mathbb R$): $$\begin{split} R_x(\alpha)\cdot R_z(\theta)\cdot R_y(\varphi)\cdot rz&=R_z(\theta')\cdot R_y(\varphi')\cdot rz\\ (&=R_z(\theta')\cdot R_y(\varphi')\cdot R_z(\sigma')\cdot rz) \end{split}$$ $$\begin{split} R_y(\beta)\cdot R_z(\theta)\cdot R_y(\varphi)\cdot rz&=R_z(\theta'')\cdot R_y(\varphi'')\cdot rz\\ (&=R_z(\theta'')\cdot R_y(\varphi'')\cdot R_z(\sigma'')\cdot rz) \end{split}$$ and $$R_z(\gamma)\cdot R_z(\theta)\cdot R_y(\varphi)\cdot rz=R_z(\theta+\gamma)\cdot R_y(\varphi)\cdot rz$$ This way, you see that for rotation about $z$, the result is immediate, and for rotation about $x$, this is the problem of transform between $YZX$ and $ZYZ$ Euler angles, and for $y$ it is between $YZY$ and $ZYZ$ Euler angles. There are ready-to-use routines for solving this problem (it might help to use quaternions to deal with the consecutive rotation if you intend to write the code yourself).