If $x \cos\theta+y\sin\theta=a$ and $x\sin\theta-y\cos\theta=b$, then $\tan\theta=\frac{bx+ay}{ax-by}$. (Math Olympiad) I tried to solve it but I can’t get the answer. Please help me in proving this trig identity: 

If 
  $$x \cos\theta+y\sin\theta=a$$
  $$x\sin\theta-y\cos\theta=b$$ 
  then $$\tan\theta=\frac{bx+ay}{ax-by}$$

I've spent many hours trying.
Thanks in advance.

$x \cos\theta + y\sin\theta = a, \,\, x \sin\theta - y\cos\theta = b$. Therefore:
$$\dfrac{x \cos\theta + y\sin\theta}{x \sin\theta - y\cos\theta} = \dfrac{a}{b}$$
$$\implies \dfrac{x + y\tan\theta}{x \tan\theta - y} = \dfrac{a}{b}$$
$$\implies bx + by\tan\theta = ax \tan\theta - ay$$
$$\implies (ax - by) \tan\theta = bx + ay$$
$$\implies \tan\theta = \dfrac{bx + ay}{ax - by}$$
