Skip to main content
Inspiring
August 15, 2021
Answered

Chunking up sine waves (one quarter at a time)

  • August 15, 2021
  • 4 replies
  • 939 views

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:

This topic has been closed for replies.
Correct answer Rick Gerard

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:

 

4 replies

Rick GerardCommunity ExpertCorrect answer
Community Expert
August 19, 2021

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:

 

Mathias Moehl
Community Expert
Community Expert
August 16, 2021

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

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
sillybombAuthor
Inspiring
August 22, 2021

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.

Mylenium
Legend
August 15, 2021

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

sillybombAuthor
Inspiring
August 15, 2021

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