Skip to main content
Participating Frequently
July 26, 2023
Answered

Expression for Exponential Scale ?

  • July 26, 2023
  • 4 replies
  • 971 views

Instead of using Keyframe assistaant > Exponential Scale, I would like to use an expression on the Scale property. What would be the correect expression taking into account scale at inpoint, scale at outpoint and duration between inpoint and outpoint? (my picture is zooming out)

Thanks !

This topic has been closed for replies.
Correct answer Mylenium
tStart=key(1).time;
tEnd=key(2).time;
tDiff=tEnd-tStart;

vStart=valueAtTime(tStart);
vEnd=valueAtTime(tEnd);
vDiff=vEnd-vStart;

mStart=Math.exp(0);
mEnd=Math.exp(1);
mFac=linear(time,tStart,tEnd,0,1);
mMul=Math.exp(mFac);

vStart+linear(mMul,mStart,mEnd,0,1)*vDiff;

 

Mylenium

4 replies

Community Expert
July 26, 2023

If you want to work without keyframes, try this version of Mylenium's expression:

 

tStart=inPoint;
tEnd= inPoint + 2;// move time in seconds
tDiff=tEnd-tStart;
vStart=[10, 10];// starting Scale
vEnd=[70, 70];// ending Scale
vDiff=vEnd-vStart;
mStart=Math.exp(0);
mEnd=Math.exp(1);
mFac=linear(time,tStart,tEnd,0,1);
mMul=Math.exp(mFac);
vStart+linear(mMul,mStart,mEnd,0,1)*vDiff;

 

 The math does not match applying the Keyframe Assistants' Exponential Scale perfectly, but it looks pretty good.

Change line two to tEnd = outPoint, and the animation will last as long as the layer.

Dan Ebberts
Community Expert
Community Expert
July 26, 2023

Something like this maybe:

t1 = inPoint;
t2 = outPoint - thisComp.frameDuration;
v1 = valueAtTime(t1);
v2 = valueAtTime(t2);
if (time < t1){
  v1;
}else if (time > t2){
  v2;
}else{
  d = t2 - t1;
  dv = v2 - v1;
  t = (time - t1)/d;
  v1 + dv*Math.exp(10*(t-1));
}
Mylenium
MyleniumCorrect answer
Legend
July 26, 2023
tStart=key(1).time;
tEnd=key(2).time;
tDiff=tEnd-tStart;

vStart=valueAtTime(tStart);
vEnd=valueAtTime(tEnd);
vDiff=vEnd-vStart;

mStart=Math.exp(0);
mEnd=Math.exp(1);
mFac=linear(time,tStart,tEnd,0,1);
mMul=Math.exp(mFac);

vStart+linear(mMul,mStart,mEnd,0,1)*vDiff;

 

Mylenium

Mylenium
Legend
July 26, 2023

Something like this perhaps:

 

tStart=key(1).time;

tEnd=key(2).time;

tDiff=tEnd-tStart;

vStart=valueAtTime(tStart);

vEnd=valueAtTime(tEnd);

vDiff=vEnd-vStart;

 

vStart+Math.exp(tDiff)*vDiff;

 

Mylenium

 

Participating Frequently
July 26, 2023

Thanks Mylenium. Sorry, I should have mentionned that current time should be taken into account to have the exponential scaling from tStart to tEnd. How would you fit the (time-inpoint) within your expression ? I tried to but was unable. Thanks !

Community Expert
July 26, 2023

If you want the animation to start at the in point of the layer:  tStart = inPoint;

If you want the animation to end 1 second before the out point of the layer: tEnd = outPoint - 1;

 

Check the expression I posted.