What is the Best Way to Determine x Given y in a Sine Wave Algorithm?

Click For Summary

Discussion Overview

The discussion revolves around determining the value of x in a sine wave algorithm to control the appearance rate of objects (sheep) in a flash animation. Participants explore mathematical relationships and propose various approaches to achieve a total appearance within a specified frame count.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks a simpler method to determine x given y in the context of a sine wave, expressing frustration with complex equations.
  • Another participant provides sine function properties, suggesting they may be relevant to the problem.
  • A different participant questions whether the sine wave is intended to determine the rate of appearance or if random numbers are being used, indicating a potential misunderstanding of the approach.
  • A participant clarifies their goal of having a total number of sheep appear smoothly over a set duration, proposing a formula for calculating x based on the current sheep number.
  • Another participant suggests summing the intervals of the sine function and adjusting them to achieve a total of 240 frames, indicating a method for scaling the intervals.
  • One participant proposes a continuous model for the appearance rate of sheep using an integral of the sine function, providing a mathematical formulation that meets the specified conditions.
  • A later reply expresses enthusiasm for the explanation provided, indicating a newfound understanding of the concepts discussed.

Areas of Agreement / Disagreement

Participants express varying levels of understanding and propose different methods, indicating that multiple competing views remain. The discussion does not reach a consensus on a single approach.

Contextual Notes

Some mathematical steps and assumptions are not fully resolved, particularly regarding the scaling of intervals and the integration approach. The discussion reflects a range of interpretations and methodologies without definitive conclusions.

Who May Find This Useful

Individuals interested in mathematical modeling, animation programming, or those seeking to understand the application of sine functions in controlling rates of appearance in simulations may find this discussion beneficial.

webamoeba
Messages
3
Reaction score
0
Hi,

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:

Code:
y=sin(x)
y = interval before next object appears

so in Maple that'd be:

Code:
plot(sin(x)+1,x=Pi/2..Pi+(Pi/2));
Now I want the total of all the equations to = 240:

Code:
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
Code:
... (sin((((Pi/2)-(Pi+Pi/2))/y+1)*y) +1) ...

if y = 2 I would need to add
Code:
... (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!

thanks

hmmm, not sure that was a very good explanation, take a look at http://www.webamoeba.co.uk/glam/CS1S01/cw2/maths.gif

it mite make more sense ;)
 
Last edited by a moderator:
Physics news on Phys.org
I honestly have no idea what you're trying to do.
Anyway, hopefully the relations:

[tex]\sin(k\pi)=0[/tex]
and
[tex]\sin(\frac{\pi}{2}+k\pi)=(-1)^k[/tex]

where k is any integer, will help.
 
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"...
 
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 dissipate 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 won't 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.
 
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
 
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 modeled 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:

[tex]s(t)=\frac{N}{2}\int_0^t\sin(t')dt'=\frac{N}{2}(1-\cos(t))[/tex]

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:

[tex]s(t)=\frac{N}{2}(1-\cos(\frac{t\pi}{T}))[/tex]

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.
 
ooooooooooo

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 that's 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!
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
7
Views
3K
Replies
5
Views
7K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 16 ·
Replies
16
Views
2K