Minor tidying up of interface.

This commit is contained in:
curt 2000-07-08 03:06:45 +00:00
parent cf1c7e7378
commit 1e53bedca5
25 changed files with 131 additions and 146 deletions

View File

@ -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 * Basically, this member function provides a general interface for
* calculating the right ascension and declinaion. This function is * calculating the right ascension and declinaion. This function is
@ -45,20 +45,20 @@
* position is calculated an a slightly different manner. * position is calculated an a slightly different manner.
* *
* arguments: * 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 * Star *ourSun: the sun's position is needed to convert heliocentric
* coordinates into geocentric coordinates. * coordinates into geocentric coordinates.
* *
* return value: none * return value: none
* *
*************************************************************************/ *************************************************************************/
void CelestialBody::updatePosition(SGTime *t, Star *ourSun) void CelestialBody::updatePosition(double mjd, Star *ourSun)
{ {
double eccAnom, v, ecl, actTime, double eccAnom, v, ecl, actTime,
xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze; xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
updateOrbElements(t); updateOrbElements(mjd);
actTime = fgCalcActTime(t); actTime = fgCalcActTime(mjd);
// calcualate the angle bewteen ecliptic and equatorial coordinate system // calcualate the angle bewteen ecliptic and equatorial coordinate system
ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 *actTime); ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 *actTime);

View File

