Copy link to clipboard
Copied
Hi I hope this actually makes sense. The picture might actually make this more confusing.
I am messing around with Sine waves trying to isolate various quarters of the wave phases.
I am trying to achieve a sine wave that reaches its peak then zeroes for another 3 phases i.e. just 1 quarter of the sine wave. Then I want to try and isolate the other 3 quarters. (End goal is to draw on all these quarters individually when I’m animating.)
I have drawn the kind of sine wave I’m attempting to achieve first next to some of my other attempts (charted up in excel) .
If anyone can please help me to isolate quadrants of the sine wave I would have a very nice weekend.
Picture:
Looks like you want the green curve whenever (time%1)<0.5 and the value 0 otherwise.
so you could use the expression
(time % 1 < 0.5) ? Math.sin(Math.PI*(time%1)) : 0
or the equivalent
if(time %1 < 0.5) Math.sin(Math.PI*(time%1))
else 0
Borrowing from Dan Ebberts Motionscript.com and Mathias Moehl's suggestion I came up with this to animate the position of a circle.
veloc = 200; //horizontal velocity (pixels per second)
amp = 300; //sine wave amplitude (pixels)
freq = 2.4; //oscillations per second
x = time*veloc;
y = amp*Math.sin(freq*(time % 1 < 0.5) ? Math.sin(Math.PI*(time%1)) : 0) - thisComp.height/2;
[x,- y]
The project looks like this:
Copy link to clipboard
Copied
I know the rules - I shouldn't be replying to my own post but have passed the deadline to edit.
I just thought of clamp() and that it might help. Still looking for the right answer though
Copy link to clipboard
Copied
That would simply be achieved by combining different functions inside the same equation. 6th grade math. The steep drop would be a simple threshold function intersecting with the sine, just the phase lengths would be different. Not sure what more you would need to know here.
Mylenium
Copy link to clipboard
Copied
Looks like you want the green curve whenever (time%1)<0.5 and the value 0 otherwise.
so you could use the expression
(time % 1 < 0.5) ? Math.sin(Math.PI*(time%1)) : 0
or the equivalent
if(time %1 < 0.5) Math.sin(Math.PI*(time%1))
else 0
Copy link to clipboard
Copied
Thanks Mathias - that was a great help exactly what I was looking for. Thankyou.
Rick also provided what I was after in another form. Thanks to you too.
Mylenium was helpful too in his own way. Thankyou. Yours is the third best answer of the three.
Copy link to clipboard
Copied
Borrowing from Dan Ebberts Motionscript.com and Mathias Moehl's suggestion I came up with this to animate the position of a circle.
veloc = 200; //horizontal velocity (pixels per second)
amp = 300; //sine wave amplitude (pixels)
freq = 2.4; //oscillations per second
x = time*veloc;
y = amp*Math.sin(freq*(time % 1 < 0.5) ? Math.sin(Math.PI*(time%1)) : 0) - thisComp.height/2;
[x,- y]
The project looks like this: