From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Global Method

Atan2(y as Double, x as Double) As Double

Supported for all project types and targets.

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.


result = Atan2 (y, x)

Part Type Description
result Double Arctangent of the point (y, x) in radians.
y Double y coordinate of the point.
x Double x coordinate of the point.


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


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

Var 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