JavaScript | Math.atan2( )

The Math.atan2() function in JavaScript is used to return the arctangent of the quotient of its arguments. The Math.atan2() method returns a numeric value between -Π and Π representing the angle theta of an (x, y) point and the positive x-axis. This is the counterclockwise angle, measured in radians, between the positive X-axis, and the point (x, y).

Syntax:

Math.atan2(value1, value2)

Parameters: This function accepts two parameters value1 and value2. value1 represents the y-coordintae and value2 represents x-coordinate of the point (x,y).



Returns: It returns the arctangent of the quotient of its arguments.

Examples:

Input  : Math.atan2(90, 15);  
Output : 1.4056476493802699

Input  : Math.atan2(15, 90);
Output : 0.16514867741462683

Below programs illustrate the Math.atan2() function in JavaScript: