Tutorial
|
|
Inbetweening is a technique for calculating values that change systematically during an animation. Generally, it will be known over which (key) frames in an animation an output value will change. The diagram shown below is a simplified version of the type of information displayed by an animation editor available in all 2D/3D applications. ![]() The known values are shown in purple and those that will be calculated are shown in red. k1 and k2 are the keyframes at which the output value begins and ends its change. frame is the current frame at which the output value will be calculated. v1 and v2 are the min and max values for the output. Since the output value will change smoothly, shown by the straight diagonal red line, this type of inbetweening is called linear inbetweening. |
|||
|
GENERAL METHOD
The easiest way of understanding the calculation of an output value
is to look at an example. Suppose we have an output value that will be
used to set the radius of a circle or sphere. Lets say at the beginning
and end of the animation the radius should be 1.5 and 4.5.
Therefore, |
||||
|
'C' IMPLEMENTATION
The 'C' code for performing linear inbetweening is shown below.
Because frame numbers are integers it is necessary to do the cast or
promotion at line 16. Without the "if" and "else if" on lines 10 to
13 the incorrect values of radius would be calculated. |
||||
|
'Tcl' IMPLEMENTATION
A Tcl implementation for linear inbetweening is shown below.
Download tweening.tcl |
||||
|
ACCELERATION
The animation of many phenomena require that changes occur in an
accelerating or deaccelerating fashion. For example, take an
exploding fireworks "sky rocket" that forms a spherical shell
of colored sparks.
|
![]() |
||
![]() As shown above, using such a curve gives a different output value than the linear interpolation, shown by the gray line. Therefore, line 16 of the 'C' implementation, where the percent value is calculated ie. percent = (float)(frame - k1)/(k2 - k1);
should be changed to, percent = pow(float)(frame - k1)/(k2 - k1), 2);
But what about de-acceleration? |
|
|
DE-ACCELERATION
A typical acceleration curve is shown on the right in blue. The equation for the deacceleration can be re-written as, y = sqrt(x) or y = pow(x, 1.0/2) Likewise, the 'C' maths function pow() could also be used for the acceleration, y = pow(x, 2)
If the second value of pow() is made equal to 1.0 we have a linear relationship between the x and y values. When the second value become the reciprocal of 2 ie. 0.5 we have the de-acceleration curve shown in blue. If however, the second value becomes zero ie. y = pow(x, 0) the 'y' value stays at 1.0. Therefore, a 'C' implementation of an inbetweening function might look this, |
![]() |
The main problem with this function is that both for acceleration and de-acceleration the final output value ie. v2 is reached abruptly. |
For a Tcl version of this function refer to tween.tcl. ![]() |