# After Effects Expressions

Currently Being Moderated

## Snappier Wiggle?

### Jun 27, 2012 1:06 PM

Tags:

How would you make a wiggle expression that radically reduced the time between values?  Like Wiggle that uses Exponential interpolation as inbetween values? So even though the pace would be something like wiggle(1,50), it would take much less than the 1 second wiggle interval to change between values.

Kind of like how a hummingbird feeds? It hovers, hovers, hovers... then snap into a new position.... hover, hover, hover... snap into new position.

(Also, is the Jagged/Smooth option of the ancient Wiggler available in expression form?)

Replies
• Currently Being Moderated
Jun 27, 2012 1:55 PM   in reply to Navarro Parker

Interesting idea. I think it might be easier to do it this way than to start with wiggle():

minVal = -100;

maxVal = 100;

minDuration = 0.5;

maxDuration = 1.5;

transRate = 400;

tEnd = 0;

n = 0;

seedRandom(n, true);

preRun = random(maxDuration);

while (time + preRun >= tEnd){

n++;

seedRandom(n, true);

dur = random(minDuration, maxDuration);

tEnd += dur;

}

t = time + preRun - (tEnd - dur);

n += 9973;

seedRandom(n, true);

endVal = random(minVal, maxVal);

seedRandom(n - 1, true);

startVal = random(minVal, maxVal);

delta = endVal-startVal;

transTime = Math.abs(delta/transRate);

ease(t, (dur-transTime)/2,(dur+transTime)/2, startVal, endVal);

You can make wiggle() more jagged by increasing the number of octaves (third parameter of wiggle()).

Dan

|
Mark as:
• Currently Being Moderated
Jun 27, 2012 2:52 PM   in reply to Navarro Parker

I guess 2D positon would be more like this:

minVal = [0,0];

maxVal = [thisComp.width,thisComp.height];

minDuration = 0.5;

maxDuration = 1.5;

transRate = 1000;

tEnd = 0;

n = 0;

seedRandom(n, true);

preRun = random(maxDuration);

while (time + preRun >= tEnd){

n++;

seedRandom(n, true);

dur = random(minDuration, maxDuration);

tEnd += dur;

}

t = time + preRun - (tEnd - dur);

n += 9973;

seedRandom(n, true);

endVal = random(minVal, maxVal);

seedRandom(n - 1, true);

startVal = random(minVal, maxVal);

delta = length(endVal,startVal);

transTime = Math.abs(delta/transRate);

ease(t, (dur-transTime)/2,(dur+transTime)/2, startVal, endVal);

Dan

|
Mark as:
• Currently Being Moderated
May 22, 2013 4:11 PM   in reply to Navarro Parker

Something like this should work:

minVal = [-100,-100];

maxVal = [100,100];

minDuration = 0.5;

maxDuration = 1.5;

transRate = 1000;

tEnd = 0;

n = 0;

seedRandom(n, true);

preRun = random(maxDuration);

while (time + preRun >= tEnd){

n++;

seedRandom(n, true);

dur = random(minDuration, maxDuration);

tEnd += dur;

}

t = time + preRun - (tEnd - dur);

n += 9973;

seedRandom(n, true);

endVal = random(minVal, maxVal);

seedRandom(n - 1, true);

startVal = random(minVal, maxVal);

delta = length(endVal,startVal);

transTime = Math.abs(delta/transRate);

value + ease(t, (dur-transTime)/2,(dur+transTime)/2, startVal, endVal);

Dan

|
Mark as:
• Currently Being Moderated
May 24, 2013 10:04 AM   in reply to Navarro Parker

Couldn't you just use multiple wiggles?

So you'd have a wiggle that would give you spikes btween 0 and 1:

Math.pow(0.5 + wiggle(1, 0.5), 10)

and you could use that to drive the frequency of another wiggle:

wiggle(Math.pow(0.5 + wiggle(1, 0.5), 10)*10, 50)

I haven't tried it, not sure if it works as I imagine. And the factors of 10 are just randomly chosen here ... But maybe worth a try.

EDIT: nope, I tried and it's not as straightforward as I thought.

|
Mark as:
• Currently Being Moderated
Jun 16, 2013 8:09 PM   in reply to Navarro Parker

This should work:

value + [ease(t, (dur-transTime)/2,(dur+transTime)/2, startVal, endVal)[0],0];

But if you're going to do that you might as well just do the random part in 1D:

minVal = -100;

maxVal = 100;

minDuration = 0.5;

maxDuration = 1.5;

transRate = 1000;

tEnd = 0;

n = 0;

seedRandom(n, true);

preRun = random(maxDuration);

while (time + preRun >= tEnd){

n++;

seedRandom(n, true);

dur = random(minDuration, maxDuration);

tEnd += dur;

}

t = time + preRun - (tEnd - dur);

n += 9973;

seedRandom(n, true);

endVal = random(minVal, maxVal);

seedRandom(n - 1, true);

startVal = random(minVal, maxVal);

delta = length(endVal,startVal);

transTime = Math.abs(delta/transRate);

value + [ease(t, (dur-transTime)/2,(dur+transTime)/2, startVal, endVal),0];

Dan

|
Mark as:
Actions

#### More Like This

• Retrieving data ...

#### Answers + Points = Status

• 10 points awarded for Correct Answers