How to – Expressions in motion graphics

Standard

For the fourth and last task we decided to create a motion graphics animation examining in depth the world of expressions on After Effects and, at the same time, trying to follow the animation principles. In particular, our goal was to write expressions to create some of the most classic physical motion that we can find among the animations (falling body, impacts, oscillation, projectile motion etc.) in order to get realistic motions.

The video consists of an animation of a domino path with a chain reaction, that was created in a manner which allowed us to show and explain some of physical motions in a funny way. The motions we chose are the following: damped harmonic oscillator, falling body, projectile motion.

Before proceeding with the animation in After Effects, we created an animatic in Photoshop to get an idea about the timing and the style that we wanted for our video. At the same time, on Illustrator we prepared the drawings to animate.

Damped harmonic oscillator (pendulum case)

If there are friction forces as the precence of the air, the oscillation amplitude of any harmonic oscillator decreases. This amplitude reduction is an event that is named damp, hence the name of the motion. For the pendulum case, if there was not the air friction, it would swing indefinitely.

Damped harmonic oscillator formula

where θ is oscillation amplitude, θMax is the maximum amplitude, α is the temporal constant of the oscillation damp and φ is the phase of the motion. Now we’re going to illustrate how to adapt this formula in order to write an After Effects expression that reproduce the classic behaviour of a pendulum that swings when there is air friction. Before moving ahead, it’s fundamental that the anchor point of the pendulum is to his extremity. The expression has to be applied to the rotation parameter of the shape layer “fixed ball” (see the figure).

We created three variables; one for the angle, one for the velocity and one for the damp and then three expression controls (one angle control and two slider controls). We parented these variables to the proper controllers by means of the spiral icon in the effect menu of the rotation parameter.

Rotation Expression

theta_zero = effect(“Theta”)(“Angle”);

vel = effect(“Velocità_angolare”)(“Slider”);

smorzamento = Math.exp(effect(“Smorzamento”)(“Slider”)*time/100);

theta_zero*Math.sin(vel*time)/smorzamento; //result

Projectile Motion

For the projectile motion, contrary to the previous case, we decided to ignore the air friction because the effect wasn’t visually remarkable in short distance, as it happens in our video. According to this hypothesis, is known that a projectile launched with a certain angle describes a parabolic path and that the horizontal component of the velocity remains constant, while the vertical one increases (negatively) because of the acceleration of gravity.

So,

velocity components

position components

where

Now let’s see how to use these information to write an expression for the projectile motion on After Effects. First of all, after opening the expression tool of the position parameter of the projectile shape layer (alt+click on the clock), it’s necessary to create and instantiate some variables to use in the motion physics formula: projectile velocity, the angle of the parabolic path traced by the projectile, the value of the gravity force and the starting point from which the projectile begins its path. These variables have to be parented to the corresponding slider to control its value (we created a variable and dragging the cursor from the spiral icon we parented the variable to the appropriate slider). On the position parameter we had to add also the two formulas related to the partition of the path on x and y axis.

Position Expression

vel = 10*effect(“velocità”)(“Slider”);

angolo = effect(“angolo”)(“Angle”);

alpha = degreesToRadians(angolo);

g = effect(“gravità”)(“Slider”);

point = effect(“punto di partenza”)(“Point”);

x0 = point[0];

y0 = point[1];

x = vel*Math.cos(alpha)*time;

y = vel*Math.sin(alpha)* time – (g/2)*time*time;

[x + x0, -y + y0]; // result

As the projectile has to be oriented along the path tangent, we had to work also on the rotation parameter creating and instantiating the same variables we used for the position parameter as shown in the following expression (pay attention to the position of the anchor point!).

It’s important to keep in mind that for the angle variable it is necessary to convert from degrees to radians (degreesToRadians(angolo)) and vice versa the tangent value from radians to degrees (radiansToDegrees(tan)).

Bounce (squash&stretch)

The bounce of a ball can be assimilated to a projectile motion. Indeed, when a ball strikes a surface with a certain angle, it bounces following the same path of a projectile. But, to simplify, since the parabola isn’t a periodical function, to describe the bounce path we used the modulus of a sine function in the motion expression. In this case we decided to work independently on the x and y coordinates of the position and in order to do that we right clicked with the mouse on the Position parameter of the ball shape layer and we chose Separate dimension.

So, at first, for the expression of the y coordinate we created a variable t related to the point of the composition in which begins the animated clip (that is not the beginning of the composition). The dec variable is the damping value and has been obtained by means of an exponential function. The path followed by the ball has been reached using the cosine function, which it can be read in the expression, overturned and in modulus. On the other hand, the expression on the x coordinate is a simple uniform rectilinear motion.

Y Position Expression

t = time-startTime;

dec = Math.exp(t/3);

(-400*Math.abs(1.5*Math.cos(5*t)/dec)+800);

X Position Expression

t = time-startTime;

200+200*t;

To realize the Squash&Stretch effect we wrote an expression on the Scale parameter of the ball. The values of the variables t and t1 have been chosen in empirical way, observing the bounce curve, in order to synchronize the curve of the Squash&Stretch (x and x1 variables) with the bounce instant.