Archive: Jus Wonderin


4th July 2007 06:31 UTC

Jus Wonderin
Is there any difference between atan(a/b) and atan2(a,b)?


7th July 2007 12:39 UTC

i think it's faster because it's implemented so it doesn't have to translate the 'a/b' from avs-code to "computer-code" anymore.
but the difference will be hardly noticeable if you don't use it in the pixelbox with, say, n=5000 so it'll be executed 5000 times per frame.

gc


7th July 2007 16:02 UTC

Ok, so It's just a bit faster then?

Edit: I just tested it and I got 120+-5 fps for atan and only 90+-5 fps for atan2.

???

Why would there be an atan2 function then? Try it on your PC. Maybe it varies between processors, or somthin. Use this preset. Just change the atan func. to atan2.


7th July 2007 16:17 UTC

I had to post a new reply because apparently you cant attatch a file while editing


9th July 2007 05:58 UTC

it seems you're right... strange.

but now i remember that in pak-9's programming tutorial he says that atan2 comes with some additional features like avoiding division by zero and some wrapping around the "ends" of a circle [you know, between r=0 and r=2*$PI]
/looks into the guide
hm can't find it now, maybe he told me on irc one time, i don't know.
when i use atan instead of atan2 in a movement there are some glitches to be found but they really are minor. and there's a small dot in the middle of the screen. plus it's slightly slower than atan2.
so i think it might actually be sometimes faster to use atan(a/b) than atan2(a,b) in an ssc but i'll stick to atan2 in movements.

but have a look [it's all in the movement]:


9th July 2007 10:47 UTC

I see what you mean. The edges look so much smoother in atan2, and there is no dot in the middle. I did get about 3 fps faster in atan2 also.


11th July 2007 13:33 UTC

atan2 returns the correct angle that the vector (a,b) makes with the x-axis....atan(b/a) returns, well just that.
like atan((-3)/4) and atan(4/(-3)) will be the same but atan2 wont be.


11th July 2007 17:23 UTC

atan((-3)/4) and atan(4/(-3)) are different. The thing is, atan(4/-3) and atan2(4,-3) are not the same. I found something in an AVS preset. Anyone wanna process it and explain?