将数学公式转换为JavaScript

时间:2019-01-14 23:09:24

标签: javascript math

我正在尝试将此数学公式转换为JS:

this piece of formula

我尝试在第一部分中使用tan^-1,但出现错误。

1 个答案:

答案 0 :(得分:3)

尝试以下

function phi_i (l, w, phi) {
   // Check and set defaults for the parameters l, w and phi in case the are not set properly ...
   var arg = 2 * l * Math.sin(phi) / ( 2 * l * Math.cos(phi) - w * Math.sin(phi) );
   return Math.atan(arg);
}