在Javascript中执行三角函数

3
我应该如何在Javascript中执行以下数学问题:

如何在Javascript中实现以下数学问题:

Tan(x) = 450/120;
x      = 75;
// In my calculator I use tan^-1(450/120) to find the answer
// How do I perform tan^-1 in javascript???

我的javascript代码输出的结果不正确:

var x = Math.atan(450/120);
alert(x); // says x = 1.3101939350475555

// Maybe I am meant to do any of the following...
var x = Math.atan(450/120) * (Math.PI/2); // still wrong answer
var x = Math.tan(450/120);  // still wrong answer

3
你的计算器是在角度模式下吗?真正的男人使用弧度。 - J. Holmes
1
说真的,一个完整的单位圆周是一条弧线,距离为2Pi,这恰好是弧度角的测量值。理解这一点以及其他三角函数与单位圆之间的关系将使你的生活变得更加轻松。 - J. Holmes
1个回答

10
var x = Math.atan(450/120);

给出了75度转化为弧度后的答案:1.3101939350475555

要得到正确的答案,只需将其转换为角度:

var x = Math.atan(450/120) * (180/Math.PI);
alert(x); // says x is 75.06858282186245

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接