Archive: atan2???


14th January 2002 20:35 UTC

atan2???
Although I only really do the MilkDrop presets I suppose this is the best place to ask this, as it was copied from AVS.

What does the atan2 (and exp) function do??

I know it is not documented but hopefully someone out there can explain - hopefully so I can understand;)?

Thanks in advance,

Rovastar


14th January 2002 20:53 UTC

Explanation
exp(a) is the same as pow(e, a), where e is euler's constant (2.7182..., the base of natural logarithms).

atan2(y,x) calculates the arctangent of (y/x), except that it checks the quadrants the point (x,y) is in and wether or not x equals zero. Atan2 is very handy to from rectangular to polar coordinates:

r = atan2(y,x)
d = sqrt(sqr(x)+sqr(y)) -> pythagoras' formula

This is the normal way it's done, however because AVS puts "0 rotation" on the vertical axis at the top (instead of on the horizontal axis on the right, as is usually done), you'll have to switch around y and x in atan2 and add a minus sign. Can't tell you out of the top of my head which it is.

I'm not sure who 'discovered' these two functions first, but I had been using atan2() without knowing it wasn't documented: it's a standard function in the C math library and I used it by habit. By nosing around inside vis_avs.dll I found exp(). It could be me, could be someone else :)


14th January 2002 21:04 UTC

Thanks UnConeD for the speedy reply that explains a lot.

As I am speaking mainly from a MilkDrop point of view and all the function code was copied from AVS. UnConeD as you are pretty clued up on this stuff is this all the commands that are available for AVS. Or are there more - I suppose some might not be in AVS.
Or where is the 'current' list of functions in AVS.

The following operators are available:
= : assign
+,-,/,* : plus, minus, divide, multiply
| : convert to integer, and do bitwise or
& : convert to integer, and do bitwise and
% : convert to integer, and get remainder
The following functions are available:
abs(var) : returns the absolute value of 'var'
sin(var) : returns the sine of the angle var (expressed in radians)
cos(var) : returns the cosine of the angle var
tan(var) : returns the tangent of the angle var
asin(var) : returns the arcsine of var
acos(var) : returns the arccosine of var
atan(var) : returns the arctangent of var
sqr(var) : returns the square of var
sqrt(var) : returns the square root of var
pow(var,var2) : returns var to the power of var2
log(var) : returns the log base e of var
log10(var) : returns the log base 10 of var
sign(var) : returns the sign of var or 0
min(var,var2) : returns the smalest value
max(var,var2) : returns the greatest value
sigmoid(var,var2) : returns sigmoid function value of x=var (var2=constraint)
rand(var) : returns a random value between 0 and var
bor(var,var2) : boolean or, returns 1 if var or var2 is != 0
bnot(var) : boolean not, returns 1 if var == 0 or 0 if var != 0
if(cond,vartrue,varfalse) : if condition is nonzero, returns valtrue, otherwise returns valfalse
equal(var,var2) : returns 1 if var = var2, else 0
above(var,var2) : returns 1 if var > var2, else 0
below(var,var2) : returns 1 if var < var2, else 0

Grrh the formating.

Thanks again in advance.

Cheers,

Rovastar


14th January 2002 21:20 UTC

If you don't mind my inquiring UnConeD, just how do you understand how AVS works so damn well? It's obivious you are a programmer, but what do you have in your head that so few others in the community seem to have?


15th January 2002 14:49 UTC

Vis plug-in experience, curiosity and a lot of mathclasses in high-school? I don't know :)

A year or two ago I made my own visualisation plug-in (for myself, it was never released) which was basically the same as the earlier versions of WVis: some built-in effects that you could toggle.
It wasn't fast or anything, but it did teach me how to do certains things (like a Trans / Movement or blurring) myself and generally taught me a lot about graphics-coding.

As far as the undocumented functions are concerned, here's the short of it: aside from exp() and atan2() I'm pretty sure there are no undocumented functions. If you want proof, open up vis_avs.dll in a hexeditor, search for the name of a function (atan2, sin, tan, etc.) and you should find the internal list of function names soon. It would be *very* weird if not all the function names were stored near each other. This is the list:

getspec.getosc..above...below...equal...if..bnot....bor.band....rand....sign....sigmoid.max.min.abs.log10...log.exp.pow.sqrt....sqr.atan2...atan....acos....asin....tan.cos.sin

(the dots are non-alphanumeric characters and I'm too lazy to properly format it :)