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:
- Example 1: When y-coordinate is greater than x-coordinate:
<scripttype="text/javascript">document.write(Math.atan2(90, 15));</script>chevron_rightfilter_noneOutput:
1.4056476493802699
- Example 2: When y-coordinate is smaller than x-coordinate
<scripttype="text/javascript">document.write(Math.atan2(15, 90));</script>chevron_rightfilter_noneOutput:
0.16514867741462683
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
- Introduction to JavaScript Course | Learn how to Build a task tracker using JavaScript
- JavaScript Course | Understanding Code Structure in JavaScript
- JavaScript Course | Logical Operators in JavaScript
- JavaScript Course | Conditional Operator in JavaScript
- JavaScript Course | Data Types in JavaScript
- JavaScript Course | Printing Hello World in JavaScript
- JavaScript Course | Loops in JavaScript
- JavaScript Course | Functions in JavaScript
- JavaScript Course | JavaScript Prompt Example
- JavaScript Course | Variables in JavaScript
- JavaScript Course | Objects in JavaScript
- JavaScript Course | Operators in JavaScript
- JavaScript vs Python : Can Python Overtop JavaScript by 2020?
- How to include a JavaScript file in another JavaScript file ?
- this in JavaScript
Supported Browsers: The browsers supported by JavaScript Math.atan2( ) function are listed below:
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



