]> git.mxchange.org Git - simgear.git/blob - simgear/ephemeris/ephemeris.hxx
Modified Files:
[simgear.git] / simgear / ephemeris / ephemeris.hxx
1 /** \file ephemeris.hxx
2  * Top level class for calculating current positions of astronomical objects.
3  */
4
5 // Top level interface written by Curtis Olson, started March 2000.
6 //
7 // All the core code underneath this is written by Durk Talsma.  See
8 // the headers of all the other individual files for details.
9 //
10 // Copyright (C) 2000  Curtis L. Olson - http://www.flightgear.org/~curt
11 //
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Library General Public
14 // License as published by the Free Software Foundation; either
15 // version 2 of the License, or (at your option) any later version.
16 //
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 // Library General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
25 //
26 // $Id$
27
28
29 #ifndef _EPHEMERIS_HXX
30 #define _EPHEMERIS_HXX
31
32
33 #include <plib/sg.h>
34
35 #include <simgear/ephemeris/star.hxx>
36 #include <simgear/ephemeris/moonpos.hxx>
37 #include <simgear/ephemeris/mercury.hxx>
38 #include <simgear/ephemeris/venus.hxx>
39 #include <simgear/ephemeris/mars.hxx>
40 #include <simgear/ephemeris/jupiter.hxx>
41 #include <simgear/ephemeris/saturn.hxx>
42 #include <simgear/ephemeris/uranus.hxx>
43 #include <simgear/ephemeris/neptune.hxx>
44 #include <simgear/ephemeris/stardata.hxx>
45
46
47 /** Ephemeris class
48  *
49  * Written by Durk Talsma <d.talsma@direct.a2000.nl> and Curtis Olson
50  * <http://www.flightgear.org/~curt>
51  *
52  * Introduction 
53  *
54  * The SGEphemeris class computes and stores the positions of the Sun,
55  * the Moon, the planets, and the brightest stars.  These positions
56  * can then be used to accurately render the dominant visible items in
57  * the Earth's sky. Note, this class isn't intended for use in an
58  * interplanetary/interstellar/intergalactic type application. It is
59  * calculates everything relative to the Earth and is therefore best
60  * suited for Earth centric applications.
61  *
62  * The positions of the various astronomical objects are time
63  * dependent, so to maintain accuracy, you will need to periodically
64  * call the update() method. The SGTime class conveniently provides
65  * the two time related values you need to pass to the update()
66  * method.
67  */
68
69 class SGEphemeris {
70
71     Star *our_sun;
72     MoonPos *moon;
73     Mercury *mercury;
74     Venus *venus;
75     Mars *mars;
76     Jupiter *jupiter;
77     Saturn *saturn;
78     Uranus *uranus;
79     Neptune *neptune;
80
81     // 9 planets, minus earth, minus pluto which we don't draw = 7
82     // planets[i][0] = Right Ascension
83     // planets[i][1] = Declination
84     // planets[i][2] = Magnitude
85     int nplanets;
86     SGVec3d planets[7];
87
88     SGStarData *stars;
89
90 public:
91
92     /**
93      * Constructor.
94      * This creates an instance of the SGEphemeris object. When
95      * calling the constructor you need to provide a path pointing to
96      * your star database file.
97      * @param path path to your star database */
98     SGEphemeris( const string &path );
99
100     /** Destructor */
101     ~SGEphemeris( void );
102
103     /**
104      * Update (recalculate) the positions of all objects for the
105      * specified time.  The update() method requires you to pass in
106      * the current modified Julian date, the current local sidereal
107      * time, and the current latitude. The update() method is designed
108      * to be called by the host application before every frame.
109      * @param mjd modified julian date
110      * @param lst current local sidereal time
111      * @param lat current latitude
112      */
113     void update(double mjd, double lst, double lat);
114
115     /**
116      * @return a pointer to a Star class containing all the positional
117      * information for Earth's Sun.
118      */
119     inline Star *get_sun() const { return our_sun; }
120
121     /** @return the right ascension of the Sun. */
122     inline double getSunRightAscension() const {
123         return our_sun->getRightAscension();
124     }
125
126     /** @return the declination of the Sun. */
127     inline double getSunDeclination() const {
128         return our_sun->getDeclination();
129     }
130
131     /**
132      * @return a pointer to a Moon class containing all the positional
133      * information for Earth's Moon.
134      */
135     inline MoonPos *get_moon() const { return moon; }
136
137     /** @return the right ascension of the Moon. */
138     inline double getMoonRightAscension() const {
139         return moon->getRightAscension();
140     }
141
142     /** @return the declination of the Moon. */
143     inline double getMoonDeclination() const {
144         return moon->getDeclination();
145     }
146
147     /** @return the numbers of defined planets. */
148     inline int getNumPlanets() const { return nplanets; }
149
150     /**
151      * Returns a pointer to an array of planet data in sgdVec3
152      * format. (See plib.sourceforge.net for information on plib and
153      * the ``sg'' package.) An sgdVec3 is a 3 element double
154      * array. The first element is the right ascension of the planet,
155      * the second is the declination, and the third is the magnitude.
156      * @return planets array
157      */
158     inline SGVec3d *getPlanets() { return planets; }
159
160     /** @return the numbers of defined stars. */
161     inline int getNumStars() const { return stars->getNumStars(); }
162
163     /**
164      * Returns a pointer to an array of star data in sgdVec3
165      * format. An The first element of the sgdVec3 is the right
166      * ascension of the planet, the second is the declination, and the
167      * third is the magnitude.
168      * @returns star array
169      */
170     inline SGVec3d *getStars() { return stars->getStars(); }
171 };
172
173
174 #endif // _EPHEMERIS_HXX
175
176