Complex Functions

Expressions can also contain complex formulas consisting of a chain of different functions. Just have a look at the following formula:

sin(3*t+exp(t/2))*0.2+sin(3*t-exp(t/1.2))*0.2*exp(t/4)

This function creates a curve with a base sine oscillation becoming denser and denser over time. The exponential part creates an overlapping oscillation with growing frequency and amplitude.

 

The graph of the function, printed above.

 

Of course, such an expression does not come out of the box. To get the desired results and range of values it is necessary to have an idea of what the individual functions look like. Each part of the above term has its own special graph. Sine, cosine, and the exponential function always show the same curve. Factors can stretch or flatten the graph, or make it steeper, for example. Combinations of the different functions produce complex curves and it is not always easy to find the appropriate values and factors to limit the results and avoid “exploding” values.

Fortunately the curve editor works like a function plotter making it much easier to optimize and adjust the factors, because you always have some visual feedback on how the curve is evolving. The best workflow is to start with the basic functions and their combinations, and then add step by step:

1. sin(t+exp(t))

2. sin(t+exp(t))+sin(t-exp(t))

3. sin(t+exp(t))+sin(t-exp(t))*exp(t)

4. sin(3*t+exp(t/2))*0.2+sin(3*t-exp(t/1.2))*0.2*exp(t/4)

 

This approach helps you to find out which part of the functions might be responsible for very high values and you can immediately limit them by multiplying or dividing with the appropriate value. The only thing you have to watch out for is bracketing, because parentheses have to be set following the basic rules of maths. It certainly takes a little time and a certain amount of testing to get the desired behaviour, but after a few tries you will be able to get along with different functions and their range. It is a good idea to have a play with the provided functions under

Insert > Unary functions

As you can see it is not that difficult to use expressions. They are a very fast and effective way to automatize certain animation tasks. In many cases it is even better to use expressions instead of scripting, because you will benefit from multi-threading and multi-core systems. Even with the simplest script RealFlow will not use more than one processor, because Python is a single-threaded programming language. Please bear in mind that this limitation is Python-specific and has nothing to do with RealFlow’s ability to use more than one processor.