PDA

View Full Version : Simplest flight simulation maths



Ñuño Martínez
08-03-2010, 10:47 AM
I'm looking for flight simulation maths.

Looking in the forums I found a link to the Wikipedia's "Flight dynamics" article (http://en.wikipedia.org/wiki/Flight_dynamics), which is the most understandable explanation I've found in the whole Internet. I didn't read it all yet but seems to be a bit complex (actually I'm afraid of these integrals. I never understood them in School so I have no idea "how to integrate in Pascal". :baby:).

I'll not implement weather nor wind and I'll not care about weapons or fuel weight so I'm looking for something simple: just define static weight, current engine force, sustentation, air resistance and angles, pass them to the function(s) and get the new speed vector and plane angles. I know there's not a "magic function" to do all that but all I find is too complex and includes analysis about glider geometry, fuel dynamics (the fuel moves inside the depot), air temperature, etc. I'll do a game not a CAD to create the next NASA's shuttle. ::)

Some years ago I found a tutorial that explains the basics of car simulation and how to get some simple values (torque, steering, weight, road and wheel resistance and few more) and build some simple formulas to build a believable arcade simulation. Actually I did a simple car demo that skids. 8) I'm wondering if there's something like that for planes. Not only formulas but also a simple explanation that allows me to modify them if necessary.

de_jean_7777
09-03-2010, 08:33 AM
This is something I would also like to know, as I have a modest interest in airplanes and have always wanted to build an combat flight simulator game with simple physics. Something similar to Ace Combat (a playstation and xbox game). Same as Nuno, I've encountered problems understanding all the complex math and integrals.

As to how you integrate in Pascal, I think you don't. Integrals are used to reach the end formula. I extremely suck at these though I studied them at college.

Ñuño Martínez
09-03-2010, 09:40 AM
This is something I would also like to know, as I have a modest interest in airplanes and have always wanted to build an combat flight simulator game with simple physics. Something similar to Ace Combat (a playstation and xbox game). Same as Nuno, I've encountered problems understanding all the complex math and integrals.


If nobody answer we can try to do it by ourselves and write an article about "simple flying physics" in the PGD wiki or something, Ok? I think this is a very interesting topic. :yes:

At the moment I've found a flight simulator written for Liberty BASIC (http://libertybasic.conforums.com/index.cgi?board=software&action=display&num=1223267787) (similar than VisualBasic or Gambas as I can see). I haven't had time to study it yet but seems to implement some simple physics. Unfortunately it unrolled the matrix and vector operations.

