X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fworld%2Fworld.cpp;h=525222f284b77c9c6bc57cd3a40df77849be5fd8;hp=1758c5e431ea4ebfb862dde58b4290408b5dd0e5;hb=1c385fe716fda927843cdbb83805bc467f517f92;hpb=7a0da3422f7c9b81ae529a7554f6d16e85f05e1d diff --git a/src/world/world.cpp b/src/world/world.cpp index 1758c5e..525222f 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -115,6 +115,16 @@ double Body::RotationalPeriod() const noexcept { } } +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);