integrate/differentiate

Discussion in 'Indie Basics' started by alien02, Mar 5, 2005.

  1. alien02

    Original Member

    Joined:
    Mar 5, 2005
    Messages:
    7
    Likes Received:
    0
    How do you integrate/differentiate when your programming? I know how to do it by hand, but not sure how to tell the computer to do it. I wouldve have thought that checking the power (p) and adding one and dividing by (p + 1) would be quite slow in real time. Any suggestions?
    Thank you
     
  2. Mike Boeh

    Administrator Original Member

    Joined:
    Jul 26, 2004
    Messages:
    949
    Likes Received:
    0
    To be honest, I have never once had the need to do either- but I would be interested to know how that comes up in game programming.
     
  3. Omega

    Original Member

    Joined:
    Sep 2, 2004
    Messages:
    265
    Likes Received:
    0
    Something like objectname.integrate(s) ?
     
  4. alien02

    Original Member

    Joined:
    Mar 5, 2005
    Messages:
    7
    Likes Received:
    0
    Maybe Im going about it the wrong way, but Im trying to incorporate a physics engine. Assuming I have acceleration, I could integrate to find velocity and integrate velocity to find position. This could also be reversed by differentiation. However, when it comes to programming the actual thing, Im not sure if I should be integrating, or if theres another method that does the same thing.

    Sorry I dont use C++, I use blitz so Im not sure what the equivalent of that function is.
     
  5. FlySim

    Indie Author

    Joined:
    Jul 30, 2004
    Messages:
    352
    Likes Received:
    0
    Take a look at numerical integration - lots easier than doing it symbollically. It is used in most physics engines.

    I use Verlet integration - easy and stable.
     
    #5 FlySim, Mar 5, 2005
    Last edited: Mar 5, 2005
  6. alien02

    Original Member

    Joined:
    Mar 5, 2005
    Messages:
    7
    Likes Received:
    0
    Thanks FlySim, Ill take a look at both of those.
     
  7. ggambett

    Moderator Original Member Indie Author

    Joined:
    Jul 26, 2004
    Messages:
    1,982
    Likes Received:
    6
    You don't need to make a symbolic integration engine, because you know beforehand what functions do you want to integrate. So, just calculate the primitives (or anti-derivatives or whatever you call them) and integrate knowing that integral(f'(x)) | (t1, t2) = f(t2) - f(t1) where f'(x) is the derivative of f(x).

    Or you could do numerical integration, which is what most people do.
     
  8. Midnight Synergy

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    275
    Likes Received:
    0
    Absolutely go with numerical solutions - integration, differentiation, solving ODEs, PDEs, Integral Equations, even solving equations for roots. Doing it symbolically would be a huge task (there are big software packages like Maple that do just that) and also very slow in a gaming physics engine.

    Solve the problem mathematically first, then look at what your game actually needs to do, then look at how you can do that much more quickly.

    Simple example: You want to calculate the parabolic path of a projectyle. Rather than actually finding the h(t) height equation for this, realize that in a parabolic path the velocity (i.e. the delta-h) increases/decreases in a linear fashion. So all you need to do is steadily decrease the delta-h and keep adding that to your current height. This way you accomplish with two additions which would otherwise take at least a quadratic function (not a huge difference, for sure, but this is just a simple example).
     
  9. PeterM

    Original Member

    Joined:
    Aug 5, 2004
    Messages:
    343
    Likes Received:
    0
    There are a good set of articles at Gaffer's site about integration in game physics.

    http://www.gaffer.org:8080/articles/

    e.g.

    Why euler integration should be avoided
    Fixing your timestep
    Physics over the internet

    Hope this helps,
    Pete
     
  10. alien02

    Original Member

    Joined:
    Mar 5, 2005
    Messages:
    7
    Likes Received:
    0
    Thanks. Does that site have a mirror, because it seems like its down :(

    EDIT: No worries, google cache to the rescue :D. This site looks very interesting.
     
    #10 alien02, Mar 5, 2005
    Last edited: Mar 5, 2005
  11. PeterM

    Original Member

    Joined:
    Aug 5, 2004
    Messages:
    343
    Likes Received:
    0
  12. ibsta

    Original Member

    Joined:
    Oct 22, 2004
    Messages:
    61
    Likes Received:
    0
    Most of the people who incorporate basic physics actually use integration without even knowing it! The use a very basic form of integration known as Euler's method.

    Right now I'm busy, but I'll try to post more on this plus some nice links.
     
  13. alien02

    Original Member

    Joined:
    Mar 5, 2005
    Messages:
    7
    Likes Received:
    0
    Thanks Ibsta, the more info the better :)
     
  14. ibsta

    Original Member

    Joined:
    Oct 22, 2004
    Messages:
    61
    Likes Received:
    0
    Here are some excellent links that should get you on your feet.

    YOU NEED TO REGISTER ON GAMASUTRA.COM WORTH IT FOR THIS ARTICLE!http://www.gamasutra.com/features/20000215/lander_01.htm

    Part 1 of heckers game physics, which includes Euler integration:
    Physics, Part 1: The Next Frontier: http://www.d6.com/users/checker/pdfs/gdmphys1.pdf

    Hecker's main page and his other two parts, including sample game physics applications:
    http://www.d6.com/users/checker/dynamics.htm


    In the rare case that you need any more explanation, just post!
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer