[英]Convert complex excel formula to javascript
To start I'm not that well versed in javascript and I'm trying to convert this complex excel formula to javascript without any luck. 首先,我不太精通javascript,并且试图将这个复杂的excel公式转换为javascript,但没有任何运气。
=DEGREES(ASIN(SIN(RADIANS(59.036))*SIN(RADIANS(150))))/2
Here's what I have so far 这是我到目前为止的
var x = DEGREES(Math.asin(Math.sin(RADIANS(59.036))*Math.sin(RADIANS(150))))/2
Obviously, DEGREES
and RADIANS
are wrong and I can't figure what the javascript equivalent would be. 显然,
DEGREES
和RADIANS
是错误的,我无法确定javascript等效的含义。
(BTW the correct answer is 5.831) (顺便说一句,正确答案是5.831)
Well, you could write your own DEGREES
and RADIANS
functions, which only involve a little math: 好吧,您可以编写自己的
DEGREES
和RADIANS
函数,它们只涉及一些数学运算:
function degrees(x) { return x * 180 / Math.PI; }
function radians(x) { return x * Math.PI / 180; }
var x = degrees(Math.asin(Math.sin(radians(59.036))*Math.sin(radians(150))))/2;
Define both functions yourself. 自己定义两个函数。 They are both trivial to implement.
它们都很容易实现。
function DEGREES(radians){
return (radians * 180 / Math.PI);
}
function RADIANS(degrees){
return (degrees / 180 * Math.PI);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.