FORUMS: list search recent posts

# Interpolation between values

FAQ   •   VIEW ALL
 Interpolation between values on May 31, 2012 at 9:00:07 pm

Hey guys,

So I am currently working on a little animation, and I wondered, if it was possible to interpolate between values, that were created by an expression, just like between normal keyframes.

I couldn't find anything using google, so I hoped you could help me out.

Tom

 Re: Interpolation between valueson May 31, 2012 at 9:24:43 pm

Can you be more specific? The expression language has interpolation methods: linear(), ease(), easeIn(), and easeOut(). Have you looked at those?

Dan

 Re: Interpolation between valueson Jun 2, 2012 at 1:38:10 pm

So before I say weird stuff while trying to paraphrase, here ist the whole thing:

The Idea of this is just to create a little automated overshoot for different parts of an animation I'm working on, in this case mostly for the hair.

Basically we have to Checkboxes, that I decided to replace with sliders. These checkboxes indicate the point in time, when the rotation of another layer is at a minimum or at a maximum. So we have:

HP:
FPS = effect("FrameRate")("Slider")
t = time - 1/FPS
SpeedTime = Speed.valueAtTime(t)

if (Speed = 0 && SpeedTime > 0 || Speeda < 0 && SpeedTime > 0) {true}
else {false}

TP:
FPS = effect("FrameRate")("Slider")
t = time - 1/FPS
SpeedTime = Speed.valueAtTime(t)

if (Speed = 0 && SpeedTime < 0 || Speed > 0 && SpeedTime < 0) {true}
else {false}

(little sidenote: I defined the Framerate by a manual value since I couldn't find the automatic way. If you could help with that, I'd be very grateful as well ;) )

The Expresion goes on to the part, where the additional rotation is calculated. At the moment speed and strengh of are predefined. I will probably change that in the future, but for now I wanted to keep it simple. It looks something like this:

HP = effect("HP")("Slider")
TP = effect("TP")("Slider")
t1 = time - 0.3
t2 = time - 0.6

HPTime1 = HP.valueAtTime(t1)
HPTime2 = HP.valueAtTime(t2)
TPTime1 = TP.valueAtTime(t1)
TPTime2 = TP.valueAtTime(t2)

if (HPTime1 == true) {AddRot = 10}
else
if (TPTime1 == true) {AddRot = -10}
else
if (HPTime2 == true) {AddRot = 0}
else
if (TPTime2 == true) {AddRot = 0}

The idea here is that 0.3 seconds after the max/minimum of the rotation is reached the Additional rotation is at it's maximum and another 0.3 seconds later back to normal.

My initial question only refers to the very last part of the expression. How do I replace the last "else" in a way, that the values are calculated by interpolation between the values that were created with the "if"s? Is that actually possible? And if not, is there another maybe much easier way to achieve the same effect?

I hope this explains my question as detailed as possible,
Tom

 Re: Interpolation between valueson Jun 2, 2012 at 4:34:48 pm

Here's what I'd do. I'd use layer markers to denote the start of an overshoot. I'd use an expression like this on the piece that needs the additional rotation:

``` dur = .3; addRot = 10; n = 0; m = marker; if (m.numKeys > 0){ n = m.nearestKey(time).index; if (m.key(n).time > time) n--; } r = 0 if (n > 0){ t = time - m.key(n).time; if (t < dur) r = easeOut(t,0,dur,0,addRot) else r = easeIn(t,dur,2*dur,addRot,0); } value + r ```

Also, FYI, the duration of one frame would be:

thisComp.frameDuration

so the frame rate would be:

1/thisComp.frameDuration

Dan

 Re: Interpolation between valueson Jun 7, 2012 at 9:54:14 am