Add a new body parameter "reflectivity" complementing albedos

new-stars-v2
Hleb Valoshka 2021-03-08 12:36:31 +02:00
parent 8e0efe3868
commit f16c355d11
5 changed files with 50 additions and 7 deletions

View File

@ -79,6 +79,7 @@ void Body::setDefaultProperties()
density = 0.0f;
bondAlbedo = 0.5f;
geomAlbedo = 0.5f;
reflectivity = 0.5f;
temperature = 0.0f;
tempDiscrepancy = 0.0f;
geometryOrientation = Quaternionf::Identity();
@ -347,6 +348,18 @@ void Body::setBondAlbedo(float _bondAlbedo)
}
float Body::getReflectivity() const
{
return reflectivity;
}
void Body::setReflectivity(float _reflectivity)
{
reflectivity = _reflectivity;
}
float Body::getTemperature(double time) const
{
if (temperature > 0)
@ -789,7 +802,7 @@ float Body::getLuminosity(float sunLuminosity,
// Compute the total energy hitting the planet
double incidentEnergy = satIrradiance * circleArea(radius * 1000);
double reflectedEnergy = incidentEnergy * geomAlbedo;
double reflectedEnergy = incidentEnergy * getReflectivity();
// Compute the luminosity (i.e. power relative to solar power)
return (float) (reflectedEnergy / astro::SOLAR_POWER);

View File

@ -233,12 +233,14 @@ class Body : public AstroObject
void setDensity(float);
// Albedo functions and temperature
/* [[deprecated]] */ float getAlbedo() const;
/* [[deprecated]] */ void setAlbedo(float);
[[deprecated]] float getAlbedo() const;
[[deprecated]] void setAlbedo(float);
float getGeomAlbedo() const;
void setGeomAlbedo(float);
float getBondAlbedo() const;
void setBondAlbedo(float);
float getReflectivity() const;
void setReflectivity(float);
float getTemperature(double t = 0) const;
void setTemperature(float);
float getTempDiscrepancy() const;
@ -392,6 +394,7 @@ class Body : public AstroObject
float density{ 0.0f };
float geomAlbedo{ 0.5f };
float bondAlbedo{ 0.5f };
float reflectivity{ 0.5f };
float temperature{ 0.0f };
float tempDiscrepancy{ 0.0f };

View File

@ -1513,7 +1513,7 @@ setupSecondaryLightSources(vector<SecondaryIlluminator>& secondaryIlluminators,
i.reflectedIrradiance += j.luminosity / ((float) (i.position_v - j.position).squaredNorm() * au2);
}
i.reflectedIrradiance *= i.body->getAlbedo();
i.reflectedIrradiance *= i.body->getReflectivity();
}
}

View File

@ -13,6 +13,8 @@
#include <config.h>
#include <cassert>
#include <limits>
#include <fmt/format.h>
#include <fmt/printf.h>
#include <celmath/mathlib.h>
#include <celutil/debug.h>
#include <celutil/gettext.h>
@ -796,7 +798,7 @@ static Body* CreateBody(const string& name,
{
// Relative URL, the base directory is the current one,
// not the main installation directory
const string p = path.string();
const string &p = path.string();
if (p[1] == ':')
// Absolute Windows path, file:/// is required
infoURL = "file:///" + p + "/" + infoURL;
@ -814,14 +816,36 @@ static Body* CreateBody(const string& name,
}
if (planetData->getNumber("GeomAlbedo", t))
body->setGeomAlbedo((float) t);
{
if (t > 0.0)
{
body->setGeomAlbedo((float) t);
// Set the BondAlbedo and Reflectivity values if it is <1, otherwise as 1.
if (t > 1.0)
t = 1.0;
body->setBondAlbedo((float) t);
body->setReflectivity((float) t);
}
else
{
fmt::print(cerr, _("Incorrect GeomAlbedo value: {}\n"), t);
}
}
if (planetData->getNumber("Reflectivity", t))
{
if (t >= 0.0 && t <= 1.0)
body->setReflectivity((float) t);
else
fmt::print(cerr, _("Incorrect Reflectivity value: {}\n"), t);
}
if (planetData->getNumber("BondAlbedo", t))
{
if (t >= 0.0 && t <= 1.0)
body->setBondAlbedo((float) t);
else
fmt::fprintf(cerr, "Incorrect BondAlbedo value: %lf\n", t);
fmt::print(cerr, _("Incorrect BondAlbedo value: {}\n"), t);
}
if (planetData->getNumber("Temperature", t))

View File

@ -626,6 +626,9 @@ static int object_getinfo(lua_State* l)
celx.setTable("name", body->getName().c_str());
celx.setTable("mass", (lua_Number)body->getMass());
celx.setTable("albedo", (lua_Number)body->getAlbedo());
celx.setTable("geomAlbedo", (lua_Number)body->getGeomAlbedo());
celx.setTable("bondAlbedo", (lua_Number)body->getBondAlbedo());
celx.setTable("reflectivity", (lua_Number)body->getReflectivity());
celx.setTable("infoURL", body->getInfoURL().c_str());
celx.setTable("radius", (lua_Number)body->getRadius());