-
Notifications
You must be signed in to change notification settings - Fork 13
/
AtmosphereParams.cs
47 lines (44 loc) · 1.4 KB
/
AtmosphereParams.cs
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
// Author:
// Allis Tauri <[email protected]>
//
// Copyright (c) 2015 Allis Tauri
//
// This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/
// or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
namespace AT_Utils
{
public struct AtmosphereParams
{
public readonly CelestialBody Body;
public readonly double Alt;
public readonly double P;
public readonly double T;
public readonly double Rho;
public readonly double Mach1;
public AtmosphereParams(CelestialBody body, double altitude)
{
Alt = altitude;
Body = body;
if(Body.atmosphere)
{
P = Body.GetPressure(Alt);
T = Body.GetTemperature(Alt);
Rho = Body.GetDensity(P, T);
Mach1 = Body.GetSpeedOfSound(P, Rho);
}
else
{
P = 0;
T = -273;
Rho = 0;
Mach1 = 0;
}
}
public override string ToString()
{
return Utils.Format("{} Atmosphere Params at Alt: {} m\nP {}, T {}, Rho {}, Mach1 {} m/s",
Body.name, Alt, P, T, Rho, Mach1);
}
}
}