# Aerodynamics for game

This topic is 613 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am making a flying simulator game. Therefor I need flight physics so I can actually fly.

So I learned that: L = 0.5 * rho * v ^ 2 * S * Cl

, where

L = Liftforce

rho = Air density

v = Speed

S = Wing area

and Cl = Lift coÃ«fficiÃ«nt

The problem is, I know each value except the Cl. Because the Cl is according to the wiki calculated using the same formula, meaning I have 2 values I don not know: Cl and L. I tried and read about the thin airfoil theory, but it is theoretically not entirely ment to work for these kind of simulations (lift coÃ«fficiÃ«nt keeps rising with a higher angle of attack unlike a realistic one). Help would be much appreciated!

Edited by cassis

##### Share on other sites

Then create your own lookup table and interpolate between angle values

i cant get a credit to that code but the idea is to interpolate between values:



//------------------------------------------------------------------------//
//  Given the attack angle and the status of the flaps, this function
//  returns the appropriate lift coefficient for a cambered airfoil with
//  a plain trailing edge flap (+/- 15 degree deflection).
//------------------------------------------------------------------------//
double	LiftCoefficient(double angle2, int flaps, double absflapangle, double maxdeflection)
{
double angle = angle2;
if (angle2 < 0) angle = -angle2;
//if (angle2 < -8) return 0.0;
if (angle2 > 24.0) return 0.0;
double clf0[9] 	= {-0.54, -0.2,  0.2, 0.57, 0.92, 1.21, 1.43,  1.4, 1.0};
double clfd[9] 	= {  0.0, 0.45, 0.85, 1.02, 1.39, 1.65, 1.75, 1.38, 1.17};
double clfu[9] 	= {-0.74, -0.4,  0.0, 0.27, 0.63, 0.92, 1.03,  1.1, 0.78};
double a[9]	 	= { -8.0, -4.0,  0.0,  4.0,  8.0, 12.0, 16.0, 20.0, 24.0};
double cl;
double cld0;
double deflectionP = absflapangle / maxdeflection;  //max 1.0 min 0.0
int	  i;

cl = 0;
for (i=0; i<8; i++)
{
if( (a[i] <= angle) && (a[i+1] > angle) )
{
switch(flaps)
{
case 0:// flaps not deflected
cl = clf0[i] - (a[i] - angle) * (clf0[i] - clf0[i+1]) / (a[i] - a[i+1]);
break;
case -1: // flaps down

cl = clfd[i] - (a[i] - angle) * (clfd[i] - clfd[i+1]) / (a[i] - a[i+1]);
cld0 = clf0[i] - (a[i] - angle) * (clf0[i] - clf0[i+1]) / (a[i] - a[i+1]);
cl = cld0 + PLUSORMINUS(angle2)*absnf(cl - cld0)*deflectionP;

break;
case 1: // flaps up
cl = clfu[i] - (a[i] - angle) * (clfu[i] - clfu[i+1]) / (a[i] - a[i+1]);
cld0 = clf0[i] - (a[i] - angle) * (clf0[i] - clf0[i+1]) / (a[i] - a[i+1]);
cl = cld0 + PLUSORMINUS(angle2)*absnf(cl - cld0)*deflectionP;
break;
}
break;
}
}
if (angle2 < 0)
return -cl;
else
return cl;
}

//------------------------------------------------------------------------//
//  Given the attack angle and the status of the flaps, this function
//  returns the appropriate drag coefficient for a cambered airfoil with
//  a plain trailing edge flap (+/- 15 degree deflection).
//------------------------------------------------------------------------//
double	DragCoefficient(double angle2, int flaps, double absflapangle, double maxdeflection)
{
double angle = angle2;
if (angle2 < 0) angle = -angle2;
if (angle2 > 24.0) return 2.0;
double cdf0[9] = {0.01, 0.0074, 0.004, 0.009, 0.013, 0.023, 0.05, 0.12, 0.21};
double cdfd[9] = {0.0065, 0.0043, 0.0055, 0.0153, 0.0221, 0.0391, 0.1, 0.195, 0.3};
double cdfu[9] = {0.005, 0.0043, 0.0055, 0.02601, 0.03757, 0.06647, 0.13, 0.18, 0.25};
double a[9]	 = {-8.0, -4.0, 0.0, 4.0, 8.0, 12.0, 16.0, 20.0, 24.0};
double cd;
double cdd0;
double deflectionP = absflapangle / maxdeflection;  //max 1.0 min 0.0
int	  i;

cd = 0.75;
for (i=0; i<8; i++)
{
if( (a[i] <= angle) && (a[i+1] > angle) )
{
switch(flaps)
{
case 0:// flaps not deflected
cd = cdf0[i] - (a[i] - angle) * (cdf0[i] - cdf0[i+1]) / (a[i] - a[i+1]);
break;
case -1: // flaps down
cd = cdfd[i] - (a[i] - angle) * (cdfd[i] - cdfd[i+1]) / (a[i] - a[i+1]);
cdd0 = cdf0[i] - (a[i] - angle) * (cdf0[i] - cdf0[i+1]) / (a[i] - a[i+1]);
cd = cdd0 + absnf(cd - cdd0)*deflectionP;
break;
case 1: // flaps up
cd = cdfu[i] - (a[i] - angle) * (cdfu[i] - cdfu[i+1]) / (a[i] - a[i+1]);
cdd0 = cdf0[i] - (a[i] - angle) * (cdf0[i] - cdf0[i+1]) / (a[i] - a[i+1]);
cd = cdd0 + absnf(cd - cdd0)*deflectionP;
break;
}
break;
}
}

return cd;

}


Edited by WiredCat

##### Share on other sites

Search for NACA profiles and you will find numerical and measured values for different angle of attack.

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633735
• Total Posts
3013597
×