Result.f = ATan2(x.f, y.f)
Calculates the angle in radian between the x axis and a line drawn in the direction specified by 'x' and 'y'. It can be used to calculate angles between lines in 2D or to transform rectangular coordinates into polar coordinates.


x.f, y.f The direction of the line to calculate the angle from. Zero values are allowed.

Return value

Returns the resulting angle in radian. The result can be transformed into degrees using the Degree() function.


This function calculates the value ATan(y/x) and examines the sign of x and y to place the angle in the correct quadrant. It also handles the cases where y is zero to avoid division by zero errors.

The result is always between -#PI and +#PI. Negative angles indicate that the line is below the x axis, positive values indicate that line is above the x axis. If 'x' and 'y' are zero then the function returns 0.

This function can handle float and double values.


  Debug ATan2(10, 10) ; will display #PI/4 (45 degrees in radian)

See Also

ATan(), Degree()

Supported OS


<- ATan() - Math Index - ATanH() ->