JavaScript atan2() Method

## JavaScript Reference

Overview

## JavaScript Objects

JS Array JS Boolean JS Date JS Math JS Number JS String JS RegExp JS Global

## Browser Objects

Window Navigator Screen History Location

## HTML DOM Objects

DOM Document DOM Elements DOM Attributes DOM Events

## HTML Objects

DOM Anchor DOM Area DOM Base DOM Body DOM Button DOM Form DOM Frame/IFrame DOM Frameset DOM Image DOM Input Button DOM Input Checkbox DOM Input File DOM Input Hidden DOM Input Password DOM Input Radio DOM Input Reset DOM Input Submit DOM Input Text DOM Link DOM Meta DOM Object DOM Option DOM Select DOM Style DOM Table DOM td / th DOM tr DOM Textarea

# JavaScript atan2() Method

JavaScript Math Object

## Examples

## Example 1 - atan2(y,x)

Assume you had a point with the (x,y) coordinates of (4,8), you could calculate the angle in radians between that point and the positive X axis as follows:

Math.atan2(8,4);

The output of the code above will be:

1.1071487177940904

Try it yourself »

## Definition and Usage

The atan2() method returns the arctangent of the quotient of its arguments, as a numeric value between PI and -PI radians.

The number returned represents the counterclockwise angle in radians (not degrees) between the positive X axis and the point (x, y).

Note: With atan2(), the y coordinate is passed as the first argument and the x coordinate is passed as the second argument.

## Browser Support

The atan2() method is supported in all major browsers.

## Syntax

Math.atan2(y,x)

Parameter | Description
--- | ---
y | Required. A number representing the y coordinate
x | Required. A number representing the x coordinate

## Return Value

Type | Description
--- | ---
Number | A Number, from PI to -PI, or NaN if the value(s) are empty

## Technical Details

JavaScript Version: | 1.0

JavaScript Math Object

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE