JavaScript atan2 () method
Examples
Examples 1 - atan2 (y, x)
Specify a coordinate (x, y), the coordinate values (4,8), used to atan2 is () method to calculate the angle between the X-axis coordinate of the arc, the following examples:
Math.atan2(8,4);
The above example output:
1.1071487177940904
Definition and Usage
atan () method returns the arctangent of a number.
The returned value represents the angle of curvature of the coordinates (x, y) and the X axis.
Note: atan2 () has two parameters, y coordinates are passed as the first parameter, X coordinates passed as the second parameter.
Browser Support
All major browsers support atan2 () method
grammar
Math.atan2( y , x )
参数 | 描述 |
---|---|
y | 必须。一个数字代表Y坐标 |
x | 必须。 一个数字代表x坐标 |
return value
类型 | 描述 |
---|---|
Number | x 的反正切值。返回的值是 -PI/2 到 PI/2 之间的弧度值。 |
technical details
JavaScript version: | 1.0 |
---|