# How are physical model programmed in simulation games?

Being a Gran Turismo fan, I'm wondering what are the algorithms used to compute realistic behavior for friction, aerodynamism, velocity, curves etc.

Also, are there sophisticated ways to simulate fluid mechanics in flight simulation which are trivial enough for an amateur project ?

If I wanted to build a flight simulator, neglecting the parameters which have the littlest effect (temperature, pressure, humidity, friction of the air on the wings, gravitational center of the plane, etc), are there some kind of physical formulae or programming models I should know about ?

Or does physics engine feature such kind of simulation dedicated calculation ?

Physics has spent hundreds of years coming up with equations to model the real world; any college physics textbook is going to walk you through the basic mathematical solutions to everything you listed - even the stuff you want to ignore.

Sometimes, for efficiency or simplicity or stability, computer simulations ignore many of the factors. Sometimes they are short-circuited - we simulate gravity with a universal force, not by actually having a mass with the size of the earth; we simulate electricity at the level of current and resistance, not individual electrons in the wires. Sometimes we approximate because the closed-form of the integral is too expensive to compute; in this case, piecewise integration does well, as e.g. RK integration, common for Newtonian physics engines, but it'll solve any ordinary differential equation you want to give it.

Most of what you have named are degenerate cases of the Navier-Stokes equations:

They may be used to model the weather, ocean currents, water flow in a pipe, air flow around a wing, and motion of stars inside a galaxy. The Navier–Stokes equations in their full and simplified forms help with the design of aircraft and cars, the study of blood flow, the design of power stations, the analysis of pollution, and many other things.

Normally, you build a flight model (simulator) on top of a physics engine. But you can certainly experiment without a full featured physics engine.

To simulate physics in a game, you need to work with 3D vectors. Just take the equations of projectile motion you learned in school, and apply them each time step (frame). Treat your vehicle like a point object.

Here are some simple examples,

• friction - subtract a small value (0.01) from your velocity each frame until it hits zero.
• air drag - multiply your velocity by 0.97 each frame
• acceleration - vel = vel + accel * timestep
• velocity - x = x + vel * timestep

Note that position (x), velocity, and acceleration are all 3D vectors. Also, to apply steering to your air vehicle, you probably want to apply a 3D force vector each frame just like gravity (0,0,-9.8) is applied.

And lastly, you'll need a way to visualize your 3D motion each frame so that you can see if you like what you are doing. I recommend opengl. Take a peek at the samples that come with physx.

Later on, you can worry about vector fields to simulate complex forces, apply numerical integration methods to reduce error, and use a full blown physics engine to handle collisions and contact points.

• How about the trajectory of a plane depending of its geometry, since aerodynamics can be affected ? Two jet fighters might not feel the same to pilot even though they have almost the same weight and speed. When driving a car, since driving simulators allow to tweak suspensions, there also are equations about vertical balancing (not only longitudinal and horizontal). And tire grip can also vary with speed. I mean at some point all those equations cannot be integrated, they have to come with some scripted behaviors which introduces pre-calculated factors. Have you tried Gran Turismo 1 ? – jokoon Sep 23 '11 at 23:09