Simple Trig inverse problem

232 Views Asked by At

Suppose we have $x=\sin a \cos b, y=\sin a\sin b, z=\cos a$. I want to invert them to get $a,b$ in terms of $x,y,z$. At first sight it appears very simple, for example my first reaction would be to say that $a= \cos^{-1} z, b= \cos^{-1}{\left(x\over \sqrt{1-z^2}\right)}$. But it doesn't feel right for example that I used only $x,z$ for $b$ since $y$ also involves $b$. I think the inverse like this might not give the right range of angles, since where $\sin,\cos$ are positive don't necessarily overlap. How might I find $a,b$ in terms of more variables? I have to get $a$ to be unique in $(0,\pi)$ and $b$ unique in $(0,2\pi)$.

2

There are 2 best solutions below

0
On

Your formula is correct when $y$ is positive. But when $y$ is negative, $$b=2\pi -\arccos\left(\frac{x}{\sqrt{1-z^2}}\right).$$

Remark: Alternately, one can use $\arctan$ to almost compute $b$. But again adjustment needs to be made, depending on the sign of $y$. In a computing setting, you may be able to use the two-variable $\text{atan}$ function, which deals with the sign issue automatically.

0
On

$a= \cos^{-1} z$ and $\frac{y}{x} = \tan(b) \Rightarrow b=\tan^{-1} \frac{y}{x}$