-
an expression for a loop-able wiggle
Hi all,
not sure if something like this has been posted before, but I think I rememebr seeing the question sometimes.
if you find you need to wiggle something, but you want it to loop seamlessly, you can use this function:function loopedRandom (t, loopTime, seed) { seedRandom(seed, timeless = true); startPos=random([5000,5000]) radius=0.25; x=startPos[0] + Math.cos(degreesToRadians(360*t/loopTime))*radius y=startPos[1] + Math.sin(degreesToRadians(360*t/loopTime))*radius return noise([x,y]) }
This function returns a value between 0 and 1, based on t and it will return the same value every loopTime seconds.
Unfortunately, it doesn’t have frequency and octaves like wiggle, but by increasing the radius-value you get faster changing results.
It works by sampling the values in a noise-field on a circular path. (see Dan Ebberts’ tut. on After Effects Hidden Gem: noise() for more info on noise)for example use it like this:
position + [ loopedRandom(time,10,1) , loopedRandom(time,10,2) ]*50 // 2-dimensional -> call twice with diff. seed function loopedRandom (t, loopTime, seed) { ... }