Wings Redux

The good parts first; the first working remote-controlled airplane in Mekside in the video below, followed by a more detailed discussion on How Stuff Works 🙂

To support experimenting with building helicopters and quadcopters, I designed a voxel block with some naive wing-like properties early on. It was extremely simple – basically the component of the relative wind velocity (that is, the reverse of the wings own velocity since there is no actual wind in the game so far) blowing parallel to the wing gave a lift force to the wing in the direction of the wing’s top surface. You might have seen the results in a previous video and this was enough to get propellers working, but when I started experimenting with building airplanes with wings and aerodynamic control surfaces, some bugs and extreme shortcomings came to light. To say the least. Actually, when I kicked on a free wing voxel lying on the ground, it flew up into the air and spiralled away by itself 🙂

This first simple model had two major shortcomings – it was mostly linear in lift versus wind speed, so the wings behaved unrealistically, and a more troublesome issue was that it didn’t care for the sign of the wing’s angle against the wind (I just took the magnitude of the projection of the wind vector against the wing normal).

Therefore it didn’t matter which way the wing pointed – as long as it had some part of it facing the wind, it always produced lift upwards (and never downwards no matter the angle). This made it impossible to implement control surfaces that are supposed to be able to steer an airplane as opposed to just giving it lift upwards (also see the pre-flight check in the video at the top of the page!).

So, I had to backtrack and learn what really makes a wing generate force from the air, and find a simple qualitative approximation of the infinitely advanced research materials on airfoil / wing shapes and performances available.

To start with, some definitions (slightly adapted for the use here):

  • Angle of attack: angle between the incoming relative wind and the wingplane
  • Airspeed (V): speed of the relative incoming wind (magnitude of the wind vector)
  • Dynamic pressure: the air pressure at the wing, given the speed of the air, proportional to V^2
  • Coefficient of Lift: relationship between dynamic pressure and the force generated on the wing, perpendicular to the wind (this is the lifting force we’re really interested in)
  • Coefficient of Drag: relationship between dynamic pressure and the force generated on the wing, parallel to the wind (opposing the movement of the wing, slowing it down)

Essentially, the Cl and Cd factors and how they depend on the angle of attack and wing configuration is the key to the aerodynamic properties.

For a completely non-aerodynamically shaped object like a flat plate, they are pretty intuitive.

The lift does not depend on any funky business, it is purely related to the deflection of the wind downwards (for example) giving a resulting net force upwards for the plate. At 45 degrees it reaches a maximum, after which I assume the air also starts being pushed upwards and at 90 degrees the air just hits it head on and spreads in any direction, evening out any force perpendicular to the wind.

The drag (force pushing the wing back in the direction of the wind) is simply related to the exposed area of the wing as seen from the incoming wind.

I found the graph below depicting these variations for a flat plate:

Coefficients of lift and drag for a simple non-aerodynamic flat plate (Image of unknown source, from www.becot.info)

They vary as could be expected. But look instead at the properties for a real airfoil and another curve appears (note that the angle of attack is not plotted for the entire 0 to 90 degree span, and that the vertical scale is different for the lift and drag coefficients):

Measured lift and drag coefficients as a function of the angle of attack for a certain airfoil shape. Image from Wikipedia.

The qualitative difference is that while the drag varies similarly (for the first 0-30 degree span at least), the lift now increases much more rapidly up until about 25 degrees, after which it falls back significantly. In fact, this region after the lift reaches maximum is called stall, and is dreaded by pilots as there is a sharp decrease in lift. So, why does the real airfoil generate lift in this way compared to the boring flat plate, and why is it much higher than the plate?

The video below show some aspects of the aerodynamics of a standard airfoil in a small wind tunnel.

An interesting phenomena to look for is that when you increase the angle of attack, the lift increases linearly with the angle up to a point where the flow-lines of the air separate from the top of the wing, abruptly reducing lift. This is called stalling the airfoil (and the entire plane if nothing is done to compensate). When the wing is beginning to stall, the drag keeps increasing, reducing the airspeed (if thrust can’t compensate) which in turn increases the angle of attack even further.

