Forum Discussion
GLW1964
Mar 12, 2022Copper Contributor
atan2 has parameters swapped
atan2(x,y) is returning the value of atan2(y,x). for example, if you put this in an Excel cell you should get 30 but get 60. =degrees(atan2(sin(radians(30)), cos(radians(30)))
mtarler
Mar 12, 2022Silver Contributor
actually no I think it is correct. Remember that Sin is opposite over hyp so essentially the y coordinate and cos is adj over hyp so essentially x component so your equation is actually giving y,x and returning 60. I can draw it out if you like.
- GLW1964Mar 12, 2022Copper Contributor
mtarler So, what has thrown me is I expect, in spite of the argument names, for the function to take atan2(opposite, adjacent) since the tangent is opposite over adjacent. But, the name x does imply the adjacent, so I concede. Code libraries I have worked with are of the form arc2(opposite, adjacent) so that is what I was expecting. Python for example has atan2(y,x). A\This is a case of what you expect to see keeping you from seeing what is actually in the documentation.