【问题标题】:Performing Trigonometry in Javascript在 Javascript 中执行三角函数
【发布时间】:2012-04-10 09:30:20
【问题描述】:

如何在 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

【问题讨论】:

  • 您的计算器是否处于度数模式?真正的男人使用弧度。
  • 严肃地说,围绕单位圆一整圈是一个距离为 2Pi 的弧,这并非巧合的是该角度的弧度测量值。理解这一点,以及其他三角函数与单位圆的关系,会让你的生活变得更轻松。

标签: javascript trigonometry


【解决方案1】:
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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-12
    • 1970-01-01
    相关资源
    最近更新 更多