I may not understand your question.
However, to start, r is the hypotenuse of a triangle formed by the axes and an angle.
is true because cosine is the adjacent side (a) over the hypotenuse (r), so this is just solving for a. This is similar with solving for b as well, but it is the side opposite the angle, so we use sine instead of cosine.
Pythagorean theorem says that for a right triangle , so when we substitute the above this gives us .
If you elaborate more on your question, that would help me.