The Wayback Machine - https://web.archive.org/web/20240204104824/https://www.geeksforgeeks.org/javascript-math-atan2-method/
Open In App
Related Articles

JavaScript Math atan2() Method

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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:  

  • value1: This parameter represents the y-coordinate.
  • value2: represents x-coordinate of the point (x,y).

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


Output

1.4056476493802699

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


Output

0.7853981633974483

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: 

  • Google Chrome 1 and above
  • Firefox 1 and above
  • Opera 3 and above
  • Safari 1 and above 

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about!


Last Updated : 01 Aug, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials