@@ -56,40 +56,49 @@ negateIf(double& d, bool condition)
5656
5757
5858// Computes the luminosity of a perfectly reflective disc.
59- // It can be used as an upper bound for the irradiance of an object when culling invisible objects.
59+ // It is also used as an upper bound for the irradiance of an object when culling invisible objects.
6060// The function translates luminosity into luminosity of the same units
6161// (distanceFromSun and objRadius must also be in the same units).
62- static float reflectedLuminosity (float sunLuminosity,
63- float distanceFromSun,
64- float objRadius)
62+ float reflectedLuminosity (float sunLuminosity,
63+ float distanceFromSun,
64+ float objRadius)
6565{
6666 float lengthRatio = objRadius / distanceFromSun;
6767 return sunLuminosity * 0.25 * lengthRatio * lengthRatio;
6868}
6969
7070
71- // Return the absolute magnitude of a star with lum times solar absolute luminosity
71+ // The following notation rules apply in the functions below and in the code in general:
72+ // - Luminosity is implied in solar units (in SI, flux is measured in W)
73+ // - Irradiance is implied in vegan units (in SI, it is measured in W/m^2)
74+
75+ // Absolute magnitude is the logarithmic inverse of luminosity.
76+ // Apparent magnitude is the logarithmic inverse of irradiance.
77+
78+
79+ // Luminosity conversions:
80+
7281float
7382lumToAbsMag (float lum)
7483{
7584 return SOLAR_ABSMAG - std::log (lum) * LN_MAG;
7685}
7786
78- // Return the apparent magnitude of a star with lum times solar luminosity viewed at lyrs light years
7987float
8088lumToAppMag (float lum, float lyrs)
8189{
8290 return absToAppMag (lumToAbsMag (lum), lyrs);
8391}
8492
85- // Return the irradiance of a star in Vega units with lum times solar luminosity viewed at the distance in km
8693float
8794lumToIrradiance (float lum, float km)
8895{
8996 return lum * SOLAR_POWER / (math::sphereArea (km * 1000 ) * VEGAN_IRRADIANCE);
9097}
9198
9299
100+ // Magnitude conversions:
101+
93102float
94103absMagToLum (float mag)
95104{
@@ -108,14 +117,17 @@ absMagToIrradiance(float mag, float km)
108117 return lumToIrradiance (absMagToLum (mag), km);
109118}
110119
111- // Conversions between the magnitude system and irradiance in Vega units
120+
121+ // Logarithmic magnitude system <-> linear irradiance system in Vega units:
122+
112123float
113124magToIrradiance (float mag)
114125{
115126 return std::exp (- mag / LN_MAG);
116127 // slower solution:
117128 // return std::pow(10.0f, -0.4f * mag);
118129}
130+
119131float
120132irradianceToMag (float irradiance)
121133{
@@ -124,14 +136,17 @@ irradianceToMag(float irradiance)
124136 // return -2.5f * std::log10(irradiance);
125137}
126138
127- // Conversions between the faintest star magnitude system and exposure
139+
140+ // Faintest star magnitude system <-> exposure time:
141+
128142float
129143faintestMagToExposure (float faintestMag)
130144{
131145 return std::exp (faintestMag / LN_MAG) * IRRADIATION_LIMIT;
132146 // slower solution:
133147 // return std::pow(10.0f, 0.4f * faintestMag) * IRRADIATION_LIMIT;
134148}
149+
135150float
136151exposureToFaintestMag (float exposure)
137152{
@@ -140,6 +155,7 @@ exposureToFaintestMag(float exposure)
140155 // return 2.5f * std::log10(exposure / IRRADIATION_LIMIT);
141156}
142157
158+
143159void
144160decimalToDegMinSec (double angle, int & degrees, int & minutes, double & seconds)
145161{
0 commit comments