Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Exit

- Home
- After Effects
- Discussions
- Re: Modifying linear interpolation methods for dif...

- Re: Modifying linear interpolation methods for dif...

0

/t5/after-effects-discussions/modifying-linear-interpolation-methods-for-different-curves/td-p/13240359
Oct 02, 2022
Oct 02, 2022

Copy link to clipboard

Copied

I have successfully modified an expression to give me an exponential increase in speed based on a layer's in-point. I'm having problems with an exponential decrease in speed. I guess what I am trying to do is modify the ease-out curve.

Here's what I have so far:

```
st = 1/thisComp.frameDuration;
movD = 20; // end position in % of comp width
mov = st; // move timing in frames
L = sourceRectAtTime();
LLeft = L.left;
LWidth = L.width;
t = time - inPoint;
tMin = 0;
tMax = tMin + mov * thisComp.frameDuration;
value1 = 0 - LWidth - LLeft;
value2 = thisComp.width * movD * .01;
x = linear(Math.exp(-t*10), tMin, tMax, value2 - LLeft, value1);
y = value[1];
[x, y]
```

Math.exp(-t*10) will give me about a half-second duration for the animation. If I set the "move" variable to 1/frame duration, the move will start at the layers in-point. What I want to do is be able to set the "mov" value to the number of frames it will take to bring the layer to a stop. I can get close by changing the "t" multiplier. Smaller numbers increase the time.

The expression I have come up with works, but I haven't figured out to define the ending point of the animation and control the curve.

Any suggestions would be appreciated.

I'd like to give a shout-out to Dan Ebberts. If anyone has a solution at the top of their head, it is Dan.

TOPICS

Expressions
,
How to
,
Scripting

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Community Expert
,
Oct 03, 2022
Oct 03, 2022

OK, so what I've got here is a kind of Frankenstein mash-up of your setup a something I had squirreled away. It has functions for accelerate (pow_in) and decelerate (pow_out), but the example is setup to use just decelerate. I'm only using 2 sliders--one to define the move frames and one to set the extremeness of the exponential curve. I hope you find it helpful. I recommend setting the Power slider up so it only has a range of 1-10.

`// slider range 1 to 10 (1 = linear, 10 slightly more extreme `

...
8
Replies
8

Rick Gerard
AUTHOR

Community Expert
,

/t5/after-effects-discussions/modifying-linear-interpolation-methods-for-different-curves/m-p/13240731#M212267
Oct 02, 2022
Oct 02, 2022

Copy link to clipboard

Copied

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/after-effects-discussions/modifying-linear-interpolation-methods-for-different-curves/m-p/13240906#M212274
Oct 02, 2022
Oct 02, 2022

Copy link to clipboard

Copied

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Rick Gerard
AUTHOR

Community Expert
,

/t5/after-effects-discussions/modifying-linear-interpolation-methods-for-different-curves/m-p/13240989#M212275
Oct 02, 2022
Oct 02, 2022

Copy link to clipboard

Copied

I am trying to create an Animation Preset that allows me to move a layer into the frame based on the layers in point then move it out based on the layers out-point. I have created about a dozen of these, all of them have a slider to select the number of frames for the move, and all use the layer's in point plus a specified number of frames to move the layer into position. They all use the ease, ease in, or ease out interpolation method. Some of them have a bounce or overshoot added. Some work with 3D layers utilizing the camera's angle of view to move a layer into position and then fly it out based on the out point. For most of the presets, all I do is place the layer where I want it to end up and apply the preset. The layer then flys in to the frame, rests in it's hero position, and then flys out. The problem is that they all rely on the standard interpolation methods, and there is no adjustment for the speed. To give the animations a more professional and polished look I am tring to gain control of the acceleration and deceleration curves.

I worked out the acceleration of the problem. I use t = Math.pow(t, speedSlider) for that one. The timing is completely controllable but I can change the curve from linear to exponential acceleration easily. Control over acceleration is working just fine.

The expression I posted gives me different shaped speed graphs for deceleration, but I cannot control when the move starts or ends. If I try and change the curve I change the start and end point of the move. The only time the start of the move corresponds to the in-point of the layer is when the Move In Frames matches the comp's frame rate

