Always use atan2 (y, x) instead of atan (y / x) for two reasons. One is mentioned by David Maimood (problems with x = 0). Another is that atan2 () works with the full range from - & pi; to + π; while atan () gives only the result between - π / 2 and + π / 2 and cannot distinguish between (x, y) = (2,2) and (x, y) = (-2, -2), since you lose sign information when doing the division, and pass only the quotient y / x to atan ().
source
share