ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Looping a sine expression within a 10 sec animation

FAQ   •   VIEW ALL
 Looping a sine expression within a 10 sec animation on Jul 12, 2018 at 6:08:53 am

Hi All,

I am trying to loop a sine expression within a 10sec frame so that when playback the sine wave is seamless.

Create a layer under Trapcode Particular
under Emitter>Position XY the expression is

xPos = 2800;
freq=0.15;
amp=random(50,100);
y = amp*Math.sin(freq*time*Math.PI*2);
yPos = y+360;
[xPos,yPos]

See my sample here.

Need some guidance on how to write the sine expression to loop whilst holding the same wave height/length and frequency ?

Thanks!
Nina

```xPos = 2800; freq=0.15; amp=random(50,100); y = amp*Math.sin(freq*time*Math.PI*2); yPos = y+360; [xPos,yPos] ```

 Re: Looping a sine expression within a 10 sec animationon Jul 12, 2018 at 6:15:04 am

Since your frequency is 0.15, after 10 seconds it will have completed 1.5 cycles, which won't loop correctly. It would work if your frequency were 0.1 or 0.2, but I don't know if either of those will work for you.

Dan

 Re: Looping a sine expression within a 10 sec animationon Jul 12, 2018 at 6:31:20 am

Thanks Dan,

I have amended the expression to the following

xPos = 2800;
freq=0.1;
amp=random(50,100)
y = amp*Math.sin(freq*time*Math.PI*2);
yPos = y+360;
[xPos,yPos]

However it seems that there's still a tinee misalignment with the particles.

I checked my other settings and think i have accurately set all other keyframes to loop at the same value start and end.

Can u assist to correct me where i went wrong?

Thanks!
Nina

```xPos = 2800; freq=0.1; amp=random(50,100) y = amp*Math.sin(freq*time*Math.PI*2); yPos = y+360; [xPos,yPos]```