Java bug with ATAN2

Ok… i think i just tripped across a java bug in the Math.atan2(x,y) operation.

Atan2 should return the following results.


X	Y			Atan2
1	1			0.785398163
-1	1			2.35619449
1	-1			-0.785398163
-1	-1			-2.35619449


but if you run Atan2 with 1, -1 you dont get -0.78… instead you get 2.356!

Not sure if this is true for all versions of java… can anyone try this out and see what you get?

thanks!
j.

just tried the same code on another machine and the function works as expected.
So its likely this bug is isolated to a specific release of java.

arg… i may have found my cause… (face to palm)
in Java atan2 is y, x instead of x,y
groan…

But you are aware, that it’s [icode]atan2(y, x)[/icode]?

Either you turned that around, or the implementation turned that around.

Ninja’d :frowning:

matheus your right on the money…

in my math i was calculating the angle so i could do some math against its specific coordinates.

i looked up the atan2 operation and everywhere i looked it was standardized on x, y
but the javadoc for Math.atan2 is y,x and i missed it .

of course i dont find that till i post up here (after being stuck for a day and a bit, trying to figure out why my math was not working )
lolz…

such is the way… back to happy coding now i guess.

j.