diff --git a/src/celengine/astro.cpp b/src/celengine/astro.cpp index 98f69a918..374ccce39 100644 --- a/src/celengine/astro.cpp +++ b/src/celengine/astro.cpp @@ -8,9 +8,9 @@ // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. -#include #include #include +#include #include #include #include @@ -19,33 +19,12 @@ #include "univcoord.h" #include #include -#include using namespace Eigen; using namespace std; using namespace celmath; -const double astro::speedOfLight = 299792.458; // km/s - -// epoch J2000: 12 UT on 1 Jan 2000 -const double astro::J2000 = 2451545.0; - -const double astro::G = 6.672e-11; // N m^2 / kg^2 - -const double astro::SolarMass = 1.989e30; -const double astro::EarthMass = 5.972e24; -const double astro::LunarMass = 7.346e22; -const double astro::JupiterMass = 1.898e27; - -const double astro::SOLAR_IRRADIANCE = 1367.6; // Watts / m^2 -const double astro::SOLAR_POWER = 3.8462e26; // Watts - -// Angle between J2000 mean equator and the ecliptic plane. -// 23 deg 26' 21".448 (Seidelmann, _Explanatory Supplement to the -// Astronomical Almanac_ (1992), eqn 3.222-1. -const double astro::J2000Obliquity = degToRad(23.4392911); - static const Quaterniond ECLIPTIC_TO_EQUATORIAL_ROTATION = XRotation(-astro::J2000Obliquity); static const Matrix3d ECLIPTIC_TO_EQUATORIAL_MATRIX = ECLIPTIC_TO_EQUATORIAL_ROTATION.toRotationMatrix(); @@ -347,30 +326,21 @@ Vector3d astro::equatorialToGalactic(const Vector3d& v) -astro::Date::Date() +astro::Date::Date() : Date(0, 0, 0) { - year = 0; - month = 0; - day = 0; - hour = 0; - minute = 0; - seconds = 0.0; - wday = 0; - utc_offset = 0; - tzname = "UTC"; } -astro::Date::Date(int Y, int M, int D) +astro::Date::Date(int Y, int M, int D) : + year(Y), + month(M), + day(D), + hour(0), + minute(0), + seconds(0.0), + wday(0), + utc_offset(0), + tzname("UTC") { - year = Y; - month = M; - day = D; - hour = 0; - minute = 0; - seconds = 0.0; - wday = 0; - utc_offset = 0; - tzname = "UTC"; } astro::Date::Date(double jd) diff --git a/src/celengine/astro.h b/src/celengine/astro.h index f4660d26c..fc5ed6a65 100644 --- a/src/celengine/astro.h +++ b/src/celengine/astro.h @@ -11,11 +11,10 @@ #ifndef _CELENGINE_ASTRO_H_ #define _CELENGINE_ASTRO_H_ -#include #include -#include +#include #include -#include +#include #define SOLAR_ABSMAG 4.83f #define LN_MAG 1.085736 @@ -223,18 +222,22 @@ namespace astro double& trueAnomaly, double& eccentricAnomaly); double meanEclipticObliquity(double jd); - extern const double J2000; - extern const double speedOfLight; // km/s - extern const double G; // gravitational constant - extern const double SolarMass; - extern const double EarthMass; - extern const double LunarMass; - extern const double JupiterMass; + // epoch J2000: 12 UT on 1 Jan 2000 + constexpr const double J2000 = 2451545.0; + constexpr const double speedOfLight = 299792.458; // km/s + constexpr const double G = 6.672e-11; // N m^2 / kg^2; gravitational constant + constexpr const double SolarMass = 1.989e30; + constexpr const double EarthMass = 5.972e24; + constexpr const double LunarMass = 7.346e22; + constexpr const double JupiterMass = 1.898e27; - extern const double J2000Obliquity; + // Angle between J2000 mean equator and the ecliptic plane. + // 23 deg 26' 21".448 (Seidelmann, _Explanatory Supplement to the + // Astronomical Almanac_ (1992), eqn 3.222-1. + constexpr const double J2000Obliquity = 23.4392911_deg; - extern const double SOLAR_IRRADIANCE; - extern const double SOLAR_POWER; // in Watts + constexpr const double SOLAR_IRRADIANCE = 1367.6; // Watts / m^2 + constexpr const double SOLAR_POWER = 3.8462e26; // in Watts } // Convert a date structure to a Julian date diff --git a/src/celestia/url.cpp b/src/celestia/url.cpp index cdf3945fe..409894668 100644 --- a/src/celestia/url.cpp +++ b/src/celestia/url.cpp @@ -30,7 +30,6 @@ using namespace Eigen; using namespace std; using namespace celmath; -const unsigned int Url::CurrentVersion = 4; constexpr const uint64_t NewRenderFlags = Renderer::ShowDwarfPlanets | Renderer::ShowMoons | Renderer::ShowMinorMoons | diff --git a/src/celestia/url.h b/src/celestia/url.h index 526f752ec..9da33334f 100644 --- a/src/celestia/url.h +++ b/src/celestia/url.h @@ -72,7 +72,7 @@ public: std::string getName() const; bool goTo(); - static const unsigned int CurrentVersion; + constexpr const static unsigned int CurrentVersion = 4; static std::string decodeString(const std::string& str); static std::string encodeString(const std::string& str);