# What is the purpose of integration in physics engines?

All online resources seem to assume that you know what this means and/or state that this is related to object movement in some way.

How does this differ than just position.x++ and position.y++ and how does integration allow us to simulate movement? (calculus integration?)

I understand there are a few different methods, namely Euler explicit, RK4, and Verlet. These methods I read are meant to solve ODE's, what are we solving for when we solve these equations?

The Euler method as applied to games is pretty much just the naive Position + (Velocity * TimeSinceLastUpdate) formula I think you were getting at. The other methods (without getting into the calc too much) are just more accurate ways of estimating velocity and position based on multiple simultaneous forces, like friction, gravity, air density, etc. It's probably most noticeable in accurate flight simulators, where the aircraft actually needs to behave according to different forces across the wings' control surfaces.

So, referring back to the Euler method, an integral is essentially a repeated sum.

Position += Velocity * TimeSinceLastUpdate; // for every frame!

Which in graph form might look like where the width of each rectangle is the time, and the height is the velocity. Obviously we can get better estimations the more rectangles we use, but that means doing more processing each frame. If we can do the job of several integrations in one step by, say, using sloped rectangles, then our physics will be just that much more accurate.

Of course, this isn't always necessary - accurate isn't always interesting.

• Great! so it is actual integration that they're talking about. I suppose if you make delta time (dt) smaller, the rectangles get thinner and you get more accurate simulations? How is this related to differential equations, because we're estimating the actual function of velocity? Feb 10 '15 at 17:16
• Yes - the differential being the relationship between acceleration, velocity, and position. As I wrote, making dt smaller isn't necessarily a good idea. There are methods (RK4, Verlet) that provide better approximations in fewer steps.
– jzx
Feb 10 '15 at 18:40