ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Min & Max Values

FAQ   •   VIEW ALL
 Min & Max Values on Feb 4, 2012 at 3:28:04 pm

Hey guys,

I have the expression: 'wiggle(7,21)' from my understanding the first number (7) controls the time between wiggles and the second number (21) controls the amount of wiggle. < Please correct me if that is wrong. I want to be able to set the min and max of the wiggle like 15-21 or something. Can anyone tell me how I would go about that.

Isaac

 Re: Min & Max Valueson Feb 4, 2012 at 5:24:53 pm

For a one-dimensional property (like rotation), you could do it like this:

minVal = 15;
maxVal = 21;
w = wiggle(7,1)-value;
value + linear(w,-1,1,minVal,maxVal)

It would be a little more complex for multi-dimensional properties, but the concept is the same.

Dan

 Re: Min & Max Valueson Sep 16, 2016 at 10:39:07 am

Hi Dan , Thanks for all the scripts you provide.

do you have an idea how to combine this one with your looping script?

freq = 1;
amp = 110;
loopTime = 3;
t = time % loopTime;
wiggle1 = wiggle(freq, amp, 1, 0.5, t);
wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime);
linear(t, 0, loopTime, wiggle1, wiggle2)

 Re: Min & Max Valueson Sep 16, 2016 at 1:05:10 pm

Try this:

minVal = 15;
maxVal = 21;
freq = 1;
amp = 110;
loopTime = 3;
t = time % loopTime;
w1 = wiggle(freq, 1, 1, 0.5, t)-value;
w2 = wiggle(freq, 1, 1, 0.5, t - loopTime)-value;
w = linear(t, 0, loopTime, w1, w2);
(minVal+maxVal)/2 + (maxVal-minVal)*w

Dan

 Re: Min & Max Valueson Feb 7, 2017 at 12:03:54 am

Hi there, that's a really useful expression. How would you modify it to only work for a single dimension (eg: X position)? Thanks in advance!

 Re: Min & Max Valueson Feb 7, 2017 at 12:31:23 am

Something like this should work:

minVal = 100;
maxVal = 200;
freq = 1;
amp = 110;
loopTime = 3;
t = time % loopTime;
w1 = wiggle(freq, 1, 1, 0.5, t)-value;
w2 = wiggle(freq, 1, 1, 0.5, t - loopTime)-value;
w = linear(t, 0, loopTime, w1, w2);
x = (minVal+maxVal)/2 + (maxVal-minVal)*w[0];
[x,value[1]]

Dan

 Re: Min & Max Valueson Feb 7, 2017 at 1:19:41 am

Great! Thanks Dan for the quick response.

That mostly works - it loops and only affects X, but the min/max is not working. It goes outside of the parameters that I set (I set it to min 0, max 250, and it's going both into negative numbers and above 250. Any thoughts as to why?

Thanks!

 Re: Min & Max Valueson Feb 7, 2017 at 1:27:09 am

It's hard to corral wiggle() precisely. You probably need to set your limits to something like 50 and 200.

Dan