Flight Simulator Guide


Introduction

This article is written in response to the many questions I see about making flight simulator projects on Scratch. This article introduces a commonly-used flight model and the physics behind it. I wish I knew this when I made my 2D flight simulator projects.

Units

Aviation is a mess of different units. Just to name a few... Altitude is in feet, distance is in nautical miles, or feet, or kilometres, depending on where it is used. Speed is in knots, air pressure can be either inches of mercury or hectopascals. Stick to SI units for the physics calculations. Use base units like seconds, metres, and kilograms. Speed should be metres/second. Acceleration should be metres/second/second. Force should be Newtons (which is kg*m/s/s). The maths is simpler this way. Feel free to display values to the user in any units you want.

Forces

The forces acting on an aircraft are often abstracted as thrust, weight, drag, and lift.

Thrust is the force that pushes the aircraft forward, produced by the engines. Weight is the force due to gravity and always pulls towards the earth. It is proportional to the aircraft's mass. Both drag and lift are related to each other. Drag is force parallel to the airflow. Lift is force perpendicular to the airflow.

It's up to you to decide how simple or complex you want your flight model as you could have just 4 vectors representing everything or you could split them up to model every single surface of the aircraft, although at that stage you might no longer be able to refer to drag and lift as abstract separate things as both are related to air pressure.

Microsoft Flight Simulator uses this:

The model I use in Flight Simulator 737 is actually pretty similar to this, although squished into 2 dimensions.

Main loop

Ideally you would be using a main loop to constantly run the physics along with the rest of the simulator. It needs time-keeping of some kind to ensure the physics runs at the correct speed (remember that the physics is measuring time in the base unit of seconds, not cycles of a loop). You could use delta-timing.

Physics tick

Every tick the following needs to happen...

1. All the forces currently acting on the aircraft are found.
2. The forces are added together to form a single resultant force and couple.
3. Acceleration to the aircraft is found from the resultant force (both positional and angular), taking into account the total mass of the object. (a=F/m, or acceleration=force/mass)
4. Acceleration changes the velocity (in pseudocode: velocity += acceleration/time_elapsed).
5. Velocity changes the position and angle (in pseudocode: position += velocity/time_elapsed).

You may want to refer to this project which uses the same steps but not for an aircraft: Free Body Physics Simulation

When a force is applied to a free object at a point that isn't at its center of mass, it will cause it to both translate and rotate. Translation is easy, it's identical to applying the same force at the center of mass. Rotation can be treated as a couple which are 2 vectors which make a pure rotational force ("torque"). They need to be separate so that the aircraft's translational and rotational components can be handled.

It is basically like this...

TranslationRotation
massangular mass (or "moment of inertia")
forcetorque (or "moment of force" or simply "moment")
accelerationangular acceleration
velocityangular velocity
displacement (or "position")angle (or "direction")

It can be confusing as there are a bunch of words which refer to the same concept. The above table is not exhaustive, there are many more!

Lift and Drag


Wikipedia article on lift


Wikipedia article on drag

Lift is the force acting on an object in an airflow (or fluid in general) that is perpendicular to it. Drag is parallel. They are both related to each other and as you can see from the above equations, they are the same (but with different variable names). Generally both are proportional to surface area, air density, velocity squared, and the dimensionless coefficient to account for the shape of the object.

With lift you want the surface area that is parallel to the airflow, and for drag you want the surface area that is perpendicular. You need to account for the fact that the aircraft is usually not travelling in the same direction as the airflow, for example it might be slightly pitched up. The wings themselves may be pitched too.

The coefficients need to be found in some way. It's more complicated because they need to account for the shape of the object and anything else not covered by the other parts of the formulas. It also varies depending on the airflow direction. You can find coefficients for airfoils online but the rest may have to be guessed or found experimentally using CFD or physical models in wind tunnels.

There are some other things to consider: