I have a question. What's the difference between atan
and atan2
in JavaScript?
I want to figure out the angle between the vector V (-1, 0) and the axis.
When I called the method atan(0 / -1)
, the answer was -0 rad.
When I called the method atan2(0, -1)
, the answer was Pi rad.
Why do they have different answers?
Also, the answer I was expecting to get was Pi rad, so since I was using atan
in my code, it kinda took me a while until I tried atan2
and it finally worked (to my surprise!)
Thanks in advance! ^_^