what is the difference between atan and atan2 in c++ ?
+4
A:
atan2
allows calculating the arctangent of all four quadrants. atan
only allows calculating from, if I remember right, quadrants 1 and 4.
Chris Jester-Young
2008-11-12 09:22:19
I really disagree with this blind posting of Wikipedia links. The point of SO is to encourage communication between programmers, and for other programmers to be able to benefit from the questions asked. I will now know if I need it in the future, that atan and atan2 exist, and what the diffs are.
endian
2008-11-12 09:27:59
Fair enough. I didn't know the answer myself, but I hoped the link might provide useful information for the asker.
xan
2008-11-12 09:36:12
+1
A:
atan(x) Returns the principal value of the arc tangent of x, expressed in radians.
atan2(y,x) Returns the principal value of the arc tangent of y/x, expressed in radians.
Notice that because of the sign ambiguity, a function cannot determine with certainty in which quadrant the angle falls only by its tangent value (atan alone). You can use atan2 if you need to determine the quadrant.
Roman M
2008-11-12 09:22:49
+2
A:
Another thing to mention is that atan2 is more stable when computing tangents using an expression like atan(y/x) and x is 0 or close to 0.
Laserallan
2008-11-12 17:03:16