Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Math.sin easing?

  • Dan Ebberts

    November 5, 2020 at 7:15 pm

    Hard to guess what you’re after exactly, but maybe something like this:

    freq = 2;

    amp = 100;

    period = 1/freq;

    t = time%period;

    tt = ease(t,0,period,0,period);

    amp*Math.sin(freq*tt*Math.PI*2)

  • Niek Pronk

    November 10, 2020 at 1:01 pm

    Hi Dan,

    thank you so much for your reply. It’s not really doing what I wanted though.

    Im trying to keep a pulse in my animation and let the Math.sin expression dictate that pulse. My expression is as follows:

    x=value[0];

    a=thisComp.layer(“SLIDER controls”).effect(“Amplitude 1”)(“Slider”);

    f=1.8461538462;

    t=time-inPoint;

    y=Math.sin(t*2*Math.PI*f/thisComp.layer(“SLIDER controls”).effect(“Speed”)(“Slider”))*a;

    [x,y]

    It is generating a nice pulse (see my attached screenshot) but I would like the top and bottom half of the pulse to have more ease-in and ease-out. Is this possible?

    Thanks again so much

    Niek

  • Filip Vandueren

    November 10, 2020 at 1:44 pm

    something like this:

    s = Math.sin(t);
    Math.pow(s, 0.5) * Math.sign(s);

    as that 0.5 will tend to 0, the sin will flatten the tops and bottoms of the sinewave more and more, approaching a square wave. Making the value of the power larger than 1 will make it approach a ‘needle pulse’ as it tends to infinity.

    If you are running the Legacy javascript engine. Math.sign() isnet supported and you would need this:

    s = Math.sin(t);
    Math.pow(s, 0.5) * (s<0 ? -1:1);

    replace the “t” with your formula of course.

  • Niek Pronk

    November 10, 2020 at 1:55 pm

    Hi Filip,

    thanks a lot for your reply. Not sure if I am applying your suggestion correctly. Does it mean I paste your suggestion after I’ve defined y? Like this:

    x=value[0];

    a=thisComp.layer(“SLIDER controls”).effect(“Amplitude 1”)(“Slider”);

    f=1.8461538462;

    t=time-inPoint;

    y=Math.sin(t*2*Math.PI*f/thisComp.layer(“SLIDER controls”).effect(“Speed”)(“Slider”))*a;

    Math.pow(y, 0.5) * Math.sign(y);

    [x,y]

    Because that unfortunately doesn’t change the pulse of the math.sin. But maybe I am doing something wrong here..?

  • Filip Vandueren

    November 10, 2020 at 4:02 pm

    You didn’t assign the new calculation to anything yet, so the y indeed stays unchanged.

    The Math.pow should be done on a -1 to +1 sin value, so wait with mulitplying *a untill afterwards.

    Like this:

    y=Math.sin(t*2*Math.PI*f/thisComp.layer("SLIDER controls").effect("Speed")("Slider"));

    y=Math.pow(y, 0.5) * Math.sign(y) * a;

    [x,y]

  • Niek Pronk

    November 12, 2020 at 8:10 am

    Thanks for your help Filip. Unfortunately it’s giving me an error and the movement is somehow only going up..

  • Filip Vandueren

    November 12, 2020 at 9:13 am

    Can you tell me the error ?

    Probably you are on an the legacy Javascript engine that doesn’t support Math.sign

    replace it with (s<0 ? -1:1)

  • Niek Pronk

    November 12, 2020 at 11:06 am

    It is still only completing the top half of the pulse. AE tells me it cannot produce a numeric value for [x,y]

    this is what i have now:

    y=Math.sin(t*2*Math.PI*f/thisComp.layer(“SLIDER controls”).effect(“Speed”)(“Slider”));

    y=Math.pow(y, 0.5) * (y<0 ? -1:1) * a;

  • Filip Vandueren

    November 14, 2020 at 2:06 pm

    Sorry, i forgot to include Math.abs(y) inside the power !

    x=value[0];

    a=thisComp.layer("SLIDER controls").effect("Amplitude 1")("Slider");

    f=1.8461538462;

    t=time-inPoint;

    y=Math.sin(t*2*Math.PI*f/thisComp.layer("SLIDER controls").effect("Speed")("Slider"));

    y=Math.pow(Math.abs(y), 0.5) * Math.sign(y) * a;

    [x,240+y];

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