![](/img/trans.png)
[英]Converting atan2 Excel code to R, to produce flow direction in Cartesian Coordinates
[英]atan2 function behaves different in javascript and excellsheet
我正在尝试atan2数学函数,但我在google excel表中得到了错误的价值。 但在javascript atan2函数中获取正确的值。 我怎样才能在excelsheet中获得该值?
我在excel中的价值是
atan2(8.6,2.7699)=0.3115
而在javascript中
atan2(8.6,2.7699)=1.259206466337312
我在这里检查了javascript值http://www.univie.ac.at/moe/rechner/rechner.html
任何人都可以说为什么会这样?
如果我想在excel中使用此值,那么我应该使用什么公式?
在Microsoft Excel中,atan2函数以相反的顺序获取参数,而Google Docs则为了一致性而做同样的事情。 如果您在javascript中翻转参数,则会得到相同的“错误”值。
Excel中atan2的函数签名是ATAN2( x _num, y _num),而在Javascript中它是Math.atan2( y,x ) 。 注意参数的顺序。
如果您按照适当的顺序提供参数,他们应该给出大致相同的答案。
Excel的ATAN2
需要x
-coordinate后跟y
坐标ATAN2(x,y)
但JavaScript ATAN2
的参数反转: ATAN2(y,x)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.