@ -61,8 +61,8 @@ protected: // make the data protected, in order to give the
double lonEcl, latEcl; double lonEcl, latEcl;
double fgCalcEccAnom(double M, double e); double fgCalcEccAnom(double M, double e);
double fgCalcActTime(SGTime *t); double fgCalcActTime(double mjd);
void updateOrbElements(SGTime *t); void updateOrbElements(double mjd);
public: public:
CelestialBody(double Nf, double Ns, CelestialBody(double Nf, double Ns,
@ -70,7 +70,7 @@ public:
double wf, double ws, double wf, double ws,
double af, double as, double af, double as,
double ef, double es, double ef, double es,
double Mf, double Ms, SGTime *t); double Mf, double Ms, double mjd);
CelestialBody(double Nf, double Ns, CelestialBody(double Nf, double Ns,
double If, double Is, double If, double Is,
double wf, double ws, double wf, double ws,
@ -84,7 +84,7 @@ public:
double getMagnitude(); double getMagnitude();
double getLon(); double getLon();
double getLat(); 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 wf, double ws,
double af, double as, double af, double as,
double ef, double es, double ef, double es,
double Mf, double Ms, SGTime *t) double Mf, double Ms, double mjd)
{ {
NFirst = Nf; NSec = Ns; NFirst = Nf; NSec = Ns;
iFirst = If; iSec = Is; iFirst = If; iSec = Is;
@ -120,7 +120,7 @@ inline CelestialBody::CelestialBody(double Nf, double Ns,
aFirst = af; aSec = as; aFirst = af; aSec = as;
eFirst = ef; eSec = es; eFirst = ef; eSec = es;
MFirst = Mf; MSec = Ms; MFirst = Mf; MSec = Ms;
updateOrbElements(t); updateOrbElements(mjd);
}; };
inline CelestialBody::CelestialBody(double Nf, double Ns, 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 * given the current time, this private member calculates the actual
* orbital elements * orbital elements
* *
* Arguments: SGTime *t: the current time: * Arguments: double mjd: the current modified julian date:
* *
* return value: none * 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)); M = DEG_TO_RAD * (MFirst + (MSec * actTime));
w = DEG_TO_RAD * (wFirst + (wSec * actTime)); w = DEG_TO_RAD * (wFirst + (wSec * actTime));
N = DEG_TO_RAD * (NFirst + (NSec * actTime)); N = DEG_TO_RAD * (NFirst + (NSec * actTime));
@ -158,7 +158,7 @@ inline void CelestialBody::updateOrbElements(SGTime *t)
a = aFirst + (aSec * actTime); 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 * this private member function returns the offset in days from the epoch for
* wich the orbital elements are calculated (Jan, 1st, 2000). * 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. * 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);
} }
/***************************************************************************** /*****************************************************************************

View File

@ -26,7 +26,7 @@
// Constructor // Constructor
FGEphemeris::FGEphemeris( const string &path ) { SGEphemeris::SGEphemeris( const string &path ) {
our_sun = new Star; our_sun = new Star;
moon = new Moon; moon = new Moon;
mercury = new Mercury; mercury = new Mercury;
@ -36,12 +36,12 @@ FGEphemeris::FGEphemeris( const string &path ) {
saturn = new Saturn; saturn = new Saturn;
uranus = new Uranus; uranus = new Uranus;
neptune = new Neptune; neptune = new Neptune;
stars = new FGStars( FGPath(path) ); stars = new SGStarData( FGPath(path) );
} }
// Destructor // Destructor
FGEphemeris::~FGEphemeris( void ) { SGEphemeris::~SGEphemeris( void ) {
delete our_sun; delete our_sun;
delete moon; delete moon;
delete mercury; delete mercury;
@ -57,17 +57,17 @@ FGEphemeris::~FGEphemeris( void ) {
// Update (recalculate) the positions of all objects for the specified // Update (recalculate) the positions of all objects for the specified
// time // time
void FGEphemeris::update( SGTime *t, double lat ) { void SGEphemeris::update( double mjd, double lst, double lat ) {
// update object positions // update object positions
our_sun->updatePosition( t ); our_sun->updatePosition( mjd );
moon->updatePosition( t, lat, our_sun ); moon->updatePosition( mjd, lst, lat, our_sun );
mercury->updatePosition( t, our_sun ); mercury->updatePosition( mjd, our_sun );
venus->updatePosition( t, our_sun ); venus->updatePosition( mjd, our_sun );
mars->updatePosition( t, our_sun ); mars->updatePosition( mjd, our_sun );
jupiter->updatePosition( t, our_sun ); jupiter->updatePosition( mjd, our_sun );
saturn->updatePosition( t, our_sun ); saturn->updatePosition( mjd, our_sun );
uranus->updatePosition( t, our_sun ); uranus->updatePosition( mjd, our_sun );
neptune->updatePosition( t, our_sun ); neptune->updatePosition( mjd, our_sun );
// update planets list // update planets list
nplanets = 7; nplanets = 7;

View File

@ -1,7 +1,10 @@
// ephemeris.hxx -- Top level class for calculating current positions of // ephemeris.hxx -- Top level class for calculating current positions of
// astronomical objects // 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 // Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
// //
@ -32,8 +35,6 @@
#include <plib/sg.h> #include <plib/sg.h>
#include <simgear/timing/sg_time.hxx>
#include "star.hxx" #include "star.hxx"
#include "moon.hxx" #include "moon.hxx"
#include "mercury.hxx" #include "mercury.hxx"
@ -46,7 +47,7 @@
#include "stars.hxx" #include "stars.hxx"
class FGEphemeris { class SGEphemeris {
Star *our_sun; Star *our_sun;
Moon *moon; Moon *moon;
@ -65,19 +66,19 @@ class FGEphemeris {
int nplanets; int nplanets;
sgdVec3 planets[7]; sgdVec3 planets[7];
FGStars *stars; SGStarData *stars;
public: public:
// Constructor // Constructor
FGEphemeris( const string &path ); SGEphemeris( const string &path );
// Destructor // Destructor
~FGEphemeris( void ); ~SGEphemeris( void );
// Update (recalculate) the positions of all objects for the // Update (recalculate) the positions of all objects for the
// specified time // specified time
void update(SGTime *t, double lat); void update(double mjd, double lst, double lat);
// sun // sun
inline Star *get_sun() const { return our_sun; } inline Star *get_sun() const { return our_sun; }

View File

@ -31,19 +31,19 @@
#include "jupiter.hxx" #include "jupiter.hxx"
/************************************************************************* /*************************************************************************
* Jupiter::Jupiter(SGTime *t) * Jupiter::Jupiter(double mjd)
* Public constructor for class Jupiter * Public constructor for class Jupiter
* Argument: The current time. * Argument: The current time.
* the hard coded orbital elements for Jupiter are passed to * the hard coded orbital elements for Jupiter are passed to
* CelestialBody::CelestialBody(); * CelestialBody::CelestialBody();
************************************************************************/ ************************************************************************/
Jupiter::Jupiter(SGTime *t) : Jupiter::Jupiter(double mjd) :
CelestialBody(100.4542, 2.7685400E-5, CelestialBody(100.4542, 2.7685400E-5,
1.3030, -1.557E-7, 1.3030, -1.557E-7,
273.8777, 1.6450500E-5, 273.8777, 1.6450500E-5,
5.2025600, 0.000000, 5.2025600, 0.000000,
0.048498, 4.469E-9, 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, * calculates the current position of Jupiter, by calling the base class,
* CelestialBody::updatePosition(); The current magnitude is calculated using * CelestialBody::updatePosition(); The current magnitude is calculated using
* a Jupiter specific equation * 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; magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV;
} }

