有什么方法可以用 asin/acos/atan 函数 JavaScript 获得弧度吗?
Is there any way to get radians with asin/acos/atan functions JavaScript?
我目前正在使用 Math.js 库来处理数学方程式。
我知道可以使用 "deg" 或 "rad" 以及三角函数 sin()、cos()、tan() 将弧度转换为度数。但是对于 arcs 函数 asin(), cos(), tan() 它似乎不起作用。
如果除了手动计算之外还有其他方法。
test= math.eval("sin(1 deg)"); //Works
test2 = math.eval("sin(1 rad)"); //Works
test3= math.eval("asin(1 deg)"); //Does not work
test4 = math.eval("asin(1 rad)"); //Does not work
你应该使用,
math.eval("asin(1)");
反正弦是以数字为输入值的反三角函数
如 documentation 所指,asin(x) 需要 number 值,而 deg 不是。
三角函数的参数(以及反三角函数的 return 值)是一个 弧度 的数字。要使用度数,乘以或除以 Math.PI/180
.
Math.sin(45 * Math.PI/180) --> -.7071...
Math(Math.arctan(1)) * 180/Math.PI --> 45 (degrees)
如果您使用的是弧度,请不要乘以或除以该系数。
Math.asin(1) --> 1.57... (radians)
Math.asin(1) * 180/Math.PI --> 90 (or something close; in degrees)
我目前正在使用 Math.js 库来处理数学方程式。
我知道可以使用 "deg" 或 "rad" 以及三角函数 sin()、cos()、tan() 将弧度转换为度数。但是对于 arcs 函数 asin(), cos(), tan() 它似乎不起作用。 如果除了手动计算之外还有其他方法。
test= math.eval("sin(1 deg)"); //Works
test2 = math.eval("sin(1 rad)"); //Works
test3= math.eval("asin(1 deg)"); //Does not work
test4 = math.eval("asin(1 rad)"); //Does not work
你应该使用,
math.eval("asin(1)");
反正弦是以数字为输入值的反三角函数
如 documentation 所指,asin(x) 需要 number 值,而 deg 不是。
三角函数的参数(以及反三角函数的 return 值)是一个 弧度 的数字。要使用度数,乘以或除以 Math.PI/180
.
Math.sin(45 * Math.PI/180) --> -.7071...
Math(Math.arctan(1)) * 180/Math.PI --> 45 (degrees)
如果您使用的是弧度,请不要乘以或除以该系数。
Math.asin(1) --> 1.57... (radians)
Math.asin(1) * 180/Math.PI --> 90 (or something close; in degrees)