Refactor astro.*/url.* to remove extern global variables
parent
41f6b95c72
commit
ddbe9ddd1d
|
@ -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 <config.h>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstdio>
|
||||
#include <utility>
|
||||
|
@ -19,33 +19,12 @@
|
|||
#include "univcoord.h"
|
||||
#include <celutil/gettext.h>
|
||||
#include <celmath/geomutil.h>
|
||||
#include <celmath/mathlib.h>
|
||||
|
||||
|
||||
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)
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
#ifndef _CELENGINE_ASTRO_H_
|
||||
#define _CELENGINE_ASTRO_H_
|
||||
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <celmath/mathlib.h>
|
||||
|
||||
#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
|
||||
|
|
|
@ -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 |
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue