2 Replies Latest reply on Nov 6, 2017 10:58 AM by Dan Ebberts

    Help Combining two Expressions

    Sully Taylor

      Hello,

       

      I have two expressions that both work independently that I am trying to combine to use on the same layer.

      The first one is a Z space zoom effect:

      zoom = 5000; //distance to zoom
      trans = 4; // transition time in frames
      trans = trans * thisComp.frameDuration;
      
      inTrans = easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,0]);
      outTrans = easeOut(time, outPoint, outPoint - trans*2, [0,0,0], [0,0,zoom]);
      value+ inTrans - outTrans
      

      And the second is an overshoot expression:

      freq = 3;
      decay = 5;
      amp = 80;
      n = 0;
      if (numKeys > 0){
        n = nearestKey(time).index;
        if (key(n).time > time) n--;
      }
      if (n > 0){
        t = time - key(n).time;
        amp = velocityAtTime(key(n).time - .001);
        w = freq*Math.PI*2;
        value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
      }else
        value
      

      This is my current attempt at combining the two, but I cant get it working. Thanks in advance for the help!

      zoom = 5000; //distance to zoom
      trans = 4; // transition time in frames
      trans = trans * thisComp.frameDuration;
      freq = 3; decay = 1;
      inTrans  = easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,100]);
      outTrans = eaoint, outPoint - trans*1, [0,0,0], [0,0,zoom]);
      
      n = nearestKey(time).index;
      amp = velocityAtTime(key(n).time - .001);
      t = time - inPoint;
      w = freq*Math.PI*2;
      value + inTrans - outTrans + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
      
        • 1. Re: Help Combining two Expressions
          Mylenium Most Valuable Participant

          I'm not clear what you are hoping to achieve. You totally nixed the conditional statemnets to retrieve the keyframe info, so this cannot work - the evaluation condition simply is never valid. That being said, the "trans" stuff would have to be applied as a filter curve to the result of the overshoot expression, not added or subtracted. In effect this simply means where "time" is used in the zoom expression's easIn() and easeOut() you fill in the result of your overshoot. It's a simple case of modulating one result with another. Of course it may require some tweaking, but it's to ealry in the morning for me to realyl get into it...

           

          Mylenium

          • 2. Re: Help Combining two Expressions
            Dan Ebberts Level 5

            This might work:

             

            zoom = 5000; //distance to zoom

            trans = 4; // transition time in frames

            trans = trans * thisComp.frameDuration;

            if (time < inPoint+trans){

              value + easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,0]);

            }else if (time > outPoint - trans*2){

              value - easeOut(time, outPoint, outPoint - trans*2, [0,0,0], [0,0,zoom]);

            }else{

              freq = 3;

              decay = 5;

              amp = 80;

              n = 0;

              if (numKeys > 0){

                n = nearestKey(time).index;

                if (key(n).time > time) n--;

              }

              if (n > 0){

                t = time - key(n).time;

                amp = velocityAtTime(key(n).time - .001);

                w = freq*Math.PI*2;

                value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);

              }else{

                value;

              }

            }

             

             

            Dan

             

            [EDIT]  This is probably better:

             

            freq = 3; 

            decay = 5; 

            amp = 80; 

            n = 0; 

            if (numKeys > 0){ 

              n = nearestKey(time).index; 

              if (key(n).time > time) n--; 

            }

            val = value;

            if (n > 0){ 

              t = time - key(n).time; 

              amp = velocityAtTime(key(n).time - .001); 

              w = freq*Math.PI*2; 

              val += amp*(Math.sin(t*w)/Math.exp(decay*t)/w); 

            }

            zoom = 5000; //distance to zoom 

            trans = 4; // transition time in frames 

            trans = trans * thisComp.frameDuration;

            if (time < inPoint+trans){

              val += easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,0]);

            }else if (time > outPoint - trans*2){

              val -= easeOut(time, outPoint, outPoint - trans*2, [0,0,0], [0,0,zoom]);

            }

            val

             

             

            Dan

            1 person found this helpful