View unanswered posts | View active topics It is currently Fri Dec 27, 2024 9:16 am



Reply to topic  [ 10 posts ] 
 Sine Waves 
Author Message
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Sine Waves
Well I put my own sine wave function together using some info from here (This was what I used).
Code:
Amplitude * math.sin(WaveNumber - AngularFrequency + Phase);

After peeking through Shook and Grif's code I was surprised I nearly got it right.
So, my questions are, why do they divide their phase by twenty? What do wavenumber and AngularFrequency do? And when I use my code, I have to update my wave's X position every frame, and when using Shook or Grif's code, the object moves on its own, Why?

My code + function. (Moves up, not right)
Shook's code + function.


Last edited by Roon3 on Wed Jul 29, 2009 9:06 am, edited 1 time in total.



Wed Jul 29, 2009 7:43 am
Profile WWW
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Reply with quote
Post Re: Sine Waves
Roon3 wrote:
Well I put my own sine wave function together using some info from here (This was what I used).
Code:
Amplitude * math.sin(WaveNumber - AngularFrequency + Phase);

After peeking through Shook and Grif's code I was surprised I nearly got it right.
So, my questions are, why do they divide their phase by twenty? What do wavenumber and AngularFrequency do? And when I use my code, my I have to update my wave's X position every frame, and when using Shook or Grif's code, the object moves on its own, Why?

My code + function. (Moves up, not right)
Shook's code + function.

The only significance about the number 20 I can think of is that it is equivalent to one in-game meter.


Wed Jul 29, 2009 8:59 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Reply with quote
Post Re: Sine Waves
Then wouldn't FrameMan.MPP work better?


Wed Jul 29, 2009 9:36 am
Profile
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Sine Waves
Roon3 wrote:
So, my questions are, why do they divide their phase by twenty? 1. What do wavenumber and AngularFrequency do? 2. And when I use my code, I have to update my wave's X position every frame, and when using Shook or Grif's code, the object moves on its own, Why? 3.

1. Arbitrary numbers are easier to type than static variable names?
2. wavenumber I think just allows for changing the position of the particle (on the y axis) when it first starts out. Not sure on angularfrequency, I suppose it might be another modifier for frequency.
3. You do not use the velocity of the particle for the x axis (or y axis in your case), Shook/Grif do. If you notice in their code, they reference self.Vel.X, storing the initial value to a variable to check against later. They only modify self.Pos.Y of the particle in question. They use the self.Pos.X as, well, x in a y=sin(x) sort of way. You increment Alpha in a sort of parametric way. x = sin(alpha), y = y-1


Wed Jul 29, 2009 2:21 pm
Profile
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: Sine Waves
Thank you Duh. The reason I did the Alpha thingy is because Wikipedia had Phase marked as a theta, so I figured is some kind of angle. Thanks for clearing that up. I can finally understand they mean here!

Edit: Wow, this phase stuff makes everything a lot clearer. Wavenumber = Frequency^(-1) Am I right?


Wed Jul 29, 2009 2:48 pm
Profile WWW
happy carebear mom
User avatar

Joined: Tue Mar 04, 2008 1:40 am
Posts: 7096
Location: b8bbd5
Reply with quote
Post Re: Sine Waves
Roon3 wrote:
Thank you Duh. The reason I did the Alpha thingy is because Wikipedia had Phase marked as a theta, so I figured is some kind of angle.

It is an angle measurement. The sine function is usually used in a circle, so the value you put in there is usually an angle. Sine gives the ratio of the opposite leg to the angle over the hypotenuse. Sorry if I sound pedantic, but I don't know where you're coming from as far as trigonometry.

Roon3 wrote:
Wavenumber = Frequency^(-1) Am I right?

Not sure if we're talking the same thing, but yes, Wavelength = 1 / Frequency.


Wed Jul 29, 2009 6:03 pm
Profile
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: Sine Waves
Duh102 wrote:
Sorry if I sound pedantic, but I don't know where you're coming from as far as trigonometry

I just finished 8th grade, (Never taken any trig classes) but don't worry, I understand what you mean.
Duh102 wrote:
Not sure if we're talking the same thing, but yes, Wavelength = 1 / Frequency.

I meant wavenumber, but never mind I did some testing and seems to be what I think it is.


Wed Jul 29, 2009 6:24 pm
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Sine Waves
The division by twenty is just an arbitrary constant that I cooked up to "slow" the entire wave down.


Wed Jul 29, 2009 11:14 pm
Profile
User avatar

Joined: Sun May 11, 2008 12:50 pm
Posts: 899
Reply with quote
Post Re: Sine Waves
Dividing by FrameMan.PPM works as well. Does anyone have any idea about what angular frequency does?


Thu Jul 30, 2009 11:49 am
Profile WWW
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Sine Waves
Roon3 wrote:
Does anyone have any idea about what angular frequency does?


Wiki says:
Quote:
Angular frequency is a measure of how fast an object is rotating


So, i'm guessing the higher the value, the faster waves curve.


Fri Jul 31, 2009 10:42 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.094s | 14 Queries | GZIP : Off ]