Math.atan2

Returns the arctangent of the quotient of its arguments.

Method of Math
Static

Syntax

atan2( y, x )

Parameters

Parameter Description
y, x Number

Description

The atan2 method returns a numeric value between -pi and pi representing the angle theta of an (x,y) point. This is the counterclockwise angle, measured in radians, between the positive X axis, and the point (x,y). Note that the arguments to this function pass the y-coordinate first and the x-coordinate second.
atan2 is passed separate x and y arguments, and atan is passed the ratio of those two arguments.

Because atan2 is a static method of Math, you always use it as Math.atan2(), rather than as a method of a Math object you created.

Examples

The following function returns the angle of the polar coordinate:

If you pass getAtan2 the values (90,15), it returns 1.4056476493802699; if you pass it the values (15,90), it returns 0.16514867741462683.

See also

Math.acos, Math.asin, Math.atan, Math.cos, Math.sin, Math.tan

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.