Aircraft physics

Blitz3D Forums/Blitz3D Programming/Aircraft physics

poopla(Posted 2003) [#1]
I'm interrested in writting an fighter plane game. Anyone know of any articles on coding this sort of thing? Or at least the maths behind it?


LostCargo(Posted 2003) [#2]
the maths are prolly easier than car physics. im having mad trouble with the car stuff.

try gamedev.net. THey have some good articles


Bot Builder(Posted 2003) [#3]
how detailed you want it? like realistic, hard to fly, or basic arcade style? or a mix? You could do Rigid body stuff if you want the plane to react to collisions/ gunfire/ Large explosions. You could also do traditional physics, where basically every game loop it calculates velocities, moves the plane according to the velocities, moves the plane down a bit for gravity, and moves it in it's current flight direction multiplied by speed. You could also try to do some limited aerodynamics stuff by figuring out how much wing is in the wind, and applying air friction proportionally.


poopla(Posted 2003) [#4]
The only part I actually need to know is how to apply forces like lift, and thrust in a global fassion. I dont simply want to move the plane in local coords, since that would look wrong. Hope ya know what I mean.


podperson(Posted 2003) [#5]
The forces on a plane are (with VERY simplistic equations provided):

Lift: the faster the plane moves forward the more upward force (relative to the plane, not the ground -- a plane flying upside down experiences lift force downwards; this is why high performance aircraft roll when turning; they are better at climbing than turning, so they "climb" sideways). LIFT = LIFT_CONSTANT x F(ALTITUDE) x SPEED. F decreases with altitude.

Drag: the faster the plane moves forward the more force operates to slow is down. DRAG = DRAG_CONSTANT x F(ALTITUDE) x SPEED^2. F decreases with altitude.

(The plane's drag is likely to be a LOT greater if it's not essentially travelling forward -- you probably want a whole different DRAG_CONSTANT for that, and the DRAG should be proportional to SPEED^3, not SPEED^2.)

Gravity: the plane is always being pulled towards the ground by gravity. GRAVITY = 9.8 METRES PER SECOND or 9.8 NEWTONS PER KG.

Thrust: the more power you allocate to the engines the more force pushes the plane forward. THRUST = CONSTANT * THROTTLE * F(ALTITUDE) -- exactly how F behaves with respect to altitude depends on the engine. (An F-15's engines generate enough thrust at sea level to lift the plane straight up at 1G acceleration; i.e. its maximum thrust = 2x its weight. Most other fighters can't quite match this thrust to mass ratio.)

(In many jets, especially before fly-by-wire, increasing your throttle setting too fast could cause flame-out -- i.e. your engine would go out. Fly-by-wire planes constrain your plane's throttle changes to what are believed to be safe rates of change -- something some pilots resent. More modern engines can have their thrust increased more rapidly.)

You'll also need to know the plane's weight (and dimensions to handle rotation properly).

How do you work out these constants?

Well, no-one publishes all the raw data you need -- a lot of it is classified for state-of-the-art aircraft. If you're a military trained pilot you may have access to some of the raw data (and you probably know aeronautical engineering than I do).

First, an aircraft's top speed in level flight is obtained by turning the engine on maximum (probably with afterburners, if it has them) and diving to go over the maximum speed and then levelling out -- the plane slows down until its THRUST equals DRAG. It follows that you need to choose constants that give you the right maximum speed in level flight.

Second, most aircraft have a "military speed" of just under the speed of sound where they are flying with most of their (non-afterburner) throttle and have high fuel efficiency. You functions and constants need to reflect this.

All this is pretty simple...

Operating the control surfaces adds:
Yaw (e.g. the rudder)
Pitch (e.g. using the ailerons in concert)
Roll (e.g. operating the ailerons in opposite directions)

Planes will have angular momentum and inertia too -- turn a plane too fast and it will spin out of control.

Finally, there's a really complicated thing called an aircraft's envelope -- in essence a body of air moving along with the aircraft, which holds a great deal of its energy. (You see similar phenomena with cars and trucks on a highway -- a truck can carry along or buffet other vehicles inside its envelope of fast-moving air.) A lot of fancy aerial maneuvers involve dealing with this envelope -- in particular, if you can slow down without losing too much envelope energy you can regain speed or altitude much faster than if you dump your envelope.

It's probably easier to do a simplistic flight sim than a simplistic car or tank sim, but I think a realistic flight sim is probably just as complex if not more complex than a ground vehicle simulator (at least until your ground vehicles start moving fast enough to have serious ground effects, suffer turbulent drag, and so forth).


Eole(Posted 2003) [#6]
I Have a Link to the physic of the plane for game, but in my home (I m currentley at my works), I post it to night or write me a mail


Eole(Posted 2003) [#7]
You re very lucky, I find it on my computer in works. This is a link to a linear flight model for game

http://www.web-discovery.net/aerodynamics/ad001.asp


Rob(Posted 2003) [#8]
great link!


Jager(Posted 2003) [#9]
Didn't someone develop a WWII flightsim game in blitz a while ago? - 1946, I think it was called.

you might want to contact that person.


poopla(Posted 2003) [#10]
Chroma was working on one. I plan to take up something similar. If chroma is listening, I will work with you on art instead of coding something like this myself. Or anyone for that matter. I would rather do some art/design work for a change.


rsbrowndog(Posted 2003) [#11]
Dev,

I am considering making a World War One arcade-y flight sim if you are interested in working on that? I have my basic engine up and running already.

Let me know...

Cheers,

Ryan


MattG(Posted 2003) [#12]
would these be of any use ryan , there are quite old models and i am sure the poly stucture is crap ..but maybe good for testing. ?





rsbrowndog(Posted 2003) [#13]
Matt,

Those would be ace! (pun partially intended!)

Can you mail them to me? (Assuming the files aren't too big!)

Send 'em to:

ryan.mail@...

Thanks,

Ryan


Andy(Posted 2003) [#14]
sswift made an flightsim demo at one point, it may be in the codearchives.

Andy


rsbrowndog(Posted 2003) [#15]
Andy,

Yes, I have a copy of that.

However, not wishing to sound critical of sswift's work as I certainly couldn't have done it, there are several problems with the code and furthermore sswift removed it from the code archives some time ago so I assume he'd rather it wasn't used.

Besides I'd rather go for a more arcade-y style flight sim than something that is 100% accurate in physics. Whilst doing a bit of research I turned up the following facts on Sopwith Camels:

Noted for its tendency to kill inexperienced flyers, many pilots feared its vicious spin characteristics. Until sufficient speed was developed during takeoff, Camel pilots maintained full right rudder to counteract the torque the rotary engine. Failure to do so often resulted in a ground loop with the Camel crashing on its starboard wingtip.

I know some people would really relish the challenge of dealing with those sort of characteristics, but personally I'd rather be zooming around taking pot-shots at the Red Baron!

Cheers,

Ryan


c5ven(Posted 2003) [#16]
there are some good aero books out there which would explain the math and physics in ways you probably can't get from website links. i've found most online resources to be riddled with approximations for which there is no accounting.

doesn't make them "wrong" or "bad", just that without stating the fluid assumptions and relevant flight envelopes, modifying and/or understanding the online work and applying it to your project may be more trouble than just getting a book and learning the stuff. the math isn't that hard.

depending on how detailed you want to go, a/c physics is much more complicated than i typically see explained online by indy game developers. for example, i've never seen anyone account for something as simple as "induced drag" (tho it must be out there). and i doubt i'll ever see anyone touch aeroelasticity - something that goes a little beyond vehicle torsion in its effects on the system.


c5ven(Posted 2003) [#17]
was doing a little review and compressibility affects may be easily approximated prior to transonic speeds (from Mach = 0.3 -> 0.8). need to read up some more. also, i need to take some time to look over wave drag. if i recall correctly, drag coefficients stay pretty stable until you hit the transonic region - then they go through the roof.

don't know if i can resolve the wave drag stuff, never studied it before. but the compressibility affects would be useful, esp for fighter jet simulation.