A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Converting physics to actionscript

  1. #1
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140

    Converting physics to actionscript

    I have so much trouble understanding mathematical equations not written for code, i have no idea how to convert these equations into working code. I need some pointers or some links to help me.

    Like this, how in hell would i write this in code.

    m(dv/dt)=-kv2

    where m is the mass of the ball, (dv/dt) is the derivative based on time, representing acceleration, and k is the side force constant.

    here's the web site i got it from link

    i'm trying to create cricket ball physics and i just don't know where to start. I know this page has everything i need, but i just need some help explaining what i need to do to make this in ActionScript.
    lather yourself up with soap - soap arcade

  2. #2
    Not Real since 1985
    Join Date
    Feb 2002
    Location
    Netherlands
    Posts
    229
    Before 1985 I was teacher in math and physics, but I had to think twice when I read this. You don't go for the easy
    The equation you mention is not very useful as it is written but if you take into account the acceleration a = dv/dt you can change the equation to
    a = -k*(v^2)/m

    Given m (mass) and k are constants and if you know the starting speed (v) you can calculate the acceleration (which will be negative because it is going slower, don't know the english word. Something like decelleration?).

    Anyhow, on this site they go quite in detail to make beautiful formula's, but I think that's how Physicians are (and I still know a few of them).

    I bought a book once from MM press: flash mx game design. It shows how this kind of formulas can be simplified while still keeping a reasonable sense of reality. Don't know how realistic your model should be.

    Good luck, I would find some physician on your neighborhood to assist and talk things through.
    Never accept the first 'impossible' unless it comes from a lady.

  3. #3
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    Hey Mr. Malee,

    I skimmed over that link that you provided, and i agree that it is very confusing

    Confusion that isn't very neccessary though, since, as i have discovered, solving physics problems in a book, and simulating physics on the computer are two different things that need to be dealt with differently

    when you solve a regular physics problem your delta time can be anything, while when running a simulation it is usually fixed, and or very small.

    so, what i'm really trying to say here is that when using numerical integration (how its done on the computer) you don't look at the big picture. on every frame (or every time step) you move the objects a little bit more by applying to them all of the forces that you should, and when you run the simulation it should all look right

    some the equations that you are looking at are trying to solve for things that dont need to be solved for in numerical integration, like the time the ball is in the air, and the speed it is traveling, which makes them a bit more complicated - but the good thing is that you're trying to make a simulation

    so if you want to convert those equations into actionscript, you'd have to change them around so that they fit into your integration, which means that they affect either the position, velocity, or acceleration of the objects.

    and that's my piece of wisdom for the day
    i hope i helped

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