isuttell / sine-waves

Generate multiple configurable sine waves
Other
416 stars 67 forks source link

Standing wave #1

Open MarekSalat opened 9 years ago

MarekSalat commented 9 years ago

Hi, great job with this sine generator. I just want to know if it´s possible to model a standing wave (something like this https://skullsinthestars.files.wordpress.com/2008/05/standing.gif) with your generator. I have this http://codepen.io/anon/pen/MYGrLo but now I need to sum both waves together. I know you have custom wave types, however I need settings (time, speed, wave length etc.. or current x,y coordinates) from both waves to calculate new wave. How would you do that in your generator?

Thank you

isuttell commented 9 years ago

Hi! So off the top of my head I don't see any easy way to do that. Each wave is calculated on the fly and in sequence. I've got an idea to around that though. I can probably add a "postCalculation" event that is called after every wave has been calculated. Then you could combine the two waves at that point.

MarekSalat commented 9 years ago

You know what, I can show you my code (when I get home), because I have managed to write my own sin waves (I was lazy at first time). Btw general wave U is function of U(z, t) where t is time, and z point in space so

SineWaves.prototype.getPoint = function(time, position, options)

should be part of Wave itself instead of part of rendering function. When you have wave in form U(z, t) you may create new wave by composing other waves. I can send you my code, or refactor yours (if I have time).