HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
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
The Math.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).
Parameter | Description |
y | Required. The y coordinate. |
x | Required. The x coordinate. |
Type | Description |
Number | PI to -PI.NaN if the values are empty or not numeric. |
Math.atan2()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |