Animations

MathMap provides the functionality to create animations. To that end, the language provides a variable called t. For each single picture in the animation (such pictures are called frames) t has a different value, depending on the position of the frame within the whole animation. The first picture in the image always has t set to 0, while for the last picture it is set to 1. Actually, the latter statement isn't always true, as we will discover shortly, but for the time being, simply assume that it is.

The following expression produces an animation which fades from black to white:

grayColor(t)

You will often want to produce animations which loop seemlessly, i.e. which looks like one endless animation when looped. For such animations, make it so that the image with a t value of 1 looks exactly like the one with a value of 0, like in the following expression:

grayColor(sin((t*2*pi+1)/2))

The problem here is that if MathMap would render the first image in the animation with t as 0 and the last image with t as 1, you would have the same frame twice when looping. Therefore, MathMap lets you choose (in the user interface) whether you would like to create a periodic (looping) animation or not. If you do, t never reaches 1 at the end of the animation but stops shortly before, depending on how many frames you want your animation to have. For example, for a periodic animation with 9 frames, t takes on the values 0, 0.1, 0.2, ... 0.9.

Hint: One way to make periodic animations is to use periodic functions like sin, cos or the modulo operator %.

Next topic: Some Useful Functions