编辑:很明显,经过许多不同的方法之后,我在atan2中犯了ann错误,但仍然很想找到公式。
我读过多个主题和文章,但不明白为什么atan和atan2在转换成学位后给出了不同的结果。下面是我的例子(来自CIElab颜色空间) x -79.7751, y 2.677374209。在这两种情况下,不对代码进行任何更改的计算都会提供不正确的值:
atan(-79.7751 / 2.677374209) = -1,537 / or in degrees -88,07778762
atan2(-79.7751 , 2.677374209) = 3,1258 / or in degrees 179,0965但是,该示例来自文章,因此我们可以检查结果。基本上答案应该是271.9222。我在互联网上发现了对atan的修正,现在我得到了同样的结果,但是x=y=0在atan中的值仍然是不确定的,因此应该对atan2做一些修正。不幸的是,我没有找到任何能产生同样结果的结果,而且会被证明(我指的是在文献中可以找到的)。CIElab的大多数来源都说使用atan2 而不进行任何更正,而且在我的特定情况下,您可以这样做是不正确的。这是我在这件事上得到的:
atan(-79.7751 / 2.677374209) = -1,537 / for atan < 0 : atan + 2pi
hence atan = 4,7459 / or in degrees 271,922 ( BINGO! )
atan2(-79.7751 , 2.677374209) = ̶3̶,̶1̶2̶5̶8̶ 3,108 / or in degrees ̶1̶7̶9̶,̶0̶9̶6̶5̶ 178,0777876
now convert, for deg > 90 : 450 - deg
atan2 result 271,922atan2 a̶a̶y̶o̶u̶̶c̶a̶n̶̶s̶e̶e̶,̶̶̶c̶l̶o s̶e̶b̶o̶̶e̶e̶l̶o s̶e̶b̶o̶e̶e̶,̶̶̶c̶l̶o u̶o̶of a̶o̶̶y̶u̶̶c̶a̶n̶e̶e̶,̶̶̶c̶l̶o f̶n̶̶e̶e̶e̶,̶̶̶c̶l̶o s̶e̶̶e̶b̶o?̶e̶of̶of̶o of̶of̶̶c,c l l s o to t l r,r r,b,c,y,f,r,b,y,y,1,d,e,b,e,t,e,b,e,n,n,r,n,r,n,n,r,n,n
https://stackoverflow.com/questions/51467097
复制相似问题