math.atan2
JavaScript | Math.atan2()方法 (JavaScript | Math.atan2() Method)
Math.atan2() is a function in math library of JavaScript that is used to find the arctangent of the quotient of its arguments. The method will return the numeric value which is the angle of (x,y) point and x-axis.
Math.atan2()是JavaScript数学库中的函数,用于查找其参数商的反正切。 该方法将返回作为(x,y)点和x轴角度的数值。
Syntax:
句法:
Math.atan2(y,x);
Parameter(s):
参数:
y,x – represent the y and x co-ordinates on the point.
y,x –代表该点的y和x坐标。
Return value:
返回值:
The return type of this method is number, it returns the arctangent of the quotient of its parameter.
该方法的返回类型为number ,它返回其参数的商的反正切值。
Technical Insights:
技术见解:
JavaScript version: ECMAScript 1
JavaScript版本:ECMAScript 1
Browser support: Chrome, Internet Explorer, Mozilla, Safari, Opera mini
浏览器支持:Chrome,Internet Explorer,Mozilla,Safari,Opera mini
Values accepted: Integer, floating-point, numeric string.
接受的值:整数,浮点数,数字字符串。
Invalid Values: non-numeric string, empty variable, empty array all will return NaN(Not a Number).
无效值:非数字字符串,空变量,空数组都将返回NaN (非数字)。
Example 1: Valid values for the method
示例1:方法的有效值
console.log(Math.atan2(2, 5));
console.log(Math.atan2(10.98, 2.3));
console.log(Math.atan2(-3.32, -1.23));
console.log(Math.atan2(0, 0));
console.log(Math.atan2("7.18", -9.23));
Output
输出量
0.3805063771123649
1.364310108279956
-1.9256000757252791
0
2.4804744828642002
Example 2: Invalid values for the method.
示例2:方法的无效值。
console.log(Math.atan2("IncludeHelp"));
// Output: NaN
console.log(Math.atan2(1 + 5i));
// Output: Uncaught SyntaxError: Invalid or unexpected token
翻译自: https://www.includehelp.com/code-snippets/math-atan2-method-with-example-in-javascript>javascript.aspx
math.atan2