live->Text(NumberString(sim.LiveCreatures().size()));
time->Text(TimeString(sim.Time()));
if (body) {
- clock->Text(TimeString(std::fmod(sim.Time(), body->RotationalPeriod())));
+ clock->Text(TimeString(std::fmod(sim.Time(), body->DayLength())) + " / " + TimeString(body->DayLength()));
} else {
clock->Text("no reference");
}
double GravitationalParameter() const noexcept;
double OrbitalPeriod() const noexcept;
double RotationalPeriod() const noexcept;
+ /// day length relative to parent, not neccessarily a sun
+ /// gives absolute value in seconds
+ /// returns sidereal day for parent-less bodies
+ double DayLength() const noexcept;
double SphereOfInfluence() const noexcept;
math::Sphere CollisionBounds() const noexcept { return math::Sphere{ glm::dvec3(0.0), Radius() }; }
}
}
+double Body::DayLength() const noexcept {
+ if (!HasParent()) {
+ return RotationalPeriod();
+ }
+ double year = OrbitalPeriod();
+ double sidereal = RotationalPeriod();
+ double grade = (angular < 0.0 ? -1.0 : 1.0) * (std::abs(axis_tilt.x) > PI * 0.5 ? -1.0 : 1.0);
+ return std::abs((year * sidereal) / ( year + (grade * sidereal)));
+}
+
double Body::SphereOfInfluence() const noexcept {
if (HasParent()) {
return orbit.SemiMajorAxis() * std::pow(Mass() / Parent().Mass(), 2.0 / 5.0);