Skip to content

Commit

Permalink
Allow (debug) output for planetary rectangular positions
Browse files Browse the repository at this point in the history
  • Loading branch information
gzotti committed May 18, 2018
1 parent c1f2ed1 commit 58a53e0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
17 changes: 11 additions & 6 deletions src/core/modules/Planet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Planet.hpp"
#include "Orbit.hpp"
#include "planetsephems/precession.h"
#include "planetsephems/EphemWrapper.hpp"
#include "StelObserver.hpp"
#include "StelProjector.hpp"
#include "sidereal_time.h"
Expand Down Expand Up @@ -442,16 +443,20 @@ QString Planet::getInfoString(const StelCore* core, const InfoStringGroup& flags
// Debug help.
//oss << "Apparent Magnitude Algorithm: " << getApparentMagnitudeAlgorithmString() << " " << vMagAlgorithm << "<br>";

#ifndef NDEBUG
// GZ This is mostly for debugging. Maybe also useful for letting people use our results to cross-check theirs, but we should not act as reference, currently...
// TODO: maybe separate this out into:
//if (flags&EclipticCoordXYZ)
// For now: add to EclipticCoordJ2000 group
//if (flags&EclipticCoordJ2000)
//{
// Vec3d eclPos=(englishName=="Sun" ? GETSTELMODULE(SolarSystem)->getLightTimeSunPosition() : eclipticPos);
// oss << q_("Ecliptical XYZ (VSOP87A): %1/%2/%3").arg(QString::number(eclPos[0], 'f', 7), QString::number(eclPos[1], 'f', 7), QString::number(eclPos[2], 'f', 7)) << "<br>";
//}

if (flags&EclipticCoordJ2000)
{
Vec3d eclPos=(englishName=="Sun" ? GETSTELMODULE(SolarSystem)->getLightTimeSunPosition() : eclipticPos);
QString algoName("VSOP87");
if (EphemWrapper::use_de431(core->getJDE())) algoName="DE431";
if (EphemWrapper::use_de430(core->getJDE())) algoName="DE430";
oss << q_("Ecliptical XYZ (%1): %2/%3/%4").arg(algoName).arg(QString::number(eclPos[0], 'f', 7), QString::number(eclPos[1], 'f', 7), QString::number(eclPos[2], 'f', 7)) << "<br>";
}
#endif
if (flags&Distance)
{
double hdistanceAu = getHeliocentricEclipticPos().length();
Expand Down
26 changes: 12 additions & 14 deletions src/core/planetsephems/EphemWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,15 @@ bool EphemWrapper::jd_fits_de431(const double jd)

bool EphemWrapper::jd_fits_de430(const double jd)
{
//return !(jd < 2287184.5 || jd > 2688974.5);
//return !(jd < 2287184.5 || jd > 2688976.5);
return ((jd > 2287184.5) && (jd < 2688976.5));
}

bool use_de430(const double jd)
bool EphemWrapper::use_de430(const double jd)
{
return StelApp::getInstance().getCore()->de430IsActive() && EphemWrapper::jd_fits_de430(jd);
}

bool use_de431(const double jd)
bool EphemWrapper::use_de431(const double jd)
{
return StelApp::getInstance().getCore()->de431IsActive() && EphemWrapper::jd_fits_de431(jd);
}
Expand All @@ -105,11 +103,11 @@ void get_planet_helio_coordsv(const double jd, double xyz[3], double xyzdot[3],
return;
}

if(use_de430(jd))
if(EphemWrapper::use_de430(jd))
{
deOk=GetDe430Coor(jd, planet_id + 1, xyz6);
}
else if(use_de431(jd))
else if(EphemWrapper::use_de431(jd))
{
deOk=GetDe431Coor(jd, planet_id + 1, xyz6);
}
Expand All @@ -134,11 +132,11 @@ void get_planet_helio_osculating_coordsv(double jd0, double jd, double xyz[3], d
return;
}

if(use_de430(jd))
if(EphemWrapper::use_de430(jd))
{
deOk=GetDe430Coor(jd, planet_id + 1, xyz6);
}
else if(use_de431(jd))
else if(EphemWrapper::use_de431(jd))
{
deOk=GetDe431Coor(jd, planet_id + 1, xyz6);
}
Expand Down Expand Up @@ -166,11 +164,11 @@ void get_pluto_helio_coordsv(double jd,double xyz[3], double xyzdot[3], void* un
return;
}

if(use_de430(jd))
if(EphemWrapper::use_de430(jd))
{
deOk=GetDe430Coor(jd, EPHEM_JPL_PLUTO_ID, xyz6);
}
else if(use_de431(jd))
else if(EphemWrapper::use_de431(jd))
{
deOk=GetDe431Coor(jd, EPHEM_JPL_PLUTO_ID, xyz6);
}
Expand Down Expand Up @@ -218,11 +216,11 @@ void get_earth_helio_coordsv(const double jd,double xyz[3], double xyzdot[3], vo
return;
}

if(use_de430(jd))
if(EphemWrapper::use_de430(jd))
{
deOk=GetDe430Coor(jd, EPHEM_JPL_EARTH_ID, xyz6);
}
else if(use_de431(jd))
else if(EphemWrapper::use_de431(jd))
{
deOk=GetDe431Coor(jd, EPHEM_JPL_EARTH_ID, xyz6);
}
Expand Down Expand Up @@ -325,9 +323,9 @@ void get_lunar_parent_coordsv(double jde, double xyz[3], double xyzdot[3], void*
Q_UNUSED(unused);
double xyz6[6];
bool deOk=false;
if(use_de430(jde))
if(EphemWrapper::use_de430(jde))
deOk=GetDe430Coor(jde, EPHEM_JPL_MOON_ID, xyz6, EPHEM_JPL_EARTH_ID);
else if(use_de431(jde))
else if(EphemWrapper::use_de431(jde))
deOk=GetDe431Coor(jde, EPHEM_JPL_MOON_ID, xyz6, EPHEM_JPL_EARTH_ID);

if (deOk)
Expand Down
2 changes: 2 additions & 0 deletions src/core/planetsephems/EphemWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class EphemWrapper{
static void init_de431(const char* filepath);
static bool jd_fits_de430(const double jd);
static bool jd_fits_de431(const double jd);
static bool use_de430(const double jd);
static bool use_de431(const double jd);
};

// These functions have an unused void pointer to be compatible to PosFuncType in SolarSystem and Planet classes.
Expand Down

0 comments on commit 58a53e0

Please sign in to comment.