Register to reply

Sine wave - long algorithm :s

by webamoeba
Tags: algorithm, sine, wave
Share this thread:
Mar9-05, 05:09 AM
P: 3

This maths stuff is tstarting to hurt my head!!! :p Ok, I want to use a sine wave to make objects appear at an increasing rate and then a decreasing rate. e.g. where:

y = interval before next object appears

so in Maple that'd be:

Now I want the total of all the equations to = 240:

solve(((sin(Pi/2)+1)+(sin(Pi/2)+1))*x=240, x);
x comes to 60 in this case. Now I want to alter the equation so as it takes another variable, y, where y = the number of objects (integer >= 0), this does not include the first and last objects.

so if y = 1 I would need to add
... (sin((((Pi/2)-(Pi+Pi/2))/y+1)*y) +1) ...
if y = 2 I would need to add
... (sin((((Pi/2)-(Pi+Pi/2))/(y-1)+1)*(y-1)) +1) + (sin((((Pi/2)-(Pi+Pi/2))/y+1)*y) +1) ...
Is there an easier way to determine x given y? without having to use all of those nasty looking equations!!!!


hmmm, not sure that was a very good explanation, take a look at

it mite make more sense ;)
Phys.Org News Partner Mathematics news on
Researcher figures out how sharks manage to act like math geniuses
Math journal puts Rauzy fractcal image on the cover
Heat distributions help researchers to understand curved space
Mar9-05, 06:02 AM
Sci Advisor
HW Helper
Galileo's Avatar
P: 2,002
I honestly have no idea what you're trying to do.
Anyway, hopefully the relations:


where k is any integer, will help.
Mar9-05, 06:10 AM
PF Gold
P: 734
What are you trying to do? Is it a simulation? you mention that you want some things to "appear at an increasing rate". Is the sine wave to determine the rate of appearance? are you using random numbers to actually determine the time for each appearance? if so, then it seems you can't use "solve"...

Mar9-05, 06:20 AM
P: 3
Sine wave - long algorithm :s

I thought I'd managed to write it badly ;) lol.

Ok, I have a flash movie with sheep that jump over a bed. I want to be able to specify the total number of sheep that will appear (lets call it s), and I want the rate at which they appear to increase smoothly, then disipate again. This must all happen within 240 frames (10 seconds), although I may want to adjust this as well later...

So I need to be able to determine the value of x on the diagram, now I think i should be using (Pi/s)*i where i is the current sheep number (starting from 0). to get the x value on a graph. So to get the y value on the graph I go sin((Pi/s)*i) from i=0 to i=i and add them together, however they wont equal 240, so I need to work out what value to times them by to get 240 as the total everytime...

does that make more sense???

thanks again.
Mar9-05, 07:00 AM
P: 540
You just add all the intervals (sin((Pi/s)*i) from i=0 to i=s) let's call the sum off all of them n, now n wil not be 240.

If you divide each interval by n the sum of all of them will be 1, but you want the sum of all intervals to be 240 so you must divide each interval by n and multiply the result by 240.

so the interval you use is:

new_interval = interval * 240/n
Mar9-05, 07:01 AM
Sci Advisor
HW Helper
Galileo's Avatar
P: 2,002
Let me get this straight.
So you want the rate to increase in the beginning and decrease near the end. Then the rate be can modelled by a sine from t=0 to t=pi (you can change this later).
At t=0, the number of sheep is 0 and at t=pi (to become 10 seconds later) it will be s=N, the total number of sheep. (We'll take the rate to be continuous for now).

Then the number of sheep at time t is:


This function satisfies s(0)=0 and s(t)=N.

If you want to go from t=0 to t=T, then it simply becomes:


The moments at which a sheep should arrive are thus values of t for which s(t)=1, s(t)=2, s(t)=3 etc.
Mar9-05, 08:01 AM
P: 3

i love u!

well maybe not love ;) but you know what I mean :D. And the strangest thing is, I actually seem to understand it! my god thats a new one on me ;) lol.

Thanks for the input everyone! Now all I;ve got to do is go and implement it :s lol.

Thanks again!

Register to reply

Related Discussions
Sine wave problem General Math 2
Creating sine wave Electrical Engineering 11
How do I define a sine wave? Introductory Physics Homework 2
Sine Wave or Spiral Quantum Physics 4
Is this a sine wave? General Discussion 5