Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Linear interpolation

From: After Effects Apprentice 09: Expressions

Video: Linear interpolation

In this chapter, we're going to take your expression skills to the next level by going just a little bit further in what you can do with the Pick Whip tool and simple numbers. If you've watched the last movie in this series, we're continuing on with the Clockwork copy I've been working with. If you jump straight here, just go ahead and open up the comp 03-Clockwork*starter in the project AEA_expressions. Don't worry about having not expressed the hour and second hands yet; we're still tying everything off of what the minute hand is doing. In fact, I'll twirl those up for now. You might have noticed we have this nice blue background going on behind this watch face.

Linear interpolation

In this chapter, we're going to take your expression skills to the next level by going just a little bit further in what you can do with the Pick Whip tool and simple numbers. If you've watched the last movie in this series, we're continuing on with the Clockwork copy I've been working with. If you jump straight here, just go ahead and open up the comp 03-Clockwork*starter in the project AEA_expressions. Don't worry about having not expressed the hour and second hands yet; we're still tying everything off of what the minute hand is doing. In fact, I'll twirl those up for now. You might have noticed we have this nice blue background going on behind this watch face.

We actually gave you a second background layer as well. If I turn off the Alien Atmospheres movie, you'll see we have this Digidelic movie that we've used in few of our lessons. Let's say that we want to reveal that Digidelic movie with a sweep that's coordinated with that minute hand. Well, there is actually an effect that does that. I've selected Alien Atmospheres, go up to Effect, and go down to the Transition category, which is multiple ways of getting rid of one layer to reveal whatever lies underneath.

In this case, we want a Radial Wipe. Radial Wipe has a parameter called Transition Completion that does this clockwork-type reveal that we want. There is a problem though: whereas rotation works in degrees-- 360 degrees being a full circle--Transition Completion works in percentage with 100% being a full circle. How do we line those two up? Well, we could just use the Pick Whip tool and simple math...

well, not-so-simple math. You'd have to search saying, well, divide by 360 because that's the degrees, times 100 by the completion, that should get us back to where we want to be, and you'd be right. But rather than twisting your mind every time you need to convert one parameter range to another, there's this wonderful little expression called Interpolation that can do it for you. So let's explore that. We want Transition Completion to follow Rotation. I already have rotation exposed. I'll hold on Option or Alt, click on the stopwatch for Transition Completion, and it will be exposed down here in the Timeline panel.

Rather than use the Pick Whip tool or start typing code, I'm going to take advantage of this little arrow here and reveal what's known as the Expression Language menu. For those who are really get into expressions, this is a list of many different expression methods and other arguments that are available to you inside After Effects. The category we're interested in is called Interpolation, how to take one range of numbers and interpolate it to match what you need for a second range of numbers. In this case, we want to use the linear interpolation, so it's a straight-up translation, and we are going to use this second option.

I'll select that and After Effects will write this little starter piece of code for me automatically. What this code is really telling me is it wants to take a value, t--the default is to use time, but it can be anything you want--and as that value goes from its minimum to its maximum value, translate it into a new desired minimum and maximum value. At this point, we can just go ahead and use the Pick Whip and type in numbers, just like we have so far. I'll carefully select this t and say, rather than using time, instead I want you to follow the rotation of this layer.

Let go over the mouse and all the code I need is written for me. I don't need to type this by hand, but it's easy enough to read. This comp has a layer called minute. Use its transform property, rotation. Great! What's rotation's minimum? 0. What its maximum? 360. That's easy. What's the minimum value I want to translate to? 0 for 0% transition completion. What's the maximum value I want to translate to? 100 for 100% complete, literally all there is to it.

Click off, the expression has been accepted, and you're going to already see up here in the Comp panel that this transition is lining up with the minute hand. I'll press 0 in the numeric keypad to RAM preview, and you'll see I now have a coordinated animation. And just as with any other expressions, I can go ahead and edit these keyframe values. Maybe I want it to be a full 360 degrees. Enter, zero to RAM preview, and automatically, my effect for transition completion follows along with my altered master keyframe value.

This linear expression is one of my favorites. I use it all the time because I'm forever having to translate to get animations to line up. Remember that it resides underneath the Expression Language menu > Interpolation, second one down. Use the Pick Whip to replace the t with whatever property you want to follow and just type in your starting and minimum and maximum, your target minimum and maximum. By the way, if you want to see a finished version of this composition, go back into the Project panel, twirl open Comps_Finished, and open up 03-Clockwork_final.

We've done a lot more things here. We've added drop shadows and in the case of the drop shadows on the watch hands, we use that trick you've already learned earlier in this lesson to make the shadow always follow the right direction. We're doing the Radial Wipe and we're doing one more trick that's kind of fun: we're having the hue of that background layer change as the animation progresses, and we're using the exact same trick we used for Radial Wipe. I'll select the Alien Atmospheres layer. Press F3 to reveal it in the Effect Controls panel.

You'll see I use the effect Color Balance. It has a Hue value that also goes from 0 to 360 degrees. But I didn't want it to go all the way around the Hue wheel. I want a very specific range. So what I did is, with the expression turned off, and set somewhere where I can see what I was doing, I went ahead and scrubbed the Hue value to see what I wanted for a starting color, maybe something in there to go ahead and match my watch face color. Then went towards the end of the animation where I can see just a little segment in here and scrub and say, let's go ahead and match the color of my new background as we get close. Maybe something more in that range.

And once I know what those two values are, I just went ahead and use that same linear expression. I used the pick whip to tie it to the rotation of the minute hand, and as it went from the 0 to 360 degrees, I said I wanted my Hue rotation to go from -180 to 120. Just the same thing as we just did with Transition Completion. I'll click off, the expression turns back on, RAM preview, return to the start of my comp, and as I drag the Current Time Indicator through here, you can watch how the Hue value changes to coordinate its movements with the minute hand.

So the Linear Interpolation expression is one good tool to have in your toolkit. Another one is the Loop expression and I'll show that in the next movie.

Show transcript

This video is part of

Image for After Effects Apprentice 09: Expressions
After Effects Apprentice 09: Expressions

20 video lessons · 10730 viewers

Chris Meyer and Trish Meyer
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed After Effects Apprentice 09: Expressions.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.