View File

@ -24,17 +24,15 @@
#ifndef _JUPITER_HXX_ #ifndef _JUPITER_HXX_
#define _JUPITER_HXX_ #define _JUPITER_HXX_
#include <simgear/timing/sg_time.hxx>
#include "celestialBody.hxx" #include "celestialBody.hxx"
#include "star.hxx" #include "star.hxx"
class Jupiter : public CelestialBody class Jupiter : public CelestialBody
{ {
public: public:
Jupiter (SGTime *t); Jupiter (double mjd);
Jupiter (); Jupiter ();
void updatePosition(SGTime *t, Star *ourSun); void updatePosition(double mjd, Star *ourSun);
}; };
#endif // _JUPITER_HXX_ #endif // _JUPITER_HXX_

View File

@ -30,19 +30,19 @@
#include "mars.hxx" #include "mars.hxx"
/************************************************************************* /*************************************************************************
* Mars::Mars(SGTime *t) * Mars::Mars(double mjd)
* Public constructor for class Mars * Public constructor for class Mars
* Argument: The current time. * Argument: The current time.
* the hard coded orbital elements for Mars are passed to * the hard coded orbital elements for Mars are passed to
* CelestialBody::CelestialBody(); * CelestialBody::CelestialBody();
************************************************************************/ ************************************************************************/
Mars::Mars(SGTime *t) : Mars::Mars(double mjd) :
CelestialBody(49.55740, 2.1108100E-5, CelestialBody(49.55740, 2.1108100E-5,
1.8497, -1.78E-8, 1.8497, -1.78E-8,
286.5016, 2.9296100E-5, 286.5016, 2.9296100E-5,
1.5236880, 0.000000, 1.5236880, 0.000000,
0.093405, 2.516E-9, 0.093405, 2.516E-9,
18.60210, 0.52402077660, t) 18.60210, 0.52402077660, mjd)
{ {
} }
Mars::Mars() : 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, * calculates the current position of Mars, by calling the base class,
* CelestialBody::updatePosition(); The current magnitude is calculated using * CelestialBody::updatePosition(); The current magnitude is calculated using
* a Mars specific equation * 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; magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV;
} }

View File

@ -24,17 +24,15 @@
#ifndef _MARS_HXX_ #ifndef _MARS_HXX_
#define _MARS_HXX_ #define _MARS_HXX_
#include <simgear/timing/sg_time.hxx>
#include "celestialBody.hxx" #include "celestialBody.hxx"
#include "star.hxx" #include "star.hxx"
class Mars : public CelestialBody class Mars : public CelestialBody
{ {
public: public:
Mars ( SGTime *t); Mars ( double mjd );
Mars (); Mars ();
void updatePosition(SGTime *t, Star *ourSun); void updatePosition(double mjd, Star *ourSun);
}; };
#endif // _MARS_HXX_ #endif // _MARS_HXX_

View File

