2015-12-29 23:20:20 +00:00
|
|
|
#include "CelestialBodyDefinition.h"
|
|
|
|
|
|
|
|
#include "Vector3.h"
|
|
|
|
#include "FloatNode.h"
|
|
|
|
|
2016-01-14 23:07:02 +00:00
|
|
|
static constexpr double WORLD_SCALING = 0.05;
|
|
|
|
static constexpr double EARTH_RADIUS = 6360.0;
|
|
|
|
static constexpr double EARTH_RADIUS_SCALED = EARTH_RADIUS / WORLD_SCALING;
|
|
|
|
|
2015-12-29 23:20:20 +00:00
|
|
|
CelestialBodyDefinition::CelestialBodyDefinition(DefinitionNode *parent, const string &name)
|
|
|
|
: DefinitionNode(parent, name) {
|
2016-01-14 23:07:02 +00:00
|
|
|
distance = new FloatNode(this, "distance");
|
2015-12-29 23:20:20 +00:00
|
|
|
phi = new FloatNode(this, "phi");
|
|
|
|
theta = new FloatNode(this, "theta");
|
|
|
|
radius = new FloatNode(this, "radius");
|
|
|
|
}
|
|
|
|
|
2016-01-14 23:07:02 +00:00
|
|
|
Vector3 CelestialBodyDefinition::getLocation(bool over_water) const {
|
|
|
|
VectorSpherical spc = {distance->getValue(), theta->getValue(), -phi->getValue()};
|
|
|
|
if (over_water) {
|
|
|
|
return Vector3(spc).sub(VECTOR_DOWN.scale(EARTH_RADIUS_SCALED));
|
|
|
|
} else {
|
|
|
|
return Vector3(spc);
|
|
|
|
}
|
2015-12-29 23:20:20 +00:00
|
|
|
}
|