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