将数学公式转换为JavaScript

将数学公式转换为JavaScript,javascript,math,Javascript,Math,我想把这个数学公式翻译成JS: 我试图在第一部分中使用tan^-1,但出现了一个错误。尝试以下方法 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.

我想把这个数学公式翻译成JS:

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

尝试以下方法

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);
}
试试下面的方法

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);
}

它指的是反切线。您可以使用'Math.atan()'函数获取反正切@蒂姆亨特:谢谢!!!!=),最后,res是这样的:Math.atan(2*LMath.sin(α))/(2*LMath.cos(α)+w*Math.sin(α))????对吗?不,因为什么是
LMath
?JS引擎没有意识到这是什么。你需要指定乘法。别忘了L和数学函数之间的*。它应该是
2*L*Math.sin(a)
etc.。它指的是反切线。您可以使用'Math.atan()'函数获取反正切@蒂姆亨特:谢谢!!!!=),最后,res是这样的:Math.atan(2*LMath.sin(α))/(2*LMath.cos(α)+w*Math.sin(α))????对吗?不,因为什么是
LMath
?JS引擎没有意识到这是什么。你需要指定乘法。别忘了L和数学函数之间的*。这将是
2*L*Math.sin(a)
etc。。。。