Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: ForumAE BasicsAE ExpressionsTutorialsArticlesPodcastsMotion GraphicsTrainingCinema 4D

Finding a loop point in an Expression

Cow Forums : Adobe After Effects Expressions
cow
Finding a loop point in an Expression
by David Rodriguez on Jun 28, 2008 at 5:09:10 pm

I am using the following on position

xAmp = 30; //height of undulations (pixels)
xFreq = .8; //undulations per second
xSpeed = 350; //speed of wave (pixels per second)

wl = xSpeed/xFreq; //wavelength (pixels)
phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;
y = xAmp*Math.sin(2*Math.PI*xFreq*time + phaseOffset);

swayAmp = 50; //amplitude of sway
swayFreq = 2; //frequency of sway
x = swayAmp * Math.sin(time * swayFreq);

value + [x,y]


and the following on rotation

xFreq = .5; //undulations per second
xSpeed = 150; //speed of wave (pixels per second)
damping = 12; //undulation damping factor

wl = xSpeed/xFreq; //wavelength (pixels)
phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;
theta = Math.atan(Math.cos(2*Math.PI*xFreq*time + phaseOffset));
radiansToDegrees(theta)/damping;


Is there any way to make these expressions loopable? I would like the position and rotation to come back to the original starting point so that it makes a perfect loop cycle.

Any help would be greatly appreciated!


Respond to this post     Return to posts index

cow
Re: Finding a loop point in an Expression
by Dan Ebberts on Jun 28, 2008 at 9:33:36 pm

I think you'd need to pick your 3 frequencies so that they are harmonically related to get any kind of reasonable loop time. Right now you have two true "frequency" values (where you have the Math.PI*2 multiplier in the wave calc) and one where you haven't done that, so I think the calculation for how often the waves all get back to their starting positions at the same time will be ugly.

Let's say you set it up where your frequencies are 1, .5, and 1/3 (for example). That gives you periods of 1 sec, 2 sec, and 3 sec. The lowest common denominator for that would be 6 sec, so your animation would loop every six seconds.

Dan



Respond to this post     Return to posts index

cow
Re: Finding a loop point in an Expression
by David Rodriguez on Jun 29, 2008 at 2:16:39 am

[Dan Ebberts] "Right now you have two true "frequency" values (where you have the Math.PI*2 multiplier in the wave calc) and one where you haven't done that..."

Is it the sway frequency that lacks the Math.PI*2 multiplier?
Can I change the math in that part to match the others?
I am confused here, sorry for my lack of understanding in this area.


Respond to this post     Return to posts index


cow
Re: Finding a loop point in an Expression
by Dan Ebberts on Jun 29, 2008 at 6:43:54 pm

Yes. If you changed it from this:

x = swayAmp * Math.sin(time * swayFreq);

to this:

x = swayAmp * Math.sin(time * swayFreq * Math.PI * 2);

and changed swayFreq to .25, then you'd have .8, .5, and .25 which should repeat every 4 seconds (I think) :-)

Dan




Respond to this post     Return to posts index

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>


FORUMSTUTORIALSMAGAZINEDVDsBOOKSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]