ATan2()

Syntax

Result.f(.d) = ATan2(x.f(.d), y.f(.d))
Description
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.

Parameters

 x.f, y.f or x.d, y.d 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.

Remarks

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.0.

This function handles and returns float or double values.

Example

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