Calculating cosine when given sine and quadrant