ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Alex Barnet
Using Sine to drive Opacity, but between a range of values
on Jun 29, 2017 at 7:47:25 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


Return to posts index

Dan Ebberts
Re: Using Sine to drive Opacity, but between a range of values
on Jun 29, 2017 at 1:13:08 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



Return to posts index

Alex Barnet
Re: Using Sine to drive Opacity, but between a range of values
on Jun 29, 2017 at 11:22:03 pm

Brilliant.

Thanks Dan!

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


Return to posts index


Dan Ebberts
Re: Using Sine to drive Opacity, but between a range of values
on Jun 30, 2017 at 12:23:26 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



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]