atan2 (Math.atan2 method)

public static atan2(y:Number, x:Number) : Number

Computes and returns the angle of the point y/x in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle). The return value is between positive pi and negative pi.

Availability: ActionScript 1.0; Flash Lite 2.0 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non-emulated math functions that Flash Player 5 supports.

Parameters

y:Number - A number specifying the y coordinate of the point.

x:Number - A number specifying the x coordinate of the point.

Returns

Number - A number.

Example

The following example returns the angle, in radians, of the point specified by the coordinates (0, 10), such that x = 0 and y = 10. Note that the first parameter to atan2 is always the y coordinate.

trace(Math.atan2(10, 0)); // output: 1.5707963267949

See also

acos (Math.acos method), asin (Math.asin method), atan (Math.atan method), cos (Math.cos method), sin (Math.sin method), tan (Math.tan method)