(Page 1 of 1 pages for this article )

Sunday, February 07, 2010

Filed under: Motion Graphics

Deeper Modes of Expression, Part 2: Interpolation Methods

Chris Meyer | 02/07

This simple method is our favorite replacement for a calculator.

As we noted last month, we’re serializing the Deeper Modes of Expression bonus chapter from our book Creating Motion Graphics with After Effects into a set of 12 posts here on PVC. As February is the shortest month, perhaps it’s appropriate that this us the shortest installment - but we also consider this to be one of the most important, core techniques offered by expressions: A quick and easy way to convert one range of numbers to another.

Interpolation Methods

Expressions in After Effects have the ability to interpolate between values. Knowing how to use the interpolation methods will make your expressions much easier to write, avoiding the need to drag out the calculator every time you need to scale one value’s range to fit another value’s range.

For example, say you wanted the X Position of a layer to move from X = 60 to X = 260 as Rotation increases from 45 degrees to 315 degrees. It would take a few moments with a calculator and pencil to figure out how to translate one range into the other. However, the interpolation methods make it easy – just plug in the ranges you need to translate between:

x_position = linear(rotation, 45, 315, 60, 260)

What this expression says is that as Rotation varies from 45 to 315, output a value that ranges from 60 to 260, scaling automatically in-between. What if Rotation goes below 45? The output will stick at 60. Same goes if the Rotation exceeds 315 – our resulting position value will stay at 260.

There are also ease, easeIn, and easeOut versions of all these interpolation methods. In the sequence of figures below, the lower wheel uses the expression ease(rotation, 45, 315, 50, 270), which results in an ease in and ease out for the resulting Position animation.

With the interpolation method described above, the wheels don’t start moving away from the left side until they rotate more than 45 degrees. The upper wheel is using linear interpolation while the bottom is using ease; as a result, the upper wheel moves faster initially. Background courtesy Digital Vision/Prototype.

There is a bit of a gotcha with the ease types: They work backward compared with the Easy Ease keyframe assistants. The interpolation method easeIn does not mean gradually slow down as you reach the second value; it means “ease in to the motion” (or away from the first value), then go to the second value in a linear fashion. This is demonstrated in the sequence below, where our wheel “skids” a bit initially, then gradually starts spinning after it moves 50 pixels away from the side of the comp. To do this, we turned the tables and applied the expression to Rotation, borrowing the X Position – position[0] – as our driving force:

easeIn(position[0],50,320,0,360)

We will use these interpolation methods liberally throughout the rest of the installments, as they can replace a lot of otherwise confusing math. In most cases, we will use the long form shown above; there are also shorter forms with just three values – for example, linear(t, value 1, value 2), which outputs a value between 0 and 1 as “t” varies between value #1 and value #2.

The other gotcha with the Interpolation methods is we’ve occasionally found cases where they refuse to convert in a particular direction, such as higher values to lower values. We’ve found that simply flipping the numbers (i.e. value 1 and value 2, as well as value 3 and value 4) makes it behave correctly.

From its name, you might think interpolation methods could also be used as a replacement for interpolating between normal keyframes. And you could use them for this purpose – but we can’t recommend it as a regular practice. Expressions give you far less control over how you interpolate than the normal keyframe interpolation methods do. if you have a copy of Creating Motion Graphics, see Chapters 4 and 5 to learn a variety of ways to control keyframes.

Rubber Hits the Road

Speaking of making wheels travel, ever wonder how to calculate the correct rotation to make a wheel appear that it has traveled a certain number of pixels? First you need to know the diameter of the wheel. Then you can use this formula:

distance = Math.PI * diameter * (rotation/360).

(This uses the JavaScript representation for pi that you learned in the previous installment.)

 

Next Installment: Deeper Into Arrays

Hopefully that was short and sweet. If you want another take on it (and admittedly, it’s easier to comprehend if you have the example project in our book), our fifth After Effects Apprentice video tutorial covered expressions; the last technique shown is the Interpolation method discussed above.

In the next installment, we’ll tackle a much deeper subject: How to deal with parameters that have more than dimension (such as position), and how to translate between parameters that have different numbers of dimensions - such as when we used position[0] above to grab just the X position value, and translate it into a rotation value. Included in the next installment will be the very useful length and lookAt expression methods. Until then…

