]> git.mxchange.org Git - simgear.git/blob - simgear/ephemeris/celestialBody.hxx
Clamp pitch values rather than just dumping an error message.
[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 Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA  02111-1307, USA.
22  *
23  * $Id$
24  **************************************************************************/
25
26
27 #ifndef _CELESTIALBODY_H_
28 #define _CELESTIALBODY_H_
29
30 #ifndef __cplusplus                                                          
31 # error This library requires C++
32 #endif                                   
33
34
35 #include <simgear/constants.h>
36
37 class Star;
38
39 class CelestialBody
40 {
41 protected:              // make the data protected, in order to give the
42                         //  inherited classes direct access to the data
43   double NFirst;        /* longitude of the ascending node first part */
44   double NSec;          /* longitude of the ascending node second part */
45   double iFirst;        /* inclination to the ecliptic first part */
46   double iSec;          /* inclination to the ecliptic second part */
47   double wFirst;        /* first part of argument of perihelion */
48   double wSec;          /* second part of argument of perihelion */
49   double aFirst;        /* semimayor axis first part*/
50   double aSec;          /* semimayor axis second part */
51   double eFirst;        /* eccentricity first part */
52   double eSec;          /* eccentricity second part */
53   double MFirst;        /* Mean anomaly first part */
54   double MSec;          /* Mean anomaly second part */
55
56   double N, i, w, a, e, M; /* the resulting orbital elements, obtained from the former */
57
58   double rightAscension, declination;
59   double r, R, s, FV;
60   double magnitude;
61   double lonEcl, latEcl;
62
63   double sgCalcEccAnom(double M, double e);
64   double sgCalcActTime(double mjd);
65   void updateOrbElements(double mjd);
66
67 public:
68   CelestialBody(double Nf, double Ns,
69                 double If, double Is,
70                 double wf, double ws,
71                 double af, double as,
72                 double ef, double es,
73                 double Mf, double Ms, double mjd);
74   CelestialBody(double Nf, double Ns,
75                 double If, double Is,
76                 double wf, double ws,
77                 double af, double as,
78                 double ef, double es,
79                 double Mf, double Ms);
80   void getPos(double *ra, double *dec);
81   void getPos(double *ra, double *dec, double *magnitude);
82   double getRightAscension();
83   double getDeclination();
84   double getMagnitude();
85   double getLon();
86   double getLat(); 
87   void updatePosition(double mjd, Star *ourSun);
88 };
89
90 inline double CelestialBody::getRightAscension() { return rightAscension; }
91 inline double CelestialBody::getDeclination() { return declination; }
92 inline double CelestialBody::getMagnitude() { return magnitude; }
93
94 inline double CelestialBody::getLon()
95 {
96   return lonEcl;
97 }
98
99 inline double CelestialBody::getLat()
100 {
101   return latEcl;
102 }
103
104 #endif // _CELESTIALBODY_H_
105