blob: 114b9e0f927da6304cdc6d2cd8f414287f0702d1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
* Copyright © 2014 Keith Packard <keithp@keithp.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "ao-fakeflight.h"
/* Density of dry air in kg/m³ for a given pressure and temperature. */
double
density_air(double pressure, /* Pa */
double temperature) /* °C */
{
return pressure / (GAS_CONSTANT * (temperature + 273.15));
}
/* Area of a circle */
double
area_circle(double diameter)
{
double radius = diameter / 2;
return M_PI * radius * radius;
}
/* Force due to drag (N) */
double
force_drag(double speed, /* m/s */
double rho, /* kg/m³ */
double cd, /* unitless */
double area) /* m² */
{
return 0.5 * rho * (speed * speed) * cd * area;
}
/* Force due to gravity (N) */
double
force_gravity(double mass, /* kg */
double altitude) /* m */
{
double distance = altitude + EARTH_RADIUS;
return GRAVITATIONAL_CONSTANT * EARTH_MASS * mass / (distance * distance);
}
|