1 /**************************************************************************
3 * Written by Durk Talsma. Originally started October 1997, for distribution
4 * with the FlightGear project. Version 2 was written in August and
5 * September 1998. This code is based upon algorithms and data kindly
6 * provided by Mr. Paul Schlyter. (pausch@saaf.se).
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 **************************************************************************/
26 #ifndef _CELESTIALBODY_H_
27 #define _CELESTIALBODY_H_
30 # error This library requires C++
34 #include <simgear/constants.h>
40 protected: // make the data protected, in order to give the
41 // inherited classes direct access to the data
42 double NFirst; /* longitude of the ascending node first part */
43 double NSec; /* longitude of the ascending node second part */
44 double iFirst; /* inclination to the ecliptic first part */
45 double iSec; /* inclination to the ecliptic second part */
46 double wFirst; /* first part of argument of perihelion */
47 double wSec; /* second part of argument of perihelion */
48 double aFirst; /* semimayor axis first part*/
49 double aSec; /* semimayor axis second part */
50 double eFirst; /* eccentricity first part */
51 double eSec; /* eccentricity second part */
52 double MFirst; /* Mean anomaly first part */
53 double MSec; /* Mean anomaly second part */
55 double N, i, w, a, e, M; /* the resulting orbital elements, obtained from the former */
57 double rightAscension, declination;
60 double lonEcl, latEcl;
62 double sgCalcEccAnom(double M, double e);
63 double sgCalcActTime(double mjd);
64 void updateOrbElements(double mjd);
67 CelestialBody(double Nf, double Ns,
72 double Mf, double Ms, double mjd);
73 CelestialBody(double Nf, double Ns,
78 double Mf, double Ms);
79 void getPos(double *ra, double *dec);
80 void getPos(double *ra, double *dec, double *magnitude);
81 double getRightAscension();
82 double getDeclination();
83 double getMagnitude();
84 double getLon() const;
85 double getLat() const;
86 void updatePosition(double mjd, Star *ourSun);
89 inline double CelestialBody::getRightAscension() { return rightAscension; }
90 inline double CelestialBody::getDeclination() { return declination; }
91 inline double CelestialBody::getMagnitude() { return magnitude; }
93 inline double CelestialBody::getLon() const
98 inline double CelestialBody::getLat() const
103 #endif // _CELESTIALBODY_H_