in reply to Re: Lissajous curves
in thread Lissajous curves
Sure you can, but atan2 has a branch cut there so you have to know that it returns pi, not minus pi which would also make sense to me (though the IEEE 754 committee might have had a reason).
Update 2011-04-18: in fact, appendix F of the C99 standard states that atan2 with zero first argument and negative second argument gives pi with the sign copied from the zero. This guarantees that atan2(-1,0) must return positive pi. You can see that indeed perl will give negative pi for a negative zero first argument:
$ perl -wE '$x = -1; $x/=2 for 1..9999; $,=" "; say $x, atan2($x,-1), +atan2(0,-1);' -0 -3.14159265358979 3.14159265358979
|
|---|