atan2 Function

Top  Previous  Next

Returns the arctangent of the quotient of its arguments, as a numeric value between PI and -PI radians.

Syntax

Math.atan2(number2, number1)

Arguments

number2A number representing the y coordinate of a point.
number1A number representing the x coordinate of a point.        

Return Value

A number which represents the counterclockwise angle in radians between the positive X axis and the point (number1, number2). The function returns NaN when given a NaN argument.

Remarks

The order of arguments is reversed; the function atan2(y, x) computes the angle corresponding to the point (x, y).

Examples

Math.atan2(0,1);          // Returns 0

Math.atan2(0,0);          // Returns 0

Math.atan2(-1000,0);       // Returns -1.570796

Math.atan2(-10000, -1000);     // Returns -1.670465

See also

Math.atan,