From 1e53bedca5afda25517dabcfa298f13acab0d4bd Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 8 Jul 2000 03:06:45 +0000 Subject: [PATCH] Minor tidying up of interface. --- simgear/ephemeris/celestialBody.cxx | 10 +++++----- simgear/ephemeris/celestialBody.hxx | 26 +++++++++++++------------- simgear/ephemeris/ephemeris.cxx | 26 +++++++++++++------------- simgear/ephemeris/ephemeris.hxx | 17 +++++++++-------- simgear/ephemeris/jupiter.cxx | 12 ++++++------ simgear/ephemeris/jupiter.hxx | 6 ++---- simgear/ephemeris/mars.cxx | 12 ++++++------ simgear/ephemeris/mars.hxx | 6 ++---- simgear/ephemeris/mercury.cxx | 12 ++++++------ simgear/ephemeris/mercury.hxx | 6 ++---- simgear/ephemeris/moon.cxx | 16 ++++++++-------- simgear/ephemeris/moon.hxx | 5 ++--- simgear/ephemeris/neptune.cxx | 12 ++++++------ simgear/ephemeris/neptune.hxx | 6 ++---- simgear/ephemeris/pluto.hxx | 3 +-- simgear/ephemeris/saturn.cxx | 14 +++++++------- simgear/ephemeris/saturn.hxx | 6 ++---- simgear/ephemeris/star.cxx | 14 +++++++------- simgear/ephemeris/star.hxx | 4 ++-- simgear/ephemeris/stars.cxx | 12 ++++++------ simgear/ephemeris/stars.hxx | 16 ++++++++-------- simgear/ephemeris/uranus.cxx | 12 ++++++------ simgear/ephemeris/uranus.hxx | 6 ++---- simgear/ephemeris/venus.cxx | 12 ++++++------ simgear/ephemeris/venus.hxx | 6 ++---- 25 files changed, 131 insertions(+), 146 deletions(-) diff --git a/simgear/ephemeris/celestialBody.cxx b/simgear/ephemeris/celestialBody.cxx index 4762f20e..de1bfc46 100644 --- a/simgear/ephemeris/celestialBody.cxx +++ b/simgear/ephemeris/celestialBody.cxx @@ -34,7 +34,7 @@ /************************************************************************** - * void CelestialBody::updatePosition(SGTime *t, Star *ourSun) + * void CelestialBody::updatePosition(double mjd, Star *ourSun) * * Basically, this member function provides a general interface for * calculating the right ascension and declinaion. This function is @@ -45,20 +45,20 @@ * position is calculated an a slightly different manner. * * arguments: - * SGTime t: provides the current time. + * double mjd: provides the modified julian date. * Star *ourSun: the sun's position is needed to convert heliocentric * coordinates into geocentric coordinates. * * return value: none * *************************************************************************/ -void CelestialBody::updatePosition(SGTime *t, Star *ourSun) +void CelestialBody::updatePosition(double mjd, Star *ourSun) { double eccAnom, v, ecl, actTime, xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze; - updateOrbElements(t); - actTime = fgCalcActTime(t); + updateOrbElements(mjd); + actTime = fgCalcActTime(mjd); // calcualate the angle bewteen ecliptic and equatorial coordinate system ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 *actTime); diff --git a/simgear/ephemeris/celestialBody.hxx b/simgear/ephemeris/celestialBody.hxx index 96f67787..40c8a116 100644 --- a/simgear/ephemeris/celestialBody.hxx +++ b/simgear/ephemeris/celestialBody.hxx @@ -61,8 +61,8 @@ protected: // make the data protected, in order to give the double lonEcl, latEcl; double fgCalcEccAnom(double M, double e); - double fgCalcActTime(SGTime *t); - void updateOrbElements(SGTime *t); + double fgCalcActTime(double mjd); + void updateOrbElements(double mjd); public: CelestialBody(double Nf, double Ns, @@ -70,7 +70,7 @@ public: double wf, double ws, double af, double as, double ef, double es, - double Mf, double Ms, SGTime *t); + double Mf, double Ms, double mjd); CelestialBody(double Nf, double Ns, double If, double Is, double wf, double ws, @@ -84,7 +84,7 @@ public: double getMagnitude(); double getLon(); double getLat(); - void updatePosition(SGTime *t, Star *ourSun); + void updatePosition(double mjd, Star *ourSun); }; /***************************************************************************** @@ -112,7 +112,7 @@ inline CelestialBody::CelestialBody(double Nf, double Ns, double wf, double ws, double af, double as, double ef, double es, - double Mf, double Ms, SGTime *t) + double Mf, double Ms, double mjd) { NFirst = Nf; NSec = Ns; iFirst = If; iSec = Is; @@ -120,7 +120,7 @@ inline CelestialBody::CelestialBody(double Nf, double Ns, aFirst = af; aSec = as; eFirst = ef; eSec = es; MFirst = Mf; MSec = Ms; - updateOrbElements(t); + updateOrbElements(mjd); }; inline CelestialBody::CelestialBody(double Nf, double Ns, @@ -139,17 +139,17 @@ inline CelestialBody::CelestialBody(double Nf, double Ns, }; /**************************************************************************** - * inline void CelestialBody::updateOrbElements(SGTime *t) + * inline void CelestialBody::updateOrbElements(double mjd) * given the current time, this private member calculates the actual * orbital elements * - * Arguments: SGTime *t: the current time: + * Arguments: double mjd: the current modified julian date: * * return value: none ***************************************************************************/ -inline void CelestialBody::updateOrbElements(SGTime *t) +inline void CelestialBody::updateOrbElements(double mjd) { - double actTime = fgCalcActTime(t); + double actTime = fgCalcActTime(mjd); M = DEG_TO_RAD * (MFirst + (MSec * actTime)); w = DEG_TO_RAD * (wFirst + (wSec * actTime)); N = DEG_TO_RAD * (NFirst + (NSec * actTime)); @@ -158,7 +158,7 @@ inline void CelestialBody::updateOrbElements(SGTime *t) a = aFirst + (aSec * actTime); } /***************************************************************************** - * inline double CelestialBody::fgCalcActTime(SGTime *t) + * inline double CelestialBody::fgCalcActTime(double mjd) * this private member function returns the offset in days from the epoch for * wich the orbital elements are calculated (Jan, 1st, 2000). * @@ -166,9 +166,9 @@ inline void CelestialBody::updateOrbElements(SGTime *t) * * return value: the (fractional) number of days until Jan 1, 2000. ****************************************************************************/ -inline double CelestialBody::fgCalcActTime(SGTime *t) +inline double CelestialBody::fgCalcActTime(double mjd) { - return (t->getMjd() - 36523.5); + return (mjd - 36523.5); } /***************************************************************************** diff --git a/simgear/ephemeris/ephemeris.cxx b/simgear/ephemeris/ephemeris.cxx index 1a53918c..069b1216 100644 --- a/simgear/ephemeris/ephemeris.cxx +++ b/simgear/ephemeris/ephemeris.cxx @@ -26,7 +26,7 @@ // Constructor -FGEphemeris::FGEphemeris( const string &path ) { +SGEphemeris::SGEphemeris( const string &path ) { our_sun = new Star; moon = new Moon; mercury = new Mercury; @@ -36,12 +36,12 @@ FGEphemeris::FGEphemeris( const string &path ) { saturn = new Saturn; uranus = new Uranus; neptune = new Neptune; - stars = new FGStars( FGPath(path) ); + stars = new SGStarData( FGPath(path) ); } // Destructor -FGEphemeris::~FGEphemeris( void ) { +SGEphemeris::~SGEphemeris( void ) { delete our_sun; delete moon; delete mercury; @@ -57,17 +57,17 @@ FGEphemeris::~FGEphemeris( void ) { // Update (recalculate) the positions of all objects for the specified // time -void FGEphemeris::update( SGTime *t, double lat ) { +void SGEphemeris::update( double mjd, double lst, double lat ) { // update object positions - our_sun->updatePosition( t ); - moon->updatePosition( t, lat, our_sun ); - mercury->updatePosition( t, our_sun ); - venus->updatePosition( t, our_sun ); - mars->updatePosition( t, our_sun ); - jupiter->updatePosition( t, our_sun ); - saturn->updatePosition( t, our_sun ); - uranus->updatePosition( t, our_sun ); - neptune->updatePosition( t, our_sun ); + our_sun->updatePosition( mjd ); + moon->updatePosition( mjd, lst, lat, our_sun ); + mercury->updatePosition( mjd, our_sun ); + venus->updatePosition( mjd, our_sun ); + mars->updatePosition( mjd, our_sun ); + jupiter->updatePosition( mjd, our_sun ); + saturn->updatePosition( mjd, our_sun ); + uranus->updatePosition( mjd, our_sun ); + neptune->updatePosition( mjd, our_sun ); // update planets list nplanets = 7; diff --git a/simgear/ephemeris/ephemeris.hxx b/simgear/ephemeris/ephemeris.hxx index 7340d5e1..446d535c 100644 --- a/simgear/ephemeris/ephemeris.hxx +++ b/simgear/ephemeris/ephemeris.hxx @@ -1,7 +1,10 @@ // ephemeris.hxx -- Top level class for calculating current positions of // astronomical objects // -// Written by Curtis Olson, started March 2000. +// Top level interface written by Curtis Olson, started March 2000. +// +// All the core code underneath this is written by Durk Talsma. See +// the headers of all the other individual files for details. // // Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org // @@ -32,8 +35,6 @@ #include -#include - #include "star.hxx" #include "moon.hxx" #include "mercury.hxx" @@ -46,7 +47,7 @@ #include "stars.hxx" -class FGEphemeris { +class SGEphemeris { Star *our_sun; Moon *moon; @@ -65,19 +66,19 @@ class FGEphemeris { int nplanets; sgdVec3 planets[7]; - FGStars *stars; + SGStarData *stars; public: // Constructor - FGEphemeris( const string &path ); + SGEphemeris( const string &path ); // Destructor - ~FGEphemeris( void ); + ~SGEphemeris( void ); // Update (recalculate) the positions of all objects for the // specified time - void update(SGTime *t, double lat); + void update(double mjd, double lst, double lat); // sun inline Star *get_sun() const { return our_sun; } diff --git a/simgear/ephemeris/jupiter.cxx b/simgear/ephemeris/jupiter.cxx index 820cdab1..5363ccec 100644 --- a/simgear/ephemeris/jupiter.cxx +++ b/simgear/ephemeris/jupiter.cxx @@ -31,19 +31,19 @@ #include "jupiter.hxx" /************************************************************************* - * Jupiter::Jupiter(SGTime *t) + * Jupiter::Jupiter(double mjd) * Public constructor for class Jupiter * Argument: The current time. * the hard coded orbital elements for Jupiter are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Jupiter::Jupiter(SGTime *t) : +Jupiter::Jupiter(double mjd) : CelestialBody(100.4542, 2.7685400E-5, 1.3030, -1.557E-7, 273.8777, 1.6450500E-5, 5.2025600, 0.000000, 0.048498, 4.469E-9, - 19.89500, 0.08308530010, t) + 19.89500, 0.08308530010, mjd) { } @@ -58,15 +58,15 @@ Jupiter::Jupiter() : } /************************************************************************* - * void Jupiter::updatePosition(SGTime *t, Star *ourSun) + * void Jupiter::updatePosition(double mjd, Star *ourSun) * * calculates the current position of Jupiter, by calling the base class, * CelestialBody::updatePosition(); The current magnitude is calculated using * a Jupiter specific equation *************************************************************************/ -void Jupiter::updatePosition(SGTime *t, Star *ourSun) +void Jupiter::updatePosition(double mjd, Star *ourSun) { - CelestialBody::updatePosition(t, ourSun); + CelestialBody::updatePosition(mjd, ourSun); magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV; } diff --git a/simgear/ephemeris/jupiter.hxx b/simgear/ephemeris/jupiter.hxx index b250fa7b..9ebcee00 100644 --- a/simgear/ephemeris/jupiter.hxx +++ b/simgear/ephemeris/jupiter.hxx @@ -24,17 +24,15 @@ #ifndef _JUPITER_HXX_ #define _JUPITER_HXX_ -#include - #include "celestialBody.hxx" #include "star.hxx" class Jupiter : public CelestialBody { public: - Jupiter (SGTime *t); + Jupiter (double mjd); Jupiter (); - void updatePosition(SGTime *t, Star *ourSun); + void updatePosition(double mjd, Star *ourSun); }; #endif // _JUPITER_HXX_ diff --git a/simgear/ephemeris/mars.cxx b/simgear/ephemeris/mars.cxx index 3cb53bce..6d22b65f 100644 --- a/simgear/ephemeris/mars.cxx +++ b/simgear/ephemeris/mars.cxx @@ -30,19 +30,19 @@ #include "mars.hxx" /************************************************************************* - * Mars::Mars(SGTime *t) + * Mars::Mars(double mjd) * Public constructor for class Mars * Argument: The current time. * the hard coded orbital elements for Mars are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Mars::Mars(SGTime *t) : +Mars::Mars(double mjd) : CelestialBody(49.55740, 2.1108100E-5, 1.8497, -1.78E-8, 286.5016, 2.9296100E-5, 1.5236880, 0.000000, 0.093405, 2.516E-9, - 18.60210, 0.52402077660, t) + 18.60210, 0.52402077660, mjd) { } Mars::Mars() : @@ -55,14 +55,14 @@ Mars::Mars() : { } /************************************************************************* - * void Mars::updatePosition(SGTime *t, Star *ourSun) + * void Mars::updatePosition(double mjd, Star *ourSun) * * calculates the current position of Mars, by calling the base class, * CelestialBody::updatePosition(); The current magnitude is calculated using * a Mars specific equation *************************************************************************/ -void Mars::updatePosition(SGTime *t, Star *ourSun) +void Mars::updatePosition(double mjd, Star *ourSun) { - CelestialBody::updatePosition(t, ourSun); + CelestialBody::updatePosition(mjd, ourSun); magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV; } diff --git a/simgear/ephemeris/mars.hxx b/simgear/ephemeris/mars.hxx index 1b896af4..cb924192 100644 --- a/simgear/ephemeris/mars.hxx +++ b/simgear/ephemeris/mars.hxx @@ -24,17 +24,15 @@ #ifndef _MARS_HXX_ #define _MARS_HXX_ -#include - #include "celestialBody.hxx" #include "star.hxx" class Mars : public CelestialBody { public: - Mars ( SGTime *t); + Mars ( double mjd ); Mars (); - void updatePosition(SGTime *t, Star *ourSun); + void updatePosition(double mjd, Star *ourSun); }; #endif // _MARS_HXX_ diff --git a/simgear/ephemeris/mercury.cxx b/simgear/ephemeris/mercury.cxx index 7aba2f4f..ff153126 100644 --- a/simgear/ephemeris/mercury.cxx +++ b/simgear/ephemeris/mercury.cxx @@ -30,19 +30,19 @@ #include "mercury.hxx" /************************************************************************* - * Mercury::Mercury(SGTime *t) + * Mercury::Mercury(double mjd) * Public constructor for class Mercury * Argument: The current time. * the hard coded orbital elements for Mercury are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Mercury::Mercury(SGTime *t) : +Mercury::Mercury(double mjd) : CelestialBody (48.33130, 3.2458700E-5, 7.0047, 5.00E-8, 29.12410, 1.0144400E-5, 0.3870980, 0.000000, 0.205635, 5.59E-10, - 168.6562, 4.09233443680, t) + 168.6562, 4.09233443680, mjd) { } Mercury::Mercury() : @@ -55,15 +55,15 @@ Mercury::Mercury() : { } /************************************************************************* - * void Mercury::updatePosition(SGTime *t, Star *ourSun) + * void Mercury::updatePosition(double mjd, Star *ourSun) * * calculates the current position of Mercury, by calling the base class, * CelestialBody::updatePosition(); The current magnitude is calculated using * a Mercury specific equation *************************************************************************/ -void Mercury::updatePosition(SGTime *t, Star *ourSun) +void Mercury::updatePosition(double mjd, Star *ourSun) { - CelestialBody::updatePosition(t, ourSun); + CelestialBody::updatePosition(mjd, ourSun); magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6); } diff --git a/simgear/ephemeris/mercury.hxx b/simgear/ephemeris/mercury.hxx index 39b37d27..262ec7b2 100644 --- a/simgear/ephemeris/mercury.hxx +++ b/simgear/ephemeris/mercury.hxx @@ -24,17 +24,15 @@ #ifndef _MERCURY_HXX_ #define _MERCURY_HXX_ -#include - #include "celestialBody.hxx" #include "star.hxx" class Mercury : public CelestialBody { public: - Mercury ( SGTime *t); + Mercury (double mjd); Mercury (); - void updatePosition(SGTime *t, Star* ourSun); + void updatePosition(double mjd, Star* ourSun); }; #endif // _MERURY_HXX_ diff --git a/simgear/ephemeris/moon.cxx b/simgear/ephemeris/moon.cxx index e28b8f7a..8bd22803 100644 --- a/simgear/ephemeris/moon.cxx +++ b/simgear/ephemeris/moon.cxx @@ -39,20 +39,20 @@ /************************************************************************* - * Moon::Moon(SGTime *t) + * Moon::Moon(double mjd) * Public constructor for class Moon. Initializes the orbital elements and * sets up the moon texture. * Argument: The current time. * the hard coded orbital elements for Moon are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Moon::Moon(SGTime *t) : +Moon::Moon(double mjd) : CelestialBody(125.1228, -0.0529538083, 5.1454, 0.00000, 318.0634, 0.1643573223, 60.266600, 0.000000, 0.054900, 0.000000, - 115.3654, 13.0649929509, t) + 115.3654, 13.0649929509, mjd) { } @@ -73,12 +73,12 @@ Moon::~Moon() /***************************************************************************** - * void Moon::updatePosition(SGTime *t, Star *ourSun) + * void Moon::updatePosition(double mjd, Star *ourSun) * this member function calculates the actual topocentric position (i.e.) * the position of the moon as seen from the current position on the surface * of the moon. ****************************************************************************/ -void Moon::updatePosition(SGTime *t, double lat, Star *ourSun) +void Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun) { double eccAnom, ecl, actTime, @@ -86,8 +86,8 @@ void Moon::updatePosition(SGTime *t, double lat, Star *ourSun) Ls, Lm, D, F, mpar, gclat, rho, HA, g, geoRa, geoDec; - updateOrbElements(t); - actTime = fgCalcActTime(t); + updateOrbElements(mjd); + actTime = fgCalcActTime(mjd); // calculate the angle between ecliptic and equatorial coordinate system // in Radians @@ -174,7 +174,7 @@ void Moon::updatePosition(SGTime *t, double lat, Star *ourSun) if (geoRa < 0) geoRa += (2*FG_PI); - HA = t->getLst() - (3.8197186 * geoRa); + HA = lst - (3.8197186 * geoRa); /* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst() << " HA = " << HA ); */ diff --git a/simgear/ephemeris/moon.hxx b/simgear/ephemeris/moon.hxx index 4756e70a..f4d083d1 100644 --- a/simgear/ephemeris/moon.hxx +++ b/simgear/ephemeris/moon.hxx @@ -26,7 +26,6 @@ #include -#include #include "celestialBody.hxx" #include "star.hxx" @@ -49,10 +48,10 @@ private: public: - Moon( SGTime *t); + Moon(double mjd); Moon(); ~Moon(); - void updatePosition(SGTime *t, double lat, Star *ourSun); + void updatePosition(double mjd, double lst, double lat, Star *ourSun); // void newImage(); }; diff --git a/simgear/ephemeris/neptune.cxx b/simgear/ephemeris/neptune.cxx index 302c5df9..89177821 100644 --- a/simgear/ephemeris/neptune.cxx +++ b/simgear/ephemeris/neptune.cxx @@ -30,19 +30,19 @@ #include "neptune.hxx" /************************************************************************* - * Neptune::Neptune(SGTime *t) + * Neptune::Neptune(double mjd) * Public constructor for class Neptune * Argument: The current time. * the hard coded orbital elements for Neptune are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Neptune::Neptune(SGTime *t) : +Neptune::Neptune(double mjd) : CelestialBody(131.7806, 3.0173000E-5, 1.7700, -2.550E-7, 272.8461, -6.027000E-6, 30.058260, 3.313E-8, 0.008606, 2.150E-9, - 260.2471, 0.00599514700, t) + 260.2471, 0.00599514700, mjd) { } Neptune::Neptune() : @@ -55,14 +55,14 @@ Neptune::Neptune() : { } /************************************************************************* - * void Neptune::updatePosition(SGTime *t, Star *ourSun) + * void Neptune::updatePosition(double mjd, Star *ourSun) * * calculates the current position of Neptune, by calling the base class, * CelestialBody::updatePosition(); The current magnitude is calculated using * a Neptune specific equation *************************************************************************/ -void Neptune::updatePosition(SGTime *t, Star *ourSun) +void Neptune::updatePosition(double mjd, Star *ourSun) { - CelestialBody::updatePosition(t, ourSun); + CelestialBody::updatePosition(mjd, ourSun); magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV; } diff --git a/simgear/ephemeris/neptune.hxx b/simgear/ephemeris/neptune.hxx index 3fe30b0e..44fcd6d4 100644 --- a/simgear/ephemeris/neptune.hxx +++ b/simgear/ephemeris/neptune.hxx @@ -24,17 +24,15 @@ #ifndef _NEPTUNE_HXX_ #define _NEPTUNE_HXX_ -#include - #include "celestialBody.hxx" #include "star.hxx" class Neptune : public CelestialBody { public: - Neptune ( SGTime *t); + Neptune (double mjd); Neptune (); - void updatePosition(SGTime *t, Star *ourSun); + void updatePosition(double mjd, Star *ourSun); }; #endif // _NEPTUNE_HXX_ diff --git a/simgear/ephemeris/pluto.hxx b/simgear/ephemeris/pluto.hxx index 3bd055fd..b500c44b 100644 --- a/simgear/ephemeris/pluto.hxx +++ b/simgear/ephemeris/pluto.hxx @@ -24,13 +24,12 @@ #ifndef _PLUTO_HXX_ #define _PLUTO_HXX_ -#include