Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions assistance explaining expression

  • assistance explaining expression

    Posted by Spaceman —> on October 3, 2012 at 12:24 pm

    Hi folks.
    SPACEMAN hgas inherited an expression although uses it
    and understands what it does, SPACEMAN does not understand
    the logic.
    Below, is the expression. SPACEMAN would be extremely grateful if someon could
    explain it.

    SPACEMAN
    🙂

    n = 0
    if ((numKeys)> 0)
    {
    n = nearestKey(time).index;
    if ((key(n).time)> time){n--;}
    }
    if (n == 0){t = 0;}
    else{ t = time - key(n).time; }
    if ((n)> 0)
    {
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    amp = thisComp.layer("+sliders+").effect("amp")("Slider");
    freq = thisComp.layer("+sliders+").effect("freq")("Slider");
    decay = thisComp.layer("+sliders+").effect("decay")("Slider");
    value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }
    else{ value; }

    SPACEMAN needs spaceship parts, not expressions…

    Dan Ebberts replied 13 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    October 3, 2012 at 9:13 pm

    The first section finds the most recent keyframe and sets variable t to the time that has elapsed since the keyframe (unless no keyframe has been reached yet, in which case t is set to zero).

    The second section gets the velocity coming into the keyframe (actually one tenth of a frame prior to the keyframe) and multiplies that by the amp slider to get the initial amplitude of a decaying sine wave that is added to the property’s current value. The frequency of the decaying wave is set by the freq slider and the decay rate is set by the decay slider.

    Does SPACEMAN have any specific questions?

    Dan

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