Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions exponential scale expression not matching 3D move

  • exponential scale expression not matching 3D move

    Posted by Daniel Crooks on November 8, 2013 at 6:44 am

    hi all

    I’ve been using Dan’s exponential scale expression for ages. I’d always assumed it was replicating a 3D camera tracking in or out of a scene. Today I actually tested it out and was surprised to find it doesn’t ??? While markedly better than a straight linear scale the exponential scale still accelerates a little too quickly at the start and the decelerates a little too slowly at the end.

    I’m hoping someone with better maths skills than myself can illuminate what might be going on…

    I’ve attached a test comp here to illustrate: 6772_scaleexptest.aep.zip

    //applyTo: scale
    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[i];
    if (v1 == 0) v1 = .0001;
    v2 = key(n+1).value[i];
    if (v2 == 0) v2 = .0001;
    k = Math.log(v1/v2)/(t2-t1);
    v[i] = v1/Math.exp((time-t1)*k)
    }
    v
    }
    }

    Dan Ebberts replied 12 years, 6 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    November 9, 2013 at 5:38 pm

    If you’re manipulating scale to represent 3D distance change, you generally want to pick a distance that represents a scale of 100%. Then a ratio of that distance to your current distance will give you the scale multiplier you need. So, for example, if you pick 500 pixels as the 100% distance, your formula becomes

    value*500/distance_from_camera

    So at 1000 pixels, your scale will be 50%, at 250 pixels it will be 200%.

    I hope that helps.

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy