首页 > 解决方案 > 将数学公式翻译成 JavaScript

问题描述

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

这条公式

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

标签: javascriptmath

解决方案


尝试以下

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

推荐阅读