I want to maintain the timing but have the same kind of control over the deceleration curve that I have for the acceleration curve. I can then add an if/else argument to the expression to switch from an acceleration curve to a deceleration curve without changing the timing or fouling up the start point.

I hope this helps you help me figure out a solution. I can achieve this kind of control if I have two keyframes, but I don't want to do that when I have hundreds of layers to animate.

I included a project file if that helps.

Community guidelines

/t5/after-effects-discussions/modifying-linear-interpolation-methods-for-different-curves/m-p/13241030#M212278
Oct 03, 2022
Oct 03, 2022

Copy link to clipboard

Copied

Wouldn't you rather use Math.log(duration,1)? Seems like you want to figure out the base rather than the exponent.

Mylenium

Community guidelines

Rick Gerard
AUTHOR

Community Expert
,

/t5/after-effects-discussions/modifying-linear-interpolation-methods-for-different-curves/m-p/13241060#M212283
Oct 03, 2022
Oct 03, 2022

Copy link to clipboard

Copied

I posted the wrong project. Here's the right one and the latest and closest version of the expression:

```
movD = effect("Move Distance")("Slider"); // end position in % of comp width
mov = effect("Move In Frames")("Slider"); // move timing in frames
curve = effect("Curve")("Slider");
L = sourceRectAtTime();
LLeft = L.left;
LWidth = L.width;
t = time - inPoint;
tMin = 0;
tMax = tMin + mov * thisComp.frameDuration;
value1 = 0 - LWidth - LLeft;
value2 = thisComp.width * movD * .01;
x = linear(Math.exp(-t * curve ), tMin, tMax, value2 - LLeft, value1);y = value[1];
[x, y]
```

Note the time change with the curve change. I'm trying to avoid that.

Mylenium, I'll give your suggestion a try.

Community guidelines

/t5/after-effects-discussions/modifying-linear-interpolation-methods-for-different-curves/m-p/13242146#M212322
Oct 03, 2022
Oct 03, 2022

Copy link to clipboard

Copied

OK, so what I've got here is a kind of Frankenstein mash-up of your setup a something I had squirreled away. It has functions for accelerate (pow_in) and decelerate (pow_out), but the example is setup to use just decelerate. I'm only using 2 sliders--one to define the move frames and one to set the extremeness of the exponential curve. I hope you find it helpful. I recommend setting the Power slider up so it only has a range of 1-10.

```
// slider range 1 to 10 (1 = linear, 10 slightly more extreme than exponential)
function pow_in(curT,t1,t2,v1,v2,n){
if(curT <= t1)return v1;
if(curT >= t2)return v2;
dt = t2 - t1;
dv = v2 - v1;
t = (curT-t1)/dt;
return v1 + dv*Math.pow(t,n);
}
function pow_out(curT,t1,t2,v1,v2,n){
if(curT <= t1)return v1;
if(curT >= t2)return v2;
dt = t2 - t1;
dv = v2 - v1;
t = (curT-t1)/dt;
return v1 + dv*(1-Math.pow(1-t,n));
}
s = effect("Power")("Slider").value;
mov = effect("Move In Frames")("Slider");
if (time < (inPoint + outPoint)/2){
val1 = [-width/2,value[1]];
val2 = [thisComp.width/2,value[1]];
time1 = inPoint;
time2 = inPoint + framesToTime(mov);
}else{
val1 = [thisComp.width/2,value[1]];
val2 = [thisComp.width + width/2,value[1]];
time1 = outPoint - framesToTime(mov);
time2 = outPoint;
}
pow_out(time,time1,time2,val1,val2,s);
```

Community guidelines

/t5/after-effects-discussions/modifying-linear-interpolation-methods-for-different-curves/m-p/13242174#M212323
Oct 03, 2022
Oct 03, 2022

Copy link to clipboard

Copied

Community guidelines

Rick Gerard
AUTHOR

Community Expert
,

LATEST
/t5/after-effects-discussions/modifying-linear-interpolation-methods-for-different-curves/m-p/13244877#M212386
Oct 04, 2022
Oct 04, 2022

Copy link to clipboard

Copied

Community guidelines

Resources

Troubleshooting FAQs

After Effects Community Recap

Getting started with After Effects

Copyright © 2024 Adobe. All rights reserved.