Also we have the 2005 PGD 'Dogfight' Competition (http://www.pascalgamedevelopment.com/PGDLib/PGDAnnual2005) games. May be we can find something in those games. I'll download them when I go to home after job.

de_jean_7777
09-03-2010, 10:18 AM
Agreed. I'm working today, and tomorrow I have some things to do, but I'll take a crack at this a bit tonight and tomorrow night (working the night shift gives me plenty of free time, as there is not much to do related to my job).

grudzio
09-03-2010, 07:04 PM
You do not have to calculate integrals given in the Wikipedia article for a simple airplane simulation. Those integrals describe the moment of inertia (or to be more precise moment of inertia tensor) and have been calculated for many common shapes. So if you make some assumptions like uniform mass distribution and use simple plane geometry, there is no need to integrate at all.

The simplest way I would have start with is to describe plane as a set of point masses, each corresponding to different part of the plane. This way the calculations should be very easy. Momentum of inertia is an additive quantity, so all you have to do is calculate it for each point and then add it together.

The formula for momentum of inertia of a mass point is also simple:
mass multiplied by square of the distance to the rotation axis.

Here are some links
Moment of inertia (http://en.wikipedia.org/wiki/Moment_of_inertia)
List of moments of inertia (http://en.wikipedia.org/wiki/List_of_moments_of_inertia) for some common shapes.

Ñuño Martínez
10-03-2010, 09:57 AM
Thanks for the comments and the links, grudzio. Good to know we can do it without dealing with integrals. ;D

BTW I wrote a draft trying to put order in ideas about flying phyisics. I'm sure it has a lot of mistakes (including bad English redaction :S) but it can be a "start point". Read it and put here your apportation.

The link to the document: http://www.burdjia.com/personal/flight.txt

jdarling
10-03-2010, 05:45 PM
Nunuo, you have two mistakes (that are EASILY understandable) in your documentation:

Each wing has its own uplift vector but for simplify we can assume
that all wings have the same uplift vector.
And

Plane rotation:
...
I think we can have a "rotation factor" for each axis (roll, yaw and pitch)
which is how much the plane rotates per wind speed unit.


Ok, the 2nd one isn't a mistake, but your lack of understanding is caused by the 1st. You actually need the uplift for each of the 4 (in a typical aircraft) primary lift surfaces (call them wings) and single vertical lift surface (tail in most planes). NOTE: I'm talking VERY general/generic here. With this information you don't have to worry about rotation as your matrix will rotate itself based on the force calculations.

To modify the rotation you modify the lift vectors (ailerons, rudder values, etc) of the lift surfaces thus changing the forces on the body. This change in forces will provide you with a good approx of the rotational values.

On the down side, this approach leaves a lot to be desired when it comes to rendering :).

Wish I still had my code from when I was a kid, built an ASCII flight sim in PB3 LOL, but I know its long gone. Personally, I'd love to build a simple wireframe flight sim (the ASCII render version was cool, but almost impossible to understand), but time seems to be against me.

- Jeremy

PS: If you want to go insane you could always translate: http://www.aerojockey.com/software/ioccc/index.html

grudzio
10-03-2010, 09:15 PM
My two cents. I don't like the part about Weight. Near the surface of the Earth gravity force (weight) is equal to objects mass m multiplied by earth acceleration g.
FG=mg g=9.81 m/s2.
Of course you can set g to one if you wish.

Or, if we want a more realistic model, we can do:

M = (m * G) / h
I think here you meant this equation
FG = GMm/h2
But there is no need for using this formula.

A = U + R + M + F
You have to divide the left hand side by mass of the plane since on the right you have acceleration and on the left forces.

Sorry for not being more constructive, but I am much better at plain physics then aerodynamics.

Ñuño Martínez
11-03-2010, 11:07 AM
(...) You actually need the uplift for each of the 4 (in a typical aircraft) primary lift surfaces (call them wings) and single vertical lift surface (tail in most planes). NOTE: I'm talking VERY general/generic here. With this information you don't have to worry about rotation as your matrix will rotate itself based on the force calculations.

To modify the rotation you modify the lift vectors (ailerons, rudder values, etc) of the lift surfaces thus changing the forces on the body. This change in forces will provide you with a good approx of the rotational values.

I actually knew it but I consciously decided to remove it from the equation with the idea of make it easer for users. Let me explain.

Imagine a flight simulator that allows to add new planes just adding a 3D model description and a file that describe their "physics". If this plane actually exists an user may dive in Internet or a library to find the characteristics, but may be he/she wants to add a non-real plane (i.e. a ship from his/her favorite sci-fi world, or the legendary F-19 ;) ). Providing the "lift vectors" will make it hard to "calibrate" in any case but specially if plane "doesn't exists". My idea was that using "rotation factors" instead of actual forces it would be easer.

BTW I have no idea how to rotate a matrix applying a vector (but I know how to apply a transformation matrix to a vector ;) ).

[edit] I'm reading the IOCCC code you linked... Impressive! :o


Sorry for not being more constructive, but I am much better at plain physics then aerodynamics.

On the contrary, I find your comment very useful. If I have time I'll try to update the document this night.

But I don't understand your suggestion about "divide the left hand side by mass since on the right you have acceleration and on the left forces". Isn't mass in the M vector enough? And isn't force the same than (or equivalent to) acceleration? (You see I have very limited knowledge about physics. :baby:).

grudzio
11-03-2010, 08:14 PM
But I don't understand your suggestion about "divide the left hand side by mass since on the right you have acceleration and on the left forces". Isn't mass in the M vector enough? And isn't force the same than (or equivalent to) acceleration?

Oops, I have confused left side with a right side (it sometimes happens to me). What I meant is that on the left side of the equation you have an acceleration and on the right side sum of forces. Now, force and acceleration are related to each other - force equals acceleration multiplied by mass, but they are different quantities with different units. So to have an exact equation You need to insert mass into the equation, either by multiplying acceleration (lhs) or dividing forces (rhs).

Btw. If you have an equation and and units of the lhs and rhs are not the same, then the equation is wrong.