The content contained in Creating Motion Graphics with After Effects - as well as the CMG Blogs and CMG Keyframes posts on ProVideoCoalition - are copyright Crish Design, except where otherwise attributed.

(Page 1 of 1 pages for this article )

               



You must be registered to comment. This is an effort to reduce spam. Please REGISTER HERE.

Name:

Email:

Location:

URL:

Smileys

Remember my personal information

Notify me of follow-up comments?

Submit the word you see below:




After Effects Apprentice Free Video: Exploring Shape Effects
After Effects Apprentice Free Video: Drawing Parametric Shapes
After Effects Apprentice Free Video: The Puppet Starch Tool
After Effects Apprentice Free Video: Eraser Tool Modes
After Effects Apprentice Free Video: Tracking with mochaAE
After Effects Apprentice Free Video: Performing a Motion Track
After Effects Apprentice Free Video: Creating 3D Objects using Adobe Repoussé
After Effects Apprentice Free Video: Understanding Axis Modes
Using After Effects as an Advanced Titler for Premiere Pro
After Effects Apprentice Free Video: Creating an Orbit Camera Rig
CMG Hidden Gems: Chapter 45 – What’s Your Preference?
CMG Hidden Gems: Chapter 44 – Prerendering and Proxies
CMG Hidden Gems: Chapter 43 – Advanced Rendering
CMG Hidden Gems: Chapter 42 – Render Queue
CMG Hidden Gems: Chapter 41 – Video Issues
CMG Hidden Gems: Chapter 40B – 3D Channel Effects
CMG Hidden Gems: Chapter 40 – Integrating with 3D Applications
CMG Hidden Gems: Chapter 39 – Integration 101
After Effects Apprentice Free Video: Multiple Playback Speeds
CMG Hidden Gems: Chapter 38 – Import and Interpret
CMG Hidden Gems: Chapter 37B and 37C – Expressions and Scripting Bonus Chapters
CMG Hidden Gems: Chapter 37 – Expressions
CMG Hidden Gems: Chapter 36B – Audio Effects
CMG Hidden Gems: Chapter 36 – Working With Audio
Upgrading to After Effects CS5.5?
CMG Hidden Gems: Chapter 35 – The Puppet Tools
After Effects Apprentice Free Video: The Wiggle Expression
CMG Hidden Gems: Chapter 34 – Roto Brush
CMG Hidden Gems: Chapter 33 – Paint and Clone
After Effects Apprentice Free Video: What Could Go Wrong?







Expression Shorts - Numerical Readout

David Torno | 02/05

Create numerical readouts for use in HUD style graphics.

image

With this Expression, I will show you how to feed numerical property information…

After Effects Apprentice Free Video: Exploring Shape Effects

Chris and Trish Meyer | 01/31

An overview of five of the simpler shape operators that can turn your basic outline into something quite twisted.

As we mentioned awhile back, we’ve been busy the past year and a half creating an extensive, multi-course video training…

Expression Shorts - Random Words Cycle

David Torno | 01/28

Create a text layer that randomly cycles through words.

image

Learn how to make a text layer randomly cycle through an array of words that…

Adobe teases Prelude at the San Francisco Supermeet, FCPUG changes its name

Scott Simmons | 01/28

The Adobe sneak looks intriguing. Makes me excited for CS6.

From the looks of Twitter last night there were a couple of surprises at the Friday evening’s San Francisco Supermeet. First bit of news I saw was that Final Cut Pro User Group (FCPUG) has decided to drop the Final Cut Pro designation from their name to become the Creative Pro User Group. Second was a sneak peek from Adobe about a new application called Prelude.

To be considered for listing, contact pr (at) provideocoalition (dot) com


Copyright © 2011, HD Expo, LLC a division of Diversified Business Communications. DBA Createasphere

All rights reserved. HD EXPO, High Def EXPO, Createasphere, E-Tech, Entertainment Technology Exposition, 3D Production Workshop, VariCamp, P2 Camp, ColorCamp 101, and Lighting, Filters & Gels for HD are all trademarks of HD Expo, LLC.

Terms of Use  |  Privacy Policy

Check PageRank