undefined angles with arcsin I have this problem but I couldn't solve it. In a paper I'm reading for controlling a device, I need to generate the following angle 
$$
\theta = \tan^{-1}\left( \frac{Y_{2} - Y_{1}}{ X_{2} - X_{1}} \right)
$$
where $Y_{2} = 10, Y_{1} = 0, X_{2} = 10$ and $X_{1} = 0$. 
Now I need to generate the following angle 
$$
\phi = \sin^{-1} ( 0.401*\sin(\theta) - 2.208*\cos(\theta) )
$$
where $\theta = 0.7854$ (rad). The next angle $\psi$ is then generated as follows 
$$
\psi = \sin^{-1} \left( \frac{0.401*\sin(\theta) + 2.208*\cos(\theta)}{\cos\phi} \right)
$$
In my code, both angles $\phi$ and $\psi$ are undefined. I know that $\phi$ should be wrapped so that $\cos\phi \neq 0$ to avoid singularity but the problem $\phi$ is already undefined. 

When $\theta=0.7854\approx \frac{\pi}{4}$, $\sin{\theta}=\cos{\theta}=\frac{\sqrt{2}}{2}$. Evaluating your definition for $\phi$ at $\frac{\pi}{4}$ comes out to $-1.278$, which is not in the domain of $\sin^{-1}{\theta}$ (because it is not in the range of $\sin{\theta}$). The problem seems to be in the part of your expression for $\phi$ that is inside the inverse sine function, since it is generating values that are not in $[-1,1]$.
