I don't think you need to get that complicated. Just use the definitions of sine and cosine within the right triangle with sides x, y, r, and the fact that if one angle is A, the other is 90 - A, and vice versa. So cos(90 - A) = x/r = sin(A) directly.