|
1 | 1 | // astro.h |
2 | 2 | // |
3 | | -// Copyright (C) 2001-2009, the Celestia Development Team |
| 3 | +// Copyright (C) 2001-present, the Celestia Development Team |
4 | 4 | // Original version by Chris Laurel <[email protected]> |
5 | 5 | // |
6 | 6 | // This program is free software; you can redistribute it and/or |
|
25 | 25 | namespace celestia::astro |
26 | 26 | { |
27 | 27 |
|
28 | | -constexpr inline float SOLAR_ABSMAG = 4.83f; |
29 | | -constexpr inline float LN_MAG = 1.0857362f; // 5/ln(100) |
| 28 | +// Angle between J2000 mean equator and the ecliptic plane: 23 deg 26' 21".448 |
| 29 | +// Seidelmann, Explanatory Supplement to the Astronomical Almanac (1992), eqn 3.222-1 |
| 30 | +constexpr inline double J2000Obliquity = 23.4392911_deg; |
| 31 | + |
| 32 | +// CODATA 2022 |
| 33 | +constexpr inline double speedOfLight = 299792.458; // km/s |
| 34 | +constexpr inline double G = 6.67430e-11; // N m^2 / kg^2 |
| 35 | + |
| 36 | +// IAU 2015 Resolution B3 + CODATA 2022 |
| 37 | +constexpr inline double SolarMass = 1.3271244e20 / G; // kg |
| 38 | +constexpr inline double EarthMass = 3.986004e14 / G; // kg |
| 39 | +constexpr inline double LunarMass = 7.346e22; // kg |
| 40 | +constexpr inline double JupiterMass = 1.2668653e17 / G; // kg |
| 41 | + |
| 42 | +// https://mips.as.arizona.edu/~cnaw/sun.html for Johnson V filter |
| 43 | +constexpr inline float SOLAR_ABSMAG = 4.81f; |
| 44 | + |
| 45 | +// IAU 2015 Resolution B3 |
| 46 | +constexpr inline float SOLAR_IRRADIANCE = 1361.0f; // W / m^2 |
| 47 | +constexpr inline float SOLAR_POWER = 3.828e26f; // W |
| 48 | + |
| 49 | +// Bessel (1979) for Johnson V filter |
| 50 | +constexpr inline float VEGAN_IRRADIANCE = 3.640e-11f; // W / m^2 |
| 51 | + |
| 52 | +// Auxiliary magnitude conversion factor |
| 53 | +constexpr inline float LN_MAG = 1.0857362f; // 5/ln(100) |
| 54 | + |
| 55 | +// Lowest screen brightness of a point to render |
| 56 | +constexpr inline float LOWEST_IRRADIATION = 1.0f / 255.0f; |
| 57 | +// = 1.0f / (255.0f * 12.92f); after implementing gamma correction |
30 | 58 |
|
31 | 59 | namespace detail |
32 | 60 | { |
@@ -60,19 +88,27 @@ constexpr inline double SECONDS_PER_DEG = 3600.0; |
60 | 88 | constexpr inline double DEG_PER_HRA = 15.0; |
61 | 89 |
|
62 | 90 | template<typename T> |
63 | | -constexpr inline auto EARTH_RADIUS = detail::enable_if_fp<T>(6378.14L); |
| 91 | +constexpr inline auto EARTH_RADIUS = detail::enable_if_fp<T>(6378.1L); // IAU 2015 Resolution B3 |
64 | 92 |
|
65 | 93 | template<typename T> |
66 | | -constexpr inline auto JUPITER_RADIUS = detail::enable_if_fp<T>(71492.0L); |
| 94 | +constexpr inline auto JUPITER_RADIUS = detail::enable_if_fp<T>(71492.0L); // IAU 2015 Resolution B3 |
67 | 95 |
|
68 | 96 | template<typename T> |
69 | | -constexpr inline auto SOLAR_RADIUS = detail::enable_if_fp<T>(696000.0L); |
| 97 | +constexpr inline auto SOLAR_RADIUS = detail::enable_if_fp<T>(695700.0L); // IAU 2015 Resolution B3 |
| 98 | + |
| 99 | +float reflectedLuminosity(float sunLuminosity, float distanceFromSun, float objRadius); |
70 | 100 |
|
71 | 101 | // Magnitude conversions |
72 | 102 | float lumToAbsMag(float lum); |
73 | 103 | float lumToAppMag(float lum, float lyrs); |
| 104 | +float lumToIrradiance(float lum, float km); |
74 | 105 | float absMagToLum(float mag); |
75 | 106 | float appMagToLum(float mag, float lyrs); |
| 107 | +float absMagToIrradiance(float mag, float lyrs); |
| 108 | +float magToIrradiance(float mag); |
| 109 | +float irradianceToMag(float irradiance); |
| 110 | +float faintestMagToExposure(float faintestMag); |
| 111 | +float exposureToFaintestMag(float exposure); |
76 | 112 |
|
77 | 113 | template<class T> |
78 | 114 | CELESTIA_CMATH_CONSTEXPR T |
@@ -175,33 +211,19 @@ void anomaly(double meanAnomaly, double eccentricity, |
175 | 211 | double& trueAnomaly, double& eccentricAnomaly); |
176 | 212 | double meanEclipticObliquity(double jd); |
177 | 213 |
|
178 | | -constexpr inline double speedOfLight = 299792.458; // km/s |
179 | | -constexpr inline double G = 6.672e-11; // N m^2 / kg^2; gravitational constant |
180 | | -constexpr inline double SolarMass = 1.989e30; |
181 | | -constexpr inline double EarthMass = 5.972e24; |
182 | | -constexpr inline double LunarMass = 7.346e22; |
183 | | -constexpr inline double JupiterMass = 1.898e27; |
184 | | - |
185 | | -// Angle between J2000 mean equator and the ecliptic plane. |
186 | | -// 23 deg 26' 21".448 (Seidelmann, _Explanatory Supplement to the |
187 | | -// Astronomical Almanac_ (1992), eqn 3.222-1. |
188 | | -constexpr inline double J2000Obliquity = 23.4392911_deg; |
189 | | - |
190 | | -constexpr inline double SOLAR_IRRADIANCE = 1367.6; // Watts / m^2 |
191 | | -constexpr inline double SOLAR_POWER = 3.8462e26; // in Watts |
192 | 214 |
|
193 | 215 | namespace literals |
194 | 216 | { |
195 | 217 |
|
196 | | -constexpr long double operator ""_au(long double au) |
| 218 | +constexpr long double operator "" _au (long double au) |
197 | 219 | { |
198 | 220 | return AUtoKilometers(au); |
199 | 221 | } |
200 | | -constexpr long double operator ""_ly(long double ly) |
| 222 | +constexpr long double operator "" _ly (long double ly) |
201 | 223 | { |
202 | 224 | return lightYearsToKilometers(ly); |
203 | 225 | } |
204 | | -constexpr long double operator ""_c(long double n) |
| 226 | +constexpr long double operator "" _c (long double n) |
205 | 227 | { |
206 | 228 | return speedOfLight * n; |
207 | 229 | } |
|
0 commit comments