在Javascript中执行三角运算

在Javascript中执行三角运算,javascript,trigonometry,Javascript,Trigonometry,如何在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.3101939350475

如何在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
以弧度为单位给出75度的答案,即:1.310193935047555

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

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

你的计算器处于度数模式吗?真正的男人使用弧度。严肃地说,围绕一个单位圆旋转一整圈就是一个距离为2Pi的圆弧,这并非巧合,而是用弧度来测量角度。了解这一点,以及其他三角函数与单位圆之间的关系,将使你的生活更加轻松。
var x = Math.atan(450/120) * (180/Math.PI);
alert(x); // says x is 75.06858282186245