Atan2 Function

Returns the arctangent of the point whose coordinates are x and y. The arctangent is the angle from the x-axis to a line drawn through the origin (0,0) and a point with coordinates x, y.

Syntax

result = Atan2( y, x )


Parameters

y

Double

y coordinate of the point.

x

Double

x coordinate of the point.



Notes

The result is expressed in radians. To convert it to degrees, multiply it by 180/PI.

The converse operations are done with Cos and Sin. That is, if you have an angle and want to find an x, y pair along the line described by 0,0 and x,y, you can do so with:

x = Cos(angle)*radius
y= Sin(angle)*radius

Examples

This example uses the Atan2 function to return the arctangent of a point directly above the origin.

Dim d as Double
Const PI=3.14159265358979323846264338327950
d=Atan2(1,0) //returns 1.57
d=Atan2(1,0)*180/PI //returns 90

See Also

Atan, Tan functions.