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 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).

**Return Value:** 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:

- When y-coordinate is greater than x-coordinate:
`<`

`script`

`type`

`=`

`"text/javascript"`

`>`

`document.write(Math.atan2(90, 15));`

`</`

`script`

`>`

Output:

1.4056476493802699

- When y-coordinate is smaller than x-coordinate
`<`

`script`

`type`

`=`

`"text/javascript"`

`>`

`document.write(Math.atan2(15, 90));`

`</`

`script`

`>`

Output:

0.16514867741462683

## leave a comment

## 0 Comments