Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Ephemeris.h

Go to the documentation of this file.
00001 /*
00002  * Ephemeris.h
00003  *
00004  * Part of Fly! Legacy project
00005  *
00006  * Copyright 2003 Chris Wallace
00007  *
00008  * Fly! Legacy is free software; you can redistribute it and/or modify
00009  *   it under the terms of the GNU General Public License as published by
00010  *   the Free Software Foundation; either version 2 of the License, or
00011  *   (at your option) any later version.
00012  *
00013  * Fly! Legacy is distributed in the hope that it will be useful,
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *   GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  *   along with Fly! Legacy; if not, write to the Free Software
00020  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00043 #ifndef EPHEMERIS_H
00044 #define EPHEMERIS_H
00045 
00046 #include "FlyLegacy.h"
00047 
00048 
00049 //
00050 // Number of days in a single lunar cycle (lunation)
00051 //
00052 #define LUNATION_DAYS 29.530589
00053 
00054 
00055 //
00056 // Structure definition containing orbital elements for a celestial body
00057 //
00058 typedef struct {
00059   double    N;    // Longitude of the ascending node
00060   double    i;    // Inclination to the ecliptic
00061   double    w;    // Argument of perihelion
00062   double    a;    // Semi-major axis
00063   double    e;    // Eccentricity
00064   double    M;    // Mean anomaly
00065 } SOrbitalElements;
00066 
00067 
00068 class CSol;
00069 
00070 class CCelestialBody
00071 {
00072 protected:
00073   double    Nf, If, wf, af, ef, Mf;   // First (constant) part of orbital elements
00074   double    Ns, Is, ws, as, es, Ms;   // Second (variable) part of orbital elements
00075   double    N, i, w, a, e, M;     // Actual orbital elements at last update
00076 
00077   double    rightAscension, declination;
00078   double    r, R, s, FV;
00079   double    magnitude;
00080   double    lonEcl, latEcl;
00081 
00082 protected:
00083   double  CalcEccAnom (double M, double e);
00084   double  CalcActTime (double mjd);
00085   void  UpdateOrbElements (double mjd);
00086 
00087 public:
00088   CCelestialBody (double Nf, double If, double wf, double af, double ef, double Mf,
00089           double Ns, double Is, double ws, double as, double es, double Ms,
00090           double mjd);
00091 
00092   CCelestialBody (double Nf, double If, double wf, double af, double ef, double Mf,
00093           double Ns, double Is, double ws, double as, double es, double Ms);
00094 
00095   void  SetElements (double Nf, double If, double wf, double af, double ef, double Mf,
00096              double Ns, double Is, double ws, double as, double es, double Ms,
00097              double mjd);
00098 
00099   void  SetElements (double Nf, double If, double wf, double af, double ef, double Mf,
00100              double Ns, double Is, double ws, double as, double es, double Ms);
00101 
00102   void  GetPos(double *ra, double *dec);
00103   void  GetPos(double *ra, double *dec, double *magnitude);
00104   double  GetRightAscension();
00105   double  GetDeclination();
00106   double  GetMagnitude();
00107 
00108   double  GetLon();
00109   double  GetLat(); 
00110   void  UpdatePosition (double mjd, CSol *ourSun);
00111 };
00112 
00113 
00114 class CSol : public CCelestialBody
00115 {
00116 public:
00117   CSol (double mjd);
00118   CSol ();
00119   ~CSol();
00120 
00121   // CSol methods
00122     void  UpdatePosition (double mjd);
00123 
00124   inline double getM(void) { return M; }
00125   inline double getw(void) { return w; }
00126   inline double getxs(void) { return xs; }
00127   inline double getys(void) { return ys; }
00128   inline double getDistance(void) { return distance; }
00129 
00130 private:
00131     double xs, ys;     // the sun's rectangular geocentric coordinates
00132     double distance;   // the sun's distance to the earth
00133 };
00134 
00135 
00136 class CMoon : public CCelestialBody {
00137 public:
00138   CMoon (double mjd);
00139   CMoon ();
00140   ~CMoon ();
00141 
00142   float age;    // Lunar phase, 0.0 = new, 0.5 = full
00143 
00144   // CMoon methods
00145   void UpdatePosition(double mjd, double lst, double lat, CSol *ourSun);
00146   float GetAge (void);
00147 };
00148 
00149 
00150 class CMercury : public CCelestialBody
00151 {
00152 public:
00153   CMercury (double mjd);
00154   CMercury ();
00155 
00156   // CCelestialBody methods
00157   void UpdatePosition(double mjd, CSol* ourSun);
00158 };
00159 
00160 
00161 class CVenus : public CCelestialBody
00162 {
00163 public:
00164   CVenus (double mjd);
00165   CVenus ();
00166 
00167   // CCelestialBody methods
00168   void UpdatePosition(double mjd, CSol *ourSun);
00169 };
00170 
00171 
00172 class CMars : public CCelestialBody
00173 {
00174 public:
00175   CMars ( double mjd );
00176   CMars ();
00177 
00178   // CCelestialBody methods
00179   void UpdatePosition(double mjd, CSol *ourSun);
00180 };
00181 
00182 
00183 class CJupiter : public CCelestialBody
00184 {
00185 public:
00186   CJupiter (double mjd);
00187   CJupiter ();
00188 
00189   // CCelestialBody methods
00190   void UpdatePosition(double mjd, CSol *ourSun);
00191 };
00192 
00193 
00194 class CSaturn : public CCelestialBody
00195 {
00196 public:
00197   CSaturn (double mjd);
00198   CSaturn ();
00199 
00200   // CCelestialBody methods
00201   void UpdatePosition(double mjd, CSol *ourSun);
00202 };
00203 
00204 
00205 #endif // EPHEMERIS_H
00206 
00207 
00208 /**************************************************************************
00209  * celestialBody.hxx
00210  * Written by Durk Talsma. Originally started October 1997, for distribution  
00211  * with the FlightGear project. Version 2 was written in August and 
00212  * September 1998. This code is based upon algorithms and data kindly 
00213  * provided by Mr. Paul Schlyter. (pausch@saaf.se). 
00214  *
00215  * This library is free software; you can redistribute it and/or
00216  * modify it under the terms of the GNU Library General Public
00217  * License as published by the Free Software Foundation; either
00218  * version 2 of the License, or (at your option) any later version.
00219  *
00220  * This library is distributed in the hope that it will be useful,
00221  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00222  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00223  * Library General Public License for more details.
00224  *
00225  * You should have received a copy of the GNU Library General Public
00226  * License along with this library; if not, write to the
00227  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00228  * Boston, MA  02111-1307, USA.
00229  *
00230  **************************************************************************/
00231 
SourceForge.net Logo Documentation generated by doxygen