There is a common meme about how an airfoil produces lift, which is only half-true but often used. This is that due to the airfoil shape, air above it has to meet up with the air passing by below it, and since the curvature on the top is larger, the air has to go faster. Therefore, because fast moving air means lower pressure, the wing is pulled upwards.

The latter part about pressure is true, but it’s simply not true that the air has to speed up to meet up with the “same” air below, after the wing. See the old video below which uses “pulsed smoke” to show the timing of the air above and below the wing. The air on top does speed up, but it doesn’t meet up with the air below. Just to make a point on the amount of confusion there is about airfoils and lift, take a look at the YouTube comments on the video and the related discussion there 🙂

The real situation is that the lift from an airfoil involves a lot of factors depending on the exact shape and construction of the airfoil and properties of the medium (air) and I’m not sure there is a simple explanation, but qualitatively at least the aerodynamic lift depends on the flow-lines of air “attaching” to the wing’s surfaces. When the angle of attack increases beyond a certain threshold, the flow-lines separate from the wing and this is where lift starts to deteriorate and stalls the wing.

In either case, back to how to simulate this in the game! Basically the physics has access to the orientation of the wing element and its (relative) velocity in the air, and has to come up with a resulting aerodynamic force vector to apply.

The angle of attack is usually defined as the angle between the incoming relative wind and the chord line of the airfoil, which in turn is the line drawn from the front of the leading edge to the trailing edge. In the case of this game, the chord-line is in the plane normal to the wing voxel’s orientation, passing through the center.

A completely symmetric airfoil would obviously produce zero lift at zero angle of attack given this definition, but often the airfoil is asymmetric and the lift curve looks more like in the graph above, with a wing parallel to the wing still producing some lift.

The Coefficient of drag relates the dynamic pressure to the force acting on the wing opposing its movement, parallel to the relative airspeed. Higher drag means we need to spend more energy on the thrust to keep up the same speed. The Cd depends on the shape of the airfoil – a cubic wing-shape (like the normal voxels in this game) would really have a drag-coefficient more than 20 times greater than a good airfoil shape for example as in the graph above. So, obviously the Cd has to be unrealistically small in the game to produce any interesting physics.

Real scientists and aeronautical engineers test airfoils in wind tunnels and simulate them in advanced programs, but for a game like this I just wanted to implement some of the qualitative features of the airfoil, so that the player could build an airplane in the simulator with control surfaces working in the same way as on a real airplane – like on the image below.

Common definitions of pitch, yaw and roll for an airplane as well as the conventional control surfaces. Image from aerospaceweb.org as per the link above in the text.

At this point I wanted to show you the video of the results, but since I guess I would have lost many reads at this point in the wall of text, I put the video at the top of the page instead 😉

Basically, I had to trim the overall multipliers for the wing drag and lift curves, but the aerodynamic physics itself did actually work pretty good from the start when designed like this. Then, the challenge turned to engineering a stable airplane with proper control surfaces and a horizontal and vertical stabilizer and proper weight distribution, and then to actually fly it (this I learned a bit when I made the video).. the control voxel shown in the video only relays the keyboards up/down and left/right commands, which here controls the elevator (up/down) and ailerons (roll left/right), so there is no way to control the rudder (turning the plane’s yaw). Still, the bank angle adjustment due to the ailerons is enough to turn around the plane as can be seen.

The next step could be to actually sit in the cockpit when you fly, but I don’t have a good mechanism to strap the player in place and also the camera following the player does not tilt and roll depending on the G-forces acting on the player, so it’s very confusing to pilot the plane in-place right now (when the plane rolls, the player’s view stays “upright” instead of that you see the horizon tilting).

I’m also considering making a hangar ship that floats on the sea, and trying to take off and land on it 🙂

Finally, a video showing flight of the airplane from the first person view. It was too difficult to control that way, mainly due to the lack of a continuous ground-plane and other visual cues to show what is up or down and the airspeed etc. For example, just like in a real airplane I think (I’m not a pilot 🙂 it seems that if you make a too tight bank and turn the “load factor” (G-force..?) of the wings increases due to the turn and the lift can’t keep it up so it can slow down and stall.

Share Button