View Full Version : integrate/differentiate
03-05-2005, 10:08 AM
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?
03-05-2005, 10:22 AM
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.
03-05-2005, 10:29 AM
Something like objectname.integrate(s) ?
03-05-2005, 10:29 AM
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.
03-05-2005, 10:37 AM
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.
03-05-2005, 10:46 AM
Thanks FlySim, Ill take a look at both of those.
03-05-2005, 11:26 AM
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.
03-05-2005, 12:38 PM
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).
03-05-2005, 01:20 PM
There are a good set of articles at Gaffer's site about integration in game physics.
Why euler integration should be avoided
Fixing your timestep
Physics over the internet
Hope this helps,
03-05-2005, 02:08 PM
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.
03-06-2005, 03:17 PM
I couldn't get the site to work when posting either, I just thought my connection was messing up (i have a dodgy gateway box...)
Here are google cache links for those who are interested:
Main articles page (http://22.214.171.124/search?q=cache:9uO9nE8_YaoJ:www.gaffer.org:8080/articles/+gaffer+physics&hl=en&client=firefox-a)
Integration basics (http://126.96.36.199/search?q=cache:hxHRIX9HMrcJ:www.gaffer.org:8080/articles/Integration.html++site:www.gaffer.org+gaffer+physi cs&hl=en&client=firefox-a)
Fix your timestep (http://188.8.131.52/search?q=cache:NcALNsvoUFYJ:www.gaffer.org:8080/articles/Timestep.html++site:www.gaffer.org+gaffer+physics&hl=en&client=firefox-a)
Physics in 3d (http://184.108.40.206/search?q=cache:g7HhQnAcTIYJ:www.gaffer.org:8080/articles/Physics3D.html++site:www.gaffer.org+gaffer+physics&hl=en&client=firefox-a)
03-06-2005, 06:01 PM
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.
03-07-2005, 08:30 AM
Thanks Ibsta, the more info the better :)
03-07-2005, 02:58 PM
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:
In the rare case that you need any more explanation, just post!
Powered by vBulletin™ Version 4.1.3 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.