This will hopefully give people some insight into how top use R2/Extreme 1.50's (and on) formula engine...

To let people write their own visual feedback scenes, point morphs, and predefined scenes, R2e uses a formula engine. This allows it to work through a mathematical formula and use the value it gets out to do something. In the case of visual feedback, it uses the numbers to figure out how much to move each bit of the screen. For the point morph, it effectively draws the formulas you typed in in 3D using dots. For predefine scenes, all the values that you can change for the 'basic' scenes in the scene options window can be changed dynamically...

Simple formulii
Since R2e 1.50, the formula engine has worked purely on R2e's built-in constants, and in one line of formula you can assign values to many of R2's constants. The general form of R2 equations is:


For instance...

(I'll explain later what all this does)

For now though, we're just going to look at one expression. take "MapB=Theta+(Radius/2)"... Every expression consists of a variable name, then an equals sign, and what its equal to. Simple maths can be used, such as +,-,*,/,DIV,MOD and ^ (to the power). You can also use brackets as you would in any algebra. There's an important point to note though - If R2 encounters an error in the formula it will put an error message in the console (in Red text) - it won't actually put up an error message - you have to check. Its always an idea to open the console, scroll up and check that there are no errors, since these will really effect what happens (even though R2 will try and work with a formula with an errors in) :)

Examples of uses of the functions are:
a MOD 5
a DIV 5

The Variable names that you can use are the R2 constants - these are usually made up of the scene ID, then a full stop, then the variable name (eg. warp.samp) if there is just a name there, the formula engine will automatically put "base." infront of it. For visual feedback and point morphs you'll find you hardly ever use anything with a full stop in, but for doing predefined scenes you will need to access info on scenes so this will come in really handy. I'll come back to what the predefined variables are later (since they're pretty specific to point morph/visual feedback)...

The R2 formula engine provides functions as well as simple maths operations. a list of these is provided below, as well as descriptions... All trig functions work in radians (between 0 and 2*pi) - a built-in constant called pi exists...
'SIN'sin(x)sin of x
'COS'cos of x
'TAN'tan(x)tan of x
'ASIN'asin(x)inverse sin of x
'ACOS'acos(x)inverse cos of x
'ATAN'atan(x)inverse tan of x
'ATAN2'atan2(y,x)inverse tan of y/x
gives the angle from the origin to the point (x,y)
'EXP'exp(x)e^x - the exponential function
'LOG'log(x)the log (base e) of x
'LOG10'log10(x)the log (base 10) of x
'SIGN'sign(x)+1 if x>0
-1 if x<0
0 if x=0
'INT'int(x)returns the integer part of x (rounded down - eg 1.9->1)
'ABS'abs(x)returns the absolute value of x (-5 -> 5, but 6 -> 6)
'RAND'rand(x)returns a random integer 0 <= rand(x) < x
'MIN'min(x,y)returns whatever is smaller, x or y
'MAX'max(x,y)returns whatever is larger, x or y
'IF'if(x,y,z)if x>0 then returns y else returns z
If you want to check if a>b then do: if(a-b,something,somethingelse)

So you can do stuff like "Theta=sin(BassTime*2)"...

Other stuff
Well, hope that was sortof enough to get started - for info on actually doing custom point morphs, visual feedback etc, i'd look at the other tutorials specifically on them... If you have any queries, please raise them on the R2 effects messageboard and i'll see if I can help you.

site design by Gordon Williams