]> git.mxchange.org Git - simgear.git/blob - simgear/ephemeris/celestialBody.hxx
Merge branch 'next' of git.mxchange.org:/var/cache/git/repos/simgear into next
[simgear.git] / simgear / ephemeris / celestialBody.hxx
1 /**************************************************************************
2  * celestialBody.hxx
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). 
7  *
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.
12  *
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.
17  *
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.
21  *
22  * $Id$
23  **************************************************************************/
24
25
26 #ifndef _CELESTIALBODY_H_
27 #define _CELESTIALBODY_H_
28
29 #ifndef __cplusplus
30 # error This library requires C++
31 #endif
32
33
34 #include <simgear/constants.h>
35
36 class Star;
37
38 class CelestialBody
39 {
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 */
54
55   double N, i, w, a, e, M; /* the resulting orbital elements, obtained from the former */
56
57   double rightAscension, declination;
58   double r, R, s, FV;
59   double magnitude;
60   double lonEcl, latEcl;
61
62   double sgCalcEccAnom(double M, double e);
63   double sgCalcActTime(double mjd);
64   void updateOrbElements(double mjd);
65
66 public:
67   CelestialBody(double Nf, double Ns,
68                 double If, double Is,
69                 double wf, double ws,
70                 double af, double as,
71                 double ef, double es,
72                 double Mf, double Ms, double mjd);
73   CelestialBody(double Nf, double Ns,
74                 double If, double Is,
75                 double wf, double ws,
76                 double af, double as,
77                 double ef, double es,
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);
87 };
88
89 inline double CelestialBody::getRightAscension() { return rightAscension; }
90 inline double CelestialBody::getDeclination() { return declination; }
91 inline double CelestialBody::getMagnitude() { return magnitude; }
92
93 inline double CelestialBody::getLon() const
94 {
95   return lonEcl;
96 }
97
98 inline double CelestialBody::getLat() const
99 {
100   return latEcl;
101 }
102
103 #endif // _CELESTIALBODY_H_
104