Skip to main content
Inspiring
March 27, 2009
Question

Keeping Exponential Scale "live" with expressions

  • March 27, 2009
  • 7 replies
  • 9395 views
Is there a way to replicate the Exponential Scale via expression?

As you know, once you run the animation assistant, the keyframes are locked down and if I need to change the start or end values, I have to delete all the intermediate KFs and re-run the animation assistant. Kind of a hassle, eh?

It would be cool if I could set a start and stop keyframe or layer markers and have the expression do its thing between a min and max value (via sliders?).
This topic has been closed for replies.

7 replies

Inspiring
April 15, 2009

So one thing I noticed with Ease & Wizz is that there's no setting exactly like AE's Exponential Scale animation assistant. I've written the author and asked to include a 'linear' interpolation as all of E&W's options use some sort of easing.

So he gave me this expression by Dan to use. But I'm getting a "div() must be scalar" error when I place use it in a scale property. Can someone take a look and see what's wrong?

if (numKeys > 1){

  v1 = key(1).value;

  v2 = key(2).value;

  t1 = key(1).time;

  t2 = key(2).time;

  if (time > t1 && time < t2){

    t = time - t1;

    T = t2 - t1;

    k = Math.log(v2/v1)/T;

    v1*Math.exp(k*t)

  }else{

    value

  }

}else{

  value

}
Inspiring
April 17, 2009

Are you using this on a 2- or 3-dimensional property?  I think the problem is here:

    k = Math.log(v2/v1)/T;

The expression looks like it was written for a one-dimensional property, not for vectors like scale or position.  I think v2/v1 is another way of expressing div(v2, v1).  In any case, you are trying to divide a vector by another vector.

My vector math was never very good, so I'm not sure what the solution is at this point.  I suspect it is more complicated than simply dividing each component of v2 by its corresponding component of v1.

Dan Ebberts
Community Expert
Community Expert
April 18, 2009

I think this should work for what you're trying to do. For two keyframes it should give the same result as if you applied AE's exonential scale. If there are more than two keyframes, it will apply the exponential scale between each adjacent pair of keyframes. Should work for multi-dimensional properties as well. I just took it out of the oven, so it may not be completely cooked. Let me know if you run into problems.

n = 0;
if (numKeys > 0){
  n = nearestKey(time).index;
    if (key(n).time > time){
      n--;
    }
}

if (n == 0 || n == numKeys){
  value
}else{
  d = 1
  try{
    value[1];
    d++;
    value[2];
    d++;
    value[3];
    d++;
  }catch (err){
  }
  t1 = key(n).time;
  t2 = key(n+1).time;
  if (d == 1){
    v1 = key(n).value;
    if (v1 == 0) v1 = .0001;
    v2 = key(n+1).value;
    if (v2 == 0) v2 = .0001;
    k = Math.log(v1/v2)/(t2-t1);
    v1/Math.exp((time-t1)*k)
  }else{
    v = [];
    for(i = 0; i < d; i++){
      v1 = key(n).value;
      if (v1 == 0) v1 = .0001;
      v2 = key(n+1).value;
      if (v2 == 0) v2 = .0001;
      k = Math.log(v1/v2)/(t2-t1);
      v = v1/Math.exp((time-t1)*k)
    }
    v
  }
}

Dan

Inspiring
April 1, 2009
Consider him tipped!
Todd_Kopriva
Inspiring
April 1, 2009
I agree. Ease and Wizz is awesome. I see a PayPal donation button on Ian's site, too. I'm just sayin'...
Inspiring
March 31, 2009
WOW! Ease 'n Wizz is awesome!
yenaphe
Inspiring
March 28, 2009
Here is the Ease 1 wizz link Mylenium talked about: http://ianhaigh.com/easeandwizz/
Inspiring
March 27, 2009
Besten Dank!
Mylenium
Legend
March 27, 2009
http://www.motionscript.com/mastering-expressions/simulation-basics-2.html also try Ease & Wizz, a collection of scripts that will setup expressions for alternate interpolation methods (from a different site, haven't the link handy).

Mylenium