@ -30,19 +30,19 @@
#include "mercury.hxx" #include "mercury.hxx"
/************************************************************************* /*************************************************************************
* Mercury::Mercury(SGTime *t) * Mercury::Mercury(double mjd)
* Public constructor for class Mercury * Public constructor for class Mercury
* Argument: The current time. * Argument: The current time.
* the hard coded orbital elements for Mercury are passed to * the hard coded orbital elements for Mercury are passed to
* CelestialBody::CelestialBody(); * CelestialBody::CelestialBody();
************************************************************************/ ************************************************************************/
Mercury::Mercury(SGTime *t) : Mercury::Mercury(double mjd) :
CelestialBody (48.33130, 3.2458700E-5, CelestialBody (48.33130, 3.2458700E-5,
7.0047, 5.00E-8, 7.0047, 5.00E-8,
29.12410, 1.0144400E-5, 29.12410, 1.0144400E-5,
0.3870980, 0.000000, 0.3870980, 0.000000,
0.205635, 5.59E-10, 0.205635, 5.59E-10,
168.6562, 4.09233443680, t) 168.6562, 4.09233443680, mjd)
{ {
} }
Mercury::Mercury() : 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, * calculates the current position of Mercury, by calling the base class,
* CelestialBody::updatePosition(); The current magnitude is calculated using * CelestialBody::updatePosition(); The current magnitude is calculated using
* a Mercury specific equation * 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); magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6);
} }

View File

@ -24,17 +24,15 @@
#ifndef _MERCURY_HXX_ #ifndef _MERCURY_HXX_
#define _MERCURY_HXX_ #define _MERCURY_HXX_
#include <simgear/timing/sg_time.hxx>
#include "celestialBody.hxx" #include "celestialBody.hxx"
#include "star.hxx" #include "star.hxx"
class Mercury : public CelestialBody class Mercury : public CelestialBody
{ {
public: public:
Mercury ( SGTime *t); Mercury (double mjd);
Mercury (); Mercury ();
void updatePosition(SGTime *t, Star* ourSun); void updatePosition(double mjd, Star* ourSun);
}; };
#endif // _MERURY_HXX_ #endif // _MERURY_HXX_

View File

@ -39,20 +39,20 @@
/************************************************************************* /*************************************************************************
* Moon::Moon(SGTime *t) * Moon::Moon(double mjd)
* Public constructor for class Moon. Initializes the orbital elements and * Public constructor for class Moon. Initializes the orbital elements and
* sets up the moon texture. * sets up the moon texture.
* Argument: The current time. * Argument: The current time.
* the hard coded orbital elements for Moon are passed to * the hard coded orbital elements for Moon are passed to
* CelestialBody::CelestialBody(); * CelestialBody::CelestialBody();
************************************************************************/ ************************************************************************/
Moon::Moon(SGTime *t) : Moon::Moon(double mjd) :
CelestialBody(125.1228, -0.0529538083, CelestialBody(125.1228, -0.0529538083,
5.1454, 0.00000, 5.1454, 0.00000,
318.0634, 0.1643573223, 318.0634, 0.1643573223,
60.266600, 0.000000, 60.266600, 0.000000,
0.054900, 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.) * this member function calculates the actual topocentric position (i.e.)
* the position of the moon as seen from the current position on the surface * the position of the moon as seen from the current position on the surface
* of the moon. * of the moon.
****************************************************************************/ ****************************************************************************/
void Moon::updatePosition(SGTime *t, double lat, Star *ourSun) void Moon::updatePosition(double mjd, double lst, double lat, Star *ourSun)
{ {
double double
eccAnom, ecl, actTime, 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, Ls, Lm, D, F, mpar, gclat, rho, HA, g,
geoRa, geoDec; geoRa, geoDec;
updateOrbElements(t); updateOrbElements(mjd);
actTime = fgCalcActTime(t); actTime = fgCalcActTime(mjd);
// calculate the angle between ecliptic and equatorial coordinate system // calculate the angle between ecliptic and equatorial coordinate system
// in Radians // in Radians
@ -174,7 +174,7 @@ void Moon::updatePosition(SGTime *t, double lat, Star *ourSun)
if (geoRa < 0) if (geoRa < 0)
geoRa += (2*FG_PI); 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() /* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst()
<< " HA = " << HA ); */ << " HA = " << HA ); */

View File

@ -26,7 +26,6 @@
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/timing/sg_time.hxx>
#include "celestialBody.hxx" #include "celestialBody.hxx"
#include "star.hxx" #include "star.hxx"
@ -49,10 +48,10 @@ private:
public: public:
Moon( SGTime *t); Moon(double mjd);
Moon(); Moon();
~Moon(); ~Moon();
void updatePosition(SGTime *t, double lat, Star *ourSun); void updatePosition(double mjd, double lst, double lat, Star *ourSun);
// void newImage(); // void newImage();
}; };

View File

@ -30,19 +30,19 @@
#include "neptune.hxx" #include "neptune.hxx"
/************************************************************************* /*************************************************************************
* Neptune::Neptune(SGTime *t) * Neptune::Neptune(double mjd)
* Public constructor for class Neptune * Public constructor for class Neptune
* Argument: The current time. * Argument: The current time.
* the hard coded orbital elements for Neptune are passed to * the hard coded orbital elements for Neptune are passed to
* CelestialBody::CelestialBody(); * CelestialBody::CelestialBody();
************************************************************************/ ************************************************************************/
Neptune::Neptune(SGTime *t) : Neptune::Neptune(double mjd) :
CelestialBody(131.7806, 3.0173000E-5, CelestialBody(131.7806, 3.0173000E-5,
1.7700, -2.550E-7, 1.7700, -2.550E-7,
272.8461, -6.027000E-6, 272.8461, -6.027000E-6,
30.058260, 3.313E-8, 30.058260, 3.313E-8,
0.008606, 2.150E-9, 0.008606, 2.150E-9,
260.2471, 0.00599514700, t) 260.2471, 0.00599514700, mjd)
{ {
} }
Neptune::Neptune() : 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, * calculates the current position of Neptune, by calling the base class,
* CelestialBody::updatePosition(); The current magnitude is calculated using * CelestialBody::updatePosition(); The current magnitude is calculated using
* a Neptune specific equation * 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; magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV;
} }

View File

@ -24,17 +24,15 @@
#ifndef _NEPTUNE_HXX_ #ifndef _NEPTUNE_HXX_
#define _NEPTUNE_HXX_ #define _NEPTUNE_HXX_
#include <simgear/timing/sg_time.hxx>
#include "celestialBody.hxx" #include "celestialBody.hxx"
#include "star.hxx" #include "star.hxx"
class Neptune : public CelestialBody class Neptune : public CelestialBody
{ {
public: public:
Neptune ( SGTime *t); Neptune (double mjd);
Neptune (); Neptune ();
void updatePosition(SGTime *t, Star *ourSun); void updatePosition(double mjd, Star *ourSun);
}; };
#endif // _NEPTUNE_HXX_ #endif // _NEPTUNE_HXX_

View File

@ -24,13 +24,12 @@
#ifndef _PLUTO_HXX_ #ifndef _PLUTO_HXX_
#define _PLUTO_HXX_ #define _PLUTO_HXX_
#include <Time/fg_time.hxx>
#include "celestialBody.hxx" #include "celestialBody.hxx"
class Pluto : public CelestialBody class Pluto : public CelestialBody
{ {
public: public:
Pluto ( FGTime *t); Pluto (double mjd);
Pluto (); Pluto ();
}; };

View File

