Namespaces
Variants
Views
Actions

Talk:cpp/numeric/math/atan2

From cppreference.com

Could it be that this graphic: http://upload.cppreference.com/mwiki/images/thumb/9/91/math-atan2.png/285px-math-atan2.png is wrong?

Im working with the g++ and after 2 hours i figured out, that std::atan2 has the same behavior like the matlab atan2-function:

http://www.mathworks.de/help/techdoc/ref/atan2.html

Look at the quadrants: Matlab's atan2 is positive for all y > 0, so it's different from the graphic in this article.

62.206.211.29 00:27, 16 May 2012 (PDT)

atan2 is not always positive when y is positive. Take for example x=-1, y=1. atan2(x,y) = atan(y/x) = atan(-1) = -0.78540.
try ezsurf ( @(x,y) atan2(x,y) ) in matlab to see a 3D plot --Bazzy 12:21, 16 May 2012 (PDT)
I think there's some confusion here. Remember that atan2 takes y as the first argument, not x. atan2(-1,1) corresponds to x=1, y=-1, and is -0.78540. At x=-1, y=1, we'd use atan2(1,-1) which is 2.3. In fact, for every positive value of y, atan2 is positive. And unless I'm mistaken, that's exactly what the diagram in question shows -- the upper half of the square corresponds to positive y, and only contains positive atan2 values. --Nate 13:30, 16 May 2012 (PDT)
I've already fixed the plot, hence the confusion. It indeed was incorrect previously. -- P12 14:09, 16 May 2012 (PDT)