Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using Sine to drive Opacity, but between a range of values

  • Using Sine to drive Opacity, but between a range of values

    Posted by Alex Barnet on June 29, 2017 at 7:47 am

    I basically have a shadow underneath a hovering object that I want to increase and decrease in opacity as a function of a sin wave. The hovering object already has this expression on it’s y position:

    amp = 5;
    freq = .75;

    y = amp*Math.sin(time*freq*Math.PI*2);
    value + [0,y,0]

    The tricky part is, getting the max and min values to fall between something like 20 and 50. I understand it might be done with something like a clamp, but I don’t understand the syntax.

    Thanks

    Dan Ebberts replied 9 years, 2 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    June 29, 2017 at 1:13 pm

    This is probably the simplest:

    freq = .75;
    s = Math.sin(time*freq*Math.PI*2);
    linear(s,-1,1,50,20)

    You might have to swap the 50 and the 20.

    Dan

  • Alex Barnet

    June 29, 2017 at 11:22 pm

    Brilliant.

    Thanks Dan!

    p.s. my colleagues and I are trying to figure out what the purpose of the Math*PI function is?

  • Dan Ebberts

    June 30, 2017 at 12:23 am

    Math.PI*2 is the number of radians in one complete cycle of the sine wav. Including it lets the freq variable specify the frequency in complete cycles per second.

    Dan

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