]> git.mxchange.org Git - simgear.git/blob - simgear/ephemeris/ephemeris.hxx
Merge branch 'next' of git.mxchange.org:/var/cache/git/repos/simgear into next
[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 #include <string>
33
34 #include <simgear/ephemeris/star.hxx>
35 #include <simgear/ephemeris/moonpos.hxx>
36 #include <simgear/ephemeris/mercury.hxx>
37 #include <simgear/ephemeris/venus.hxx>
38 #include <simgear/ephemeris/mars.hxx>
39 #include <simgear/ephemeris/jupiter.hxx>
40 #include <simgear/ephemeris/saturn.hxx>
41 #include <simgear/ephemeris/uranus.hxx>
42 #include <simgear/ephemeris/neptune.hxx>
43 #include <simgear/ephemeris/stardata.hxx>
44
45 #include <simgear/math/SGMath.hxx>
46 #include <simgear/misc/sg_path.hxx>
47
48
49 /** Ephemeris class
50  *
51  * Written by Durk Talsma <d.talsma@direct.a2000.nl> and Curtis Olson
52  * <http://www.flightgear.org/~curt>
53  *
54  * Introduction 
55  *
56  * The SGEphemeris class computes and stores the positions of the Sun,
57  * the Moon, the planets, and the brightest stars.  These positions
58  * can then be used to accurately render the dominant visible items in
59  * the Earth's sky. Note, this class isn't intended for use in an
60  * interplanetary/interstellar/intergalactic type application. It is
61  * calculates everything relative to the Earth and is therefore best
62  * suited for Earth centric applications.
63  *
64  * The positions of the various astronomical objects are time
65  * dependent, so to maintain accuracy, you will need to periodically
66  * call the update() method. The SGTime class conveniently provides
67  * the two time related values you need to pass to the update()
68  * method.
69  */
70
71 class SGEphemeris {
72
73     Star *our_sun;
74     MoonPos *moon;
75     Mercury *mercury;
76     Venus *venus;
77     Mars *mars;
78     Jupiter *jupiter;
79     Saturn *saturn;
80     Uranus *uranus;
81     Neptune *neptune;
82
83     // 9 planets, minus earth, minus pluto which we don't draw = 7
84     // planets[i][0] = Right Ascension
85     // planets[i][1] = Declination
86     // planets[i][2] = Magnitude
87     int nplanets;
88     SGVec3d planets[7];
89
90     SGStarData *stars;
91
92 public:
93
94     /**
95      * Constructor.
96      * This creates an instance of the SGEphemeris object. When
97      * calling the constructor you need to provide a path pointing to
98      * your star database file.
99      * @param path path to your star database */
100     SGEphemeris( const std::string &path );
101
102     /** Destructor */
103     ~SGEphemeris( void );
104
105     /**
106      * Update (recalculate) the positions of all objects for the
107      * specified time.  The update() method requires you to pass in
108      * the current modified Julian date, the current local sidereal
109      * time, and the current latitude. The update() method is designed
110      * to be called by the host application before every frame.
111      * @param mjd modified julian date
112      * @param lst current local sidereal time
113      * @param lat current latitude
114      */
115     void update(double mjd, double lst, double lat);
116
117     /**
118      * @return a pointer to a Star class containing all the positional
119      * information for Earth's Sun.
120      */
121     inline Star *get_sun() const { return our_sun; }
122
123     /** @return the right ascension of the Sun. */
124     inline double getSunRightAscension() const {
125         return our_sun->getRightAscension();
126     }
127
128     /** @return the declination of the Sun. */
129     inline double getSunDeclination() const {
130         return our_sun->getDeclination();
131     }
132
133     /**
134      * @return a pointer to a Moon class containing all the positional
135      * information for Earth's Moon.
136      */
137     inline MoonPos *get_moon() const { return moon; }
138
139     /** @return the right ascension of the Moon. */
140     inline double getMoonRightAscension() const {
141         return moon->getRightAscension();
142     }
143
144     /** @return the declination of the Moon. */
145     inline double getMoonDeclination() const {
146         return moon->getDeclination();
147     }
148
149     /** @return the numbers of defined planets. */
150     inline int getNumPlanets() const { return nplanets; }
151
152     /**
153      * Returns a pointer to an array of planet data in sgdVec3
154      * format. (See plib.sourceforge.net for information on plib and
155      * the ``sg'' package.) An sgdVec3 is a 3 element double
156      * array. The first element is the right ascension of the planet,
157      * the second is the declination, and the third is the magnitude.
158      * @return planets array
159      */
160     inline SGVec3d *getPlanets() { return planets; }
161     inline const SGVec3d *getPlanets() const { return planets; }
162
163     /** @return the numbers of defined stars. */
164     inline int getNumStars() const { return stars->getNumStars(); }
165
166     /**
167      * Returns a pointer to an array of star data in sgdVec3
168      * format. An The first element of the sgdVec3 is the right
169      * ascension of the planet, the second is the declination, and the
170      * third is the magnitude.
171      * @returns star array
172      */
173     inline SGVec3d *getStars() { return stars->getStars(); }
174     inline const SGVec3d *getStars() const { return stars->getStars(); }
175 };
176
177
178 #endif // _EPHEMERIS_HXX
179
180