• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Chunking up sine waves (one quarter at a time)

Participant ,
Aug 14, 2021 Aug 14, 2021

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:

math sin quarters only.jpg

TOPICS
Expressions , Scripting

Views

455

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Aug 15, 2021 Aug 15, 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

Votes

Translate

Translate
Community Expert , Aug 18, 2021 Aug 18, 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:

Broken Sin wave.png

 

Votes

Translate

Translate
Participant ,
Aug 14, 2021 Aug 14, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 14, 2021 Aug 14, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2021 Aug 15, 2021

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

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 22, 2021 Aug 22, 2021

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 18, 2021 Aug 18, 2021

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:

Broken Sin wave.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines