# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Math.sin wave cycle

• # Math.sin wave cycle

2 Members · 3 Posts
• ### Alex Andry

June 20, 2022 at 11:50 am

Hello everyone,

is it possible to make a cycle through the length of the composition from this expression?

Thank you!

S = effect(“Speed”)(“Slider”);

A = effect(“Amp”)(“Slider”);

F = effect(“Frequency”)(“Slider”);

R = effect(“Resolution”)(“Slider”);

W = effect(“Width”)(“Slider”);

P = [];

for (i=0; i<R; i++) {

P.push([W/R*i, Math.cos(time*S+i / (R/F))*A]);}

createPath(P, [], [], false)

• ### Filip Vandueren

June 20, 2022 at 12:41 pm

Try this, with a slider “Cycles” instead of “Speed” that you set to how many cycles you want to occur in the comp’s duration, then:

`C = effect("Cycles")("Slider");S = (Math.PI*2*C)/thisComp.duration;A = effect("Amp")("Slider");F = effect("Frequency")("Slider");R = effect("Resolution")("Slider");W = effect("Width")("Slider");P = [];for (i=0; i<R; i++) {	P.push([W/R*i, Math.cos(time*S+i / (R/F))*A]);	}createPath(P, [], [], false)`
• ### Alex Andry

June 20, 2022 at 1:03 pm

Perfect!

Thank you Filip!

I tried to solve it in a different way and confused myself.

Viewing 1 - 3 of 3 posts