In the equation $x\cos(\theta) + y\sin(\theta) = z$ how do I solve in terms of $\theta$? In the equation $$x\cos(\theta) + y\sin(\theta) = z,$$ how do I solve in terms of $\theta$? i.e $\theta = \dots$.
 A: 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.
A: There are various possible strategies.  I will mention one approach. Of course if there is a solution, there are infinitely many, since we can add $2\pi$ to any solution and get another solution.
Let's change notation a little. We are interested in the equation
$$a\cos\theta + b\sin\theta=q$$
Rewrite this equation as
$$\frac{a}{\sqrt{a^2+b^2}}\cos\theta+ \frac{b}{\sqrt{a^2+b^2}}\sin\theta=\frac{q}{\sqrt{a^2+b^2}}$$
Now let $\phi$ be the angle whose sine is $a/\sqrt{a^2+b^2}$ and whose cosine is $b/\sqrt{a^2+b^2}$.
By a formula that I hope is familiar (sine of a sum of angles), the equation can be rewritten as
$$\sin(\phi+\theta)=\frac{q}{\sqrt{a^2+b^2}}$$
Look at the right-hand side. If its absolute value is greater than $1$, there will be no (real) solution. Otherwise, for simplicity, call the right-hand side $w$.
Then we can write that
$\phi+\theta=\arcsin w$ or $\phi+\theta=\pi-\arcsin w$.  Now remember that whatever solutions you get through this process, anything obtained by adding $2n\pi$, where $n$ is an integer, to a solution, is also a solution.
The reason I went in detail through this approach is that in Physics, it is often important to express $a\cos\theta+b\sin\theta$ in the form $c\sin(\phi+\theta)$ that we used to solve the equation. There are other approaches.
A: Let us introduce $c=\cos \theta$. Then your equation reads
$$x c + s y \sqrt{1-c^2} =z$$
where $s=\pm 1$ is related to the quadrant of $\theta$ (+1 in the first and second quadrant and -1 in the third and forth). Subtracting $x c$ from both sides then squaring the equation yields
$$y^2 (1-c^2) = (z- xc)^2 = z^2 -2 zx c + x^2 c^2.$$
This is a quadratic equation with the solutions
$$ c_\pm = \frac{x z \pm y \sqrt{x^2+ y^2 - z^2}}{x^2 + y^2}.$$ In order that $c_\pm$ are real, we need $z^2 \leq x^2+y^2$. 
As we have squared the equation, we have to check whether $c_\pm$ solves the original equation. Indeed, $c_\pm$ solves the original equation with $s_\pm=\text{sgn}[(z-xc_\pm)/y]$. Therefore, we have the two solutions (mod $2\pi$)
$$\theta = s_\pm 
   \arccos(c_\pm).   $$
