A puzzling step in a solution for "Find $\sin(x)$ and $\cos(x)$, if $a\sin(x)+b\cos(x)=c$" A textbook problem:

Find $\sin(x)$ and $\cos(x)$, if $a\sin(x)+b\cos(x)=c$

The solution from the textbook:

Let's divide each term of this equation by $\sqrt{a^2+b^2}$:
  $$\frac{a}{\sqrt{a^2+b^2}}\sin(x)+\frac{b}{\sqrt{a^2+b^2}}\cos(x)=\frac{c}{\sqrt{a^2+b^2}}$$
  Since the sum of squares of $\frac{a}{\sqrt{a^2+b^2}}$ and $\frac{b}{\sqrt{a^2+b^2}}$ equals 1, then there will always exist an angle, let's call it $\phi$, for which 
  $$\sin(\phi)=\frac{a}{\sqrt{a^2+b^2}};$$
  $$\cos(\phi)=\frac{b}{\sqrt{a^2+b^2}}$$
  Using this, let's transform our equation to
  $$\sin(\phi)sin(x)+cos(\phi)cos(x)=\frac{c}{\sqrt{a^2+b^2}}$$
  This will bring us to
  $$\cos(x-\phi)=\frac{c}{\sqrt{a^2+b^2}}$$ 

This I understand. But the next step is:

It is evident from this that 
  $$\sin(x-\phi)=\pm\frac{\sqrt{a^2+b^2-c^2}}{\sqrt{a^2+b^2}}$$

Could you give me a hint regarding this last transformation? 

Using Anurag A's hint, 
$$\sin(x-\phi)=\pm\sqrt{1-\cos^2(x-\phi)}$$ 
Since 
$$\left(\frac{a}{\sqrt{a^2+b^2}}\right)^2+\left(\frac{b}{\sqrt{a^2+b^2}}\right)^2=1,$$
$$\sin(x-\phi)=\pm\sqrt{\left(\frac{a}{\sqrt{a^2+b^2}}\right)^2+\left(\frac{b}{\sqrt{a^2+b^2}}\right)^2-\left(\frac{c}{\sqrt{a^2+b^2}}\right)^2};$$ 
$$\sin(x-\phi)=\pm\frac{\sqrt{a^2+b^2-c^2}}{\sqrt{\left(\sqrt{a^2+b^2}\right)^2}}=\pm\frac{\sqrt{a^2+b^2-c^2}}{\sqrt{a^2+b^2}}$$