@ -30,19 +30,19 @@
#include "saturn.hxx" #include "saturn.hxx"
/************************************************************************* /*************************************************************************
* Saturn::Saturn(SGTime *t) * Saturn::Saturn(double mjd)
* Public constructor for class Saturn * Public constructor for class Saturn
* Argument: The current time. * Argument: The current time.
* the hard coded orbital elements for Saturn are passed to * the hard coded orbital elements for Saturn are passed to
* CelestialBody::CelestialBody(); * CelestialBody::CelestialBody();
************************************************************************/ ************************************************************************/
Saturn::Saturn(SGTime *t) : Saturn::Saturn(double mjd) :
CelestialBody(113.6634, 2.3898000E-5, CelestialBody(113.6634, 2.3898000E-5,
2.4886, -1.081E-7, 2.4886, -1.081E-7,
339.3939, 2.9766100E-5, 339.3939, 2.9766100E-5,
9.5547500, 0.000000, 9.5547500, 0.000000,
0.055546, -9.499E-9, 0.055546, -9.499E-9,
316.9670, 0.03344422820, t) 316.9670, 0.03344422820, mjd)
{ {
} }
Saturn::Saturn() : Saturn::Saturn() :
@ -56,17 +56,17 @@ Saturn::Saturn() :
} }
/************************************************************************* /*************************************************************************
* void Saturn::updatePosition(SGTime *t, Star *ourSun) * void Saturn::updatePosition(double mjd, Star *ourSun)
* *
* calculates the current position of Saturn, by calling the base class, * calculates the current position of Saturn, by calling the base class,
* CelestialBody::updatePosition(); The current magnitude is calculated using * CelestialBody::updatePosition(); The current magnitude is calculated using
* a Saturn specific equation * a Saturn specific equation
*************************************************************************/ *************************************************************************/
void Saturn::updatePosition(SGTime *t, Star *ourSun) void Saturn::updatePosition(double mjd, Star *ourSun)
{ {
CelestialBody::updatePosition(t, ourSun); CelestialBody::updatePosition(mjd, ourSun);
double actTime = fgCalcActTime(t); double actTime = fgCalcActTime(mjd);
double ir = 0.4897394; double ir = 0.4897394;
double Nr = 2.9585076 + 6.6672E-7*actTime; double Nr = 2.9585076 + 6.6672E-7*actTime;
double B = asin (sin(declination) * cos(ir) - double B = asin (sin(declination) * cos(ir) -

View File

@ -24,17 +24,15 @@
#ifndef _SATURN_HXX_ #ifndef _SATURN_HXX_
#define _SATURN_HXX_ #define _SATURN_HXX_
#include <simgear/timing/sg_time.hxx>
#include "celestialBody.hxx" #include "celestialBody.hxx"
#include "star.hxx" #include "star.hxx"
class Saturn : public CelestialBody class Saturn : public CelestialBody
{ {
public: public:
Saturn ( SGTime *t); Saturn (double mjd);
Saturn (); Saturn ();
void updatePosition(SGTime *t, Star *ourSun); void updatePosition(double mjd, Star *ourSun);
}; };
#endif // _SATURN_HXX_ #endif // _SATURN_HXX_

View File

@ -34,7 +34,7 @@
/************************************************************************* /*************************************************************************
* Star::Star(SGTime *t) * Star::Star(double mjd)
* Public constructor for class Star * Public constructor for class Star
* Argument: The current time. * Argument: The current time.
* the hard coded orbital elements our sun are passed to * the hard coded orbital elements our sun are passed to
@ -42,13 +42,13 @@
* note that the word sun is avoided, in order to prevent some compilation * note that the word sun is avoided, in order to prevent some compilation
* problems on sun systems * problems on sun systems
************************************************************************/ ************************************************************************/
Star::Star(SGTime *t) : Star::Star(double mjd) :
CelestialBody (0.000000, 0.0000000000, CelestialBody (0.000000, 0.0000000000,
0.0000, 0.00000, 0.0000, 0.00000,
282.9404, 4.7093500E-5, 282.9404, 4.7093500E-5,
1.0000000, 0.000000, 1.0000000, 0.000000,
0.016709, -1.151E-9, 0.016709, -1.151E-9,
356.0470, 0.98560025850, t) 356.0470, 0.98560025850, mjd)
{ {
distance = 0.0; distance = 0.0;
} }
@ -70,20 +70,20 @@ Star::~Star()
/************************************************************************* /*************************************************************************
* void Star::updatePosition(SGTime *t, Star *ourSun) * void Star::updatePosition(double mjd, Star *ourSun)
* *
* calculates the current position of our sun. * calculates the current position of our sun.
*************************************************************************/ *************************************************************************/
void Star::updatePosition(SGTime *t) void Star::updatePosition(double mjd)
{ {
double double
actTime, eccAnom, actTime, eccAnom,
xv, yv, v, r, xv, yv, v, r,
xe, ye, ze, ecl; xe, ye, ze, ecl;
updateOrbElements(t); updateOrbElements(mjd);
actTime = fgCalcActTime(t); actTime = fgCalcActTime(mjd);
ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); // Angle in Radians ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); // Angle in Radians
eccAnom = fgCalcEccAnom(M, e); // Calculate the eccentric Anomaly (also known as solving Kepler's equation) eccAnom = fgCalcEccAnom(M, e); // Calculate the eccentric Anomaly (also known as solving Kepler's equation)

View File

@ -38,10 +38,10 @@ private:
public: public:
Star (SGTime *t); Star (double mjd);
Star (); Star ();
~Star(); ~Star();
void updatePosition(SGTime *t); void updatePosition(double mjd);
double getM(); double getM();
double getw(); double getw();
double getxs(); double getxs();

View File

@ -31,25 +31,25 @@
#endif #endif
// Constructor // Constructor
FGStars::FGStars() { SGStarData::SGStarData() {
} }
FGStars::FGStars( FGPath path ) { SGStarData::SGStarData( FGPath path ) {
data_path = FGPath( path ); data_path = FGPath( path );
load(); load();
} }
// Destructor // Destructor
FGStars::~FGStars() { SGStarData::~SGStarData() {
} }
bool FGStars::load() { bool SGStarData::load() {
// -dw- avoid local data > 32k error by dynamic allocation of the // -dw- avoid local data > 32k error by dynamic allocation of the
// array, problem for some compilers // array, problem for some compilers
stars = new sgdVec3[FG_MAX_STARS]; stars = new sgdVec3[SG_MAX_STARS];
// build the full path name to the stars data base file // build the full path name to the stars data base file
data_path.append( "stars" ); data_path.append( "stars" );
@ -69,7 +69,7 @@ bool FGStars::load() {
nstars = 0; nstars = 0;
// read in each line of the file // read in each line of the file
while ( ! in.eof() && nstars < FG_MAX_STARS ) { while ( ! in.eof() && nstars < SG_MAX_STARS ) {
in >> skipcomment; in >> skipcomment;
getline( in, name, ',' ); getline( in, name, ',' );

View File

@ -21,8 +21,8 @@
// $Id$ // $Id$
#ifndef _STARS_HXX #ifndef _SG_STARDATA_HXX
#define _STARS_HXX #define _SG_STARDATA_HXX
#include <plib/sg.h> #include <plib/sg.h>
@ -30,10 +30,10 @@
#include <simgear/misc/fgpath.hxx> #include <simgear/misc/fgpath.hxx>
#define FG_MAX_STARS 850 #define SG_MAX_STARS 850
class FGStars { class SGStarData {
int nstars; int nstars;
sgdVec3 *stars; sgdVec3 *stars;
@ -43,11 +43,11 @@ class FGStars {
public: public:
// Constructor // Constructor
FGStars(); SGStarData();
FGStars( FGPath path ); SGStarData( FGPath path );
// Destructor // Destructor
~FGStars(); ~SGStarData();
// load the stars database // load the stars database
bool load(); bool load();
@ -58,4 +58,4 @@ public:
}; };
#endif // _STARS_HXX #endif // _SG_STARDATA_HXX

View File

@ -30,19 +30,19 @@
#include "uranus.hxx" #include "uranus.hxx"
/************************************************************************* /*************************************************************************
* Uranus::Uranus(SGTime *t) * Uranus::Uranus(double mjd)
* Public constructor for class Uranus * Public constructor for class Uranus
* Argument: The current time. * Argument: The current time.
* the hard coded orbital elements for Uranus are passed to * the hard coded orbital elements for Uranus are passed to
* CelestialBody::CelestialBody(); * CelestialBody::CelestialBody();
************************************************************************/ ************************************************************************/
Uranus::Uranus(SGTime *t) : Uranus::Uranus(double mjd) :
CelestialBody(74.00050, 1.3978000E-5, CelestialBody(74.00050, 1.3978000E-5,
0.7733, 1.900E-8, 0.7733, 1.900E-8,
96.66120, 3.0565000E-5, 96.66120, 3.0565000E-5,
19.181710, -1.55E-8, 19.181710, -1.55E-8,
0.047318, 7.450E-9, 0.047318, 7.450E-9,
142.5905, 0.01172580600, t) 142.5905, 0.01172580600, mjd)
{ {
} }
Uranus::Uranus() : Uranus::Uranus() :
@ -56,14 +56,14 @@ Uranus::Uranus() :
} }
/************************************************************************* /*************************************************************************
* void Uranus::updatePosition(SGTime *t, Star *ourSun) * void Uranus::updatePosition(double mjd, Star *ourSun)
* *
* calculates the current position of Uranus, by calling the base class, * calculates the current position of Uranus, by calling the base class,
* CelestialBody::updatePosition(); The current magnitude is calculated using * CelestialBody::updatePosition(); The current magnitude is calculated using
* a Uranus specific equation * a Uranus specific equation
*************************************************************************/ *************************************************************************/
void Uranus::updatePosition(SGTime *t, Star *ourSun) void Uranus::updatePosition(double mjd, Star *ourSun)
{ {
CelestialBody::updatePosition(t, ourSun); CelestialBody::updatePosition(mjd, ourSun);
magnitude = -7.15 + 5*log10( r*R) + 0.001 * FV; magnitude = -7.15 + 5*log10( r*R) + 0.001 * FV;
} }

View File

@ -24,17 +24,15 @@
#ifndef _URANUS_HXX_ #ifndef _URANUS_HXX_
#define _URANUS_HXX_ #define _URANUS_HXX_
#include <simgear/timing/sg_time.hxx>
#include "celestialBody.hxx" #include "celestialBody.hxx"
#include "star.hxx" #include "star.hxx"
class Uranus : public CelestialBody class Uranus : public CelestialBody
{ {
public: public:
Uranus ( SGTime *t); Uranus (double mjd);
Uranus (); Uranus ();
void updatePosition(SGTime *t, Star *ourSun); void updatePosition(double mjd, Star *ourSun);
}; };
#endif // _URANUS_HXX_ #endif // _URANUS_HXX_

View File

@ -30,19 +30,19 @@
#include "venus.hxx" #include "venus.hxx"
/************************************************************************* /*************************************************************************
* Venus::Venus(SGTime *t) * Venus::Venus(double mjd)
* Public constructor for class Venus * Public constructor for class Venus
* Argument: The current time. * Argument: The current time.
* the hard coded orbital elements for Venus are passed to * the hard coded orbital elements for Venus are passed to
* CelestialBody::CelestialBody(); * CelestialBody::CelestialBody();
************************************************************************/ ************************************************************************/
Venus::Venus(SGTime *t) : Venus::Venus(double mjd) :
CelestialBody(76.67990, 2.4659000E-5, CelestialBody(76.67990, 2.4659000E-5,
3.3946, 2.75E-8, 3.3946, 2.75E-8,
54.89100, 1.3837400E-5, 54.89100, 1.3837400E-5,
0.7233300, 0.000000, 0.7233300, 0.000000,
0.006773, -1.302E-9, 0.006773, -1.302E-9,
48.00520, 1.60213022440, t) 48.00520, 1.60213022440, mjd)
{ {
} }
Venus::Venus() : Venus::Venus() :
@ -56,14 +56,14 @@ Venus::Venus() :
} }
/************************************************************************* /*************************************************************************
* void Venus::updatePosition(SGTime *t, Star *ourSun) * void Venus::updatePosition(double mjd, Star *ourSun)
* *
* calculates the current position of Venus, by calling the base class, * calculates the current position of Venus, by calling the base class,
* CelestialBody::updatePosition(); The current magnitude is calculated using * CelestialBody::updatePosition(); The current magnitude is calculated using
* a Venus specific equation * a Venus specific equation
*************************************************************************/ *************************************************************************/
void Venus::updatePosition(SGTime *t, Star *ourSun) void Venus::updatePosition(double mjd, Star *ourSun)
{ {
CelestialBody::updatePosition(t, ourSun); CelestialBody::updatePosition(mjd, ourSun);
magnitude = -4.34 + 5*log10( r*R ) + 0.013 * FV + 4.2E-07 * pow(FV,3); magnitude = -4.34 + 5*log10( r*R ) + 0.013 * FV + 4.2E-07 * pow(FV,3);
} }

View File

@ -24,17 +24,15 @@
#ifndef _VENUS_HXX_ #ifndef _VENUS_HXX_
#define _VENUS_HXX_ #define _VENUS_HXX_
#include <simgear/timing/sg_time.hxx>
#include "celestialBody.hxx" #include "celestialBody.hxx"
#include "star.hxx" #include "star.hxx"
class Venus : public CelestialBody class Venus : public CelestialBody
{ {
public: public:
Venus ( SGTime *t); Venus (double mjd);
Venus (); Venus ();
void updatePosition(SGTime *t, Star *ourSun); void updatePosition(double mjd, Star *ourSun);
}; };
#endif // _VENUS_HXX_ #endif // _VENUS_HXX_