<s>[INST] Solving this equation for $\theta$ $$ 0 = x\cos\theta\cos\phi+y\sin\theta\cos\phi+z\sin\phi$$
Here's what I've tried doing.
$$\begin{align}
  x\cos\theta\cos\phi+y\sin\theta\cos\phi & = -z\sin\phi \\
  x\cos\theta+y\sin\theta & = -z\tan\phi \\
  x\cos\theta+y\sqrt{1-\cos^2\theta} & = -z\tan\phi \\
  y\sqrt{1-\cos^2\theta} & = -x\cos\theta-z\tan\phi \\
  y^2-y^2\cos^2\theta & = x^2\cos^2\theta-z^2\tan^2\phi+2xz\cos\theta\tan\phi \\
  0 & = (x^2+y^2)\cos^2\theta+2xz\tan\phi\cos\theta-y^2-z^2\tan^2\phi
\end{align}$$
$$\begin{align}
  \cos\theta & = \frac{-2xz\tan\phi\pm\sqrt{4x^2z^2\tan^2\phi-4(x^2+y^2)(-y^2-z^2\tan^2\phi)}}{2(x^2+y^2)} \\
  \cos\theta & = \frac{-2xz\tan\phi\pm2\sqrt{x^2z^2\tan^2\phi+y^2(x^2+y^2)-x^2z^2\tan^2\phi-y^2z^2\tan^2\phi}}{2(x^2+y^2)} \\
  \cos\theta & = \frac{-xz\tan\phi\pm y\sqrt{x^2+y^2-z^2\tan^2\phi}}{x^2+y^2} \\
\end{align}$$
However, the $\pm$ is throwing me off. I'm assuming that either the $+$ or $-$ gives a complex solution or something, but I'm not sure what.
 [/INST] HINT :
$$
x\cos\theta+y\sin\theta=r\cos(\theta-\alpha),
$$
where $r^2=x^2+y^2$ and $\tan\alpha=\dfrac{y}{x}$. You may refer to this link.
$$\\$$

$$\Large\color{blue}{\text{# }\mathbb{Q.E.D.}\text{ #}}$$
</s>