Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Dan expression spring? Physic laws?

  • Dan expression spring? Physic laws?

    Posted by Rafael on July 24, 2006 at 5:41 pm

    I have been using this expression from Dan Ebberts. It sort of work, but I wonder if it could calculate the velocity from the previous keyframe to the next keyframe and calculate how much the spring effect is been affected. Calculating the pixel/per second?
    Extra thought: Wouldn’t be great to see a plug-in developped by Dan that mimics different the physics of law? I heard that Motion 2 does some of that, but I am an After Effects person…

    n = 0;
    if (numKeys > 0){
    n = nearestKey(time).index;
    if (key(n).time > time){
    n–;
    }
    }
    if (n == 0){
    value
    }else{
    t = time – key(n).time;
    veloc = 12
    amplitude = 330;
    decay = 3;
    y = amplitude*Math.cos(veloc*t)/Math.exp(decay*t);
    value+[y,y,0];
    }

    Rafael replied 19 years, 9 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 24, 2006 at 7:40 pm

    It sounds like you want something like the old Motion Math spring script. George Polevoy posted an expression a few years ago that works pretty well:

    // AE expression by George Polevoy
    // http://www.creativecow.net

    // attaches an object to a “Controller” object with a “spring”
    // You need another “Controller” which will drive animation of this one

    // parameters
    conserveMotion = 0.95; // valid range: 0.5 to 0.995
    springResistance = 10; // positive values
    prerollTime = 2; // value in seconds. greater values give more precise result

    //
    fps = 1.0 / this_comp.frame_duration;
    if ( prerollTime > time ) prerollTime = time;
    dt = this_comp.frame_duration;
    frame = time * fps;
    integrationTime = time – prerollTime;

    s = [0,0];
    p = this_comp.layer(“Controller”).position.value_at_time( integrationTime );

    i = frame – prerollTime * fps;
    for (; i < frame; i++, integrationTime += dt ) { c = this_comp.layer("Controller").position.value_at_time( integrationTime ); d = c - p; s = s + d * springResistance; s = s * conserveMotion; p = p + s * dt; } Dan

    Activity

  • Rafael

    July 24, 2006 at 10:28 pm

    Hello Dan, thanks for answering.
    It does not work well. tarting from keyframe ‘A’ to keyframe ‘B’, the layer behaves strangly, it sort of shakes. What I am looking for is a spring effect that occurs after the keyframe B is done calculated on the speed.
    It seems like yours was closer to the answer.

  • Ryan Hill

    July 25, 2006 at 4:57 pm

    Did you try playing around with the “parameter” values?

    conserveMotion = 0.95; // valid range: 0.5 to 0.995
    springResistance = 10; // positive values

  • Rafael

    July 26, 2006 at 11:44 pm

    I tried changing those numbers.
    But it still doesn’t achieve the simple move from keyframe A to B with a spring effect after keyframe B.
    I guess it’s not possible. 🙁

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