A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Is this model doable in Flash, while still being viewable over the internet?

Hybrid View

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    3

    Is this model doable in Flash, while still being viewable over the internet?

    I want to make an animation in flash as follows: A 2D chamber containing thousands of gas molecules (each represented as one pixel, and each assumed to be of identical mass) with 2D gaussian speed distribution, colliding elastically with one another and with the chamber walls.

    I then want one of the chamber's walls to to vibrate back and forth, where the amplitude of vibration at each frame is read from a WAV file. (basically, this wall is a speaker)

    Finally, I want the opposite chamber wall to vibrate as a function of the force being applied to it by the gas molecules that collide with it. (basically, this wall is a microphone) I then want to plot the amplitude of this vibration over time.

    Ideally, this animation would run at 44100 frames/second. But I could lower the frame rate if absolutely necessary.

    Do you think that this will be too computer resource intensive for internet viewing?

    Can you recommend any particular tutorials and/or code to help me make this animation? I'm a flash noob but I'm familiar with computer programming, and the physics models that would be involved in making an animation like this.

    Thanks, any help would be much appreciated

  2. #2
    Junior Member
    Join Date
    Jan 2006
    Posts
    16
    What would be the purpose of the animation?

    Flash can only do a framerate of 120, and I'm sure humans will see vibration even at that as merely a blur, let alone 44.1khz

  3. #3
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    what would be the visual difference between "thousands of gas molecules (each represented as one pixel, and each assumed to be of identical mass)... colliding elastically with one another" and simply passing through each other?
    who is this? a word of friendly advice: FFS stop using AS2

  4. #4
    Junior Member
    Join Date
    Mar 2008
    Posts
    3
    The purpose of the animation is to demonstrate how sound is created, propagated through air, and recorded.

    The air molecules must collide and not pass through one another. Air molecule collision is necessary for sound to propagate through air in any model.


    The reason for wanting a framerate of 44100 frames/sec is that the framerate of an audio .wav file is 44100 frames/sec. I'll want to slow down playback of the animation anyway, I can simply slow it down enough so that the audio .wav file's frame rate matches flash's frame rate.

    Can you recommend any particular tutorials and/or code to help me make this animation?

  5. #5
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    Quote Originally Posted by maxplanck
    The air molecules must collide and not pass through one another. Air molecule collision is necessary for sound to propagate through air in any model.
    why are you so sure can you please write down equations for speed of two (I assume no more than two will collide at once) moleculas before and after collision here?
    who is this? a word of friendly advice: FFS stop using AS2

  6. #6
    Junior Member
    Join Date
    Mar 2008
    Posts
    3
    Well, it may not be necessary (MAY, I'm not sure), but this is how it's represented almost universally, and this representation is closer to the truth than a model that assumes collisions never occur. So, I'd like to do it this way.

    I think that I must allow for multiple simultaneous collisions, since they are bound to occur in such a model.

    Here are the relevant equations. I'm hoping to find a Flash Physics environment that already contains these, or at least some flash actionscript code that already contains these.

    http://www.plasmaphysics.org.uk/programs/coll2d_cpp.htm

    http://www.plasmaphysics.org.uk/collision2d.htm

    http://en.wikipedia.org/wiki/Elastic...ee-dimensional

  7. #7
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    from the last link you posted, take a look at

    and

    and tell me, what would be the difference from when black box simply passes through blue? what they do is merely exchange speed and, since your moleculas will be all same color, there will be no noteable difference.

    then again, you might want to (needlessly) complicate things assuming non-central collisions, but imho that would be simply waste of CPU.
    who is this? a word of friendly advice: FFS stop using AS2

  8. #8
    Junior Member
    Join Date
    Mar 2008
    Posts
    3
    wow that hadn't occurred to me, thanks!

    In that case, I should be able to completely omit particle-particle collisions from the model.. thanks a lot!

    Now, all I need to model is:

    Speaker Membrane-Particle Collisions (particle simply reverses horizontal velocity, plus speaker membrane velocity)

    Particle-Wall Collisions (particle simply reverses vertical velocity)

    Particle-Microphone Membrane Collisions (displacement of Microphone Membrane calculated using a simple spring model, with force applied to the spring at any given instant calculated as a function of the sum of the horizontal velocities of the particles in collision with the spring at that instant)


    Can you recommend any particular tutorials and/or code to help me make this animation? I just want to avoid re-inventing the wheel, if you know what I mean.


    Also: Can you recommend another programming environment/language that will allow users to view and operate this application through a web page, but which will allow me to use a frame rate of 44100 frames per second? I'd like to be able to allow the user to slow down the frame rate as well. I'd also like to be able to use .wav files to control the Speaker Membrane, and to be able to play these .wav files through the user's speakers through the application.

    This probably sounds pretty ambitious, but I want to try to make it happen if it's possible.

  9. #9
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    no application will allow you frame rate 44k, because, well, CRT cant handle it (not to mention LCD). what you could possibly do is calculate at 44k rate, but draw only at ~20. but this way, you are wasting lots of resources for nothing (in any environment), because much lower rates will result in calculation with acceptable error.

    now, with flash/as3 you can use mp3 file to control membrane, this is described all over the net.

    you can also have bouncing particles in flash more or less along the lines you yourself wrote, maybe up to 50 000 at reasonable frame rate, but the thing is that real moleculas move very fast... as Stuv said, if you draw it without timelapse you get blur (or noise) at best. which means they have to move much slower on screen than they in fact do in gas.

    as for alternative environment? you can try and dig into ps3, I have heared they have powerful built-in physics.
    who is this? a word of friendly advice: FFS stop using AS2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center