Why are the arguments to atan2 Y,X rather than X,Y?

Don Neufeld picture Don Neufeld · Jun 25, 2009 · Viewed 8.9k times · Source

In C the atan2 function has the following signature:

double atan2( double y, double x );

Other languages do this as well. This is the only function I know of that takes its arguments in Y,X order rather than X,Y order, and it screws me up regularly because when I think coordinates, I think (X,Y).

Does anyone know why atan2's argument order convention is this way?

Answer

CookieOfFortune picture CookieOfFortune · Jun 25, 2009

Because I believe it is related to arctan(y/x), so y appears on top.

Here's a nice link talking about it a bit: Angles and Directions