TITLE: In the equation $x\cos(\theta) + y\sin(\theta) = z$ how do I solve in terms of $\theta$?
QUESTION [6 upvotes]: In the equation $$x\cos(\theta) + y\sin(\theta) = z,$$ how do I solve in terms of $\theta$? i.e $\theta = \dots$.

REPLY [4 votes]: This expands my comment above. As I wrote here "certain trigonometric equations such as the linear equations in $\sin x$ and $\cos x$ can be solved by a resolvent quadratic equation. One method is to write the $\sin x$ and $\cos x$ functions in terms of (...) $\tan$ of the half-angle".
Applying this method, since 
$$\cos \theta =\frac{1-\tan ^{2}\frac{\theta }{2}}{1+\tan ^{2}\frac{\theta }{2%
}}\qquad\text{and}\qquad\sin \theta =\frac{2\tan \frac{\theta }{2}}{1+\tan ^{2}\frac{\theta }{2}},$$
your equation is equivalent to
$$x\frac{1-\tan ^{2}\frac{\theta }{2}}{1+\tan ^{2}\frac{\theta }{2}}+y\frac{%
2\tan \frac{\theta }{2}}{1+\tan ^{2}\frac{\theta }{2}}=z.$$
Let $u=\tan \frac{\theta }{2}$. Then we can write it as
$$\left( x+z\right) u^{2}-2yu+z-x=0,$$
which has the solutions
$$u=\tan \frac{\theta }{2}=\frac{1}{2\left( x+z\right) }\left( 2y\pm2\sqrt{%
y^{2}+x^{2}-z^{2}}\right).$$
Thus 
$$\theta =2\arctan \left( \frac{1}{ x+z }\left( y\pm %
\sqrt{y^{2}+x^{2}-z^{2}}\right) \right) +2n\pi,\qquad n\in\mathbb{Z} .$$
This method is valid iff $\theta \neq (2k+1)\pi $, with $k\in\mathbb{Z}$. 
A different technique is to use an auxiliary angle.