Atan2

From Xojo Documentation
Jump to: navigation, search
Method

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

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)

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.

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, Xojo.Math.ATan2

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About