Inverting a somewhat complicated trig transformation

59 Views Asked by At

I have, for somewhat arcane reasons, the following transformation between given spherical angles $(\theta,\phi)$ (with $-\pi/2 < \theta < \pi/2$) and new angles $(\theta',\phi')$ (with $-\pi/2 < \theta' < \pi/2$):

$$ \theta' = \sin^{-1} (\cos \theta \sin \phi)$$ $$ \phi' = \frac{\pi}{2} - \tan^{-1} (\tan \theta / \cos \phi)$$

where by $\tan^{-1} (b/a)$ we mean the specific angle in $(-\pi,\pi]$ reached in the XY plane from the X axis to the point $(a,b)$ (this is familiar to programmers as the atan2(y,x) function).

I need to invert that transformation, that is, to find $(\theta,\phi)$ given $(\theta', \phi')$.

I "derived" some time back that the answer should be $$ \theta = \sin^{-1}(\cos\theta'\cos\phi') \\ $$ $$ \phi = \tan^{-1} \left( \sin \theta' / (\cos \theta' \sin \phi')\right)$$ where the same convention for the arctangent applies.

This works for various angles I have tried, but I would like to see a derivation better than just trial and error.

I have been able to derive the correct expression for $\theta$ but I keep getting complicated messes when going for $\phi$. Can anybody help?

PS the original question reversed the expressions for the arctangents (comes from working with an Excel spreadsheet, where the order of arguments is $x$ then $y$). Sorry about that.