Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 821
Don Neufeld Avatar asked Jun 25 '09 18:06

Don Neufeld


People also ask

Should I use atan or atan2?

atan2(y,x) is generally used if you want to convert cartesian coordinates to polar coordinates. It will give you the angle, while sqrt(x*x+y*y) or, if available, hypot(y,x) will give you the size. atan(x) is simply the inverse of tan.

What is the action of function atan2 X Y?

atan2() function returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y), for Math. atan2(y,x) .

What is atan2 X Y?

ATAN2(y,x) returns the arc tangent of the two numbers x and y. It is similar to calculating the arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of the result. The result is an angle expressed in radians. To convert from radians to degrees, use the DEGREES function.

What is the difference between atan and atan2 in Matlab?

The four-quadrant inverse tangent, atan2(Y,X) , returns values in the closed interval [-pi,pi] based on the values of Y and X , as shown in the graphic. In contrast, atan(Y/X) returns results that are limited to the interval [-pi/2,pi/2] , shown on the right side of the diagram.


1 Answers

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

like image 152
CookieOfFortune Avatar answered Sep 17 '22 18:09

CookieOfFortune