JavaScript Math atan2() Method (original) (raw)

Last Updated : 01 Aug, 2023

Javascript **Math.atan2() method 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 method accepts two parameters as mentioned above and described below:

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

Below are examples of the **Math atan2() Method.

**Example 1: When the y-coordinate is greater than the x-coordinate:

JavaScript `

console.log(Math.atan2(90, 15));

`

**Example 2: When y-coordinate is smaller than x-coordinate

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

JavaScript `

console.log(Math.atan2(15, 90));

`

Output

0.16514867741462683

**Example 3: When y-coordinate is the same as x-coordinate

JavaScript `

console.log(Math.atan2(90, 90));

`

We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article.

**Supported Browsers: