1 // ephemeris.cxx -- Top level class for calculating current positions of
2 // astronomical objects
4 // Written by Curtis Olson, started March 2000.
6 // Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
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.
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.
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.
26 # include <simgear_config.h>
31 #include "ephemeris.hxx"
35 SGEphemeris::SGEphemeris( const string &path ) {
38 mercury = new Mercury;
41 jupiter = new Jupiter;
44 neptune = new Neptune;
46 for ( int i = 0; i < nplanets; ++i ) {
47 sgdSetVec3( planets[i], 0.0, 0.0, 0.0 );
49 stars = new SGStarData( SGPath(path) );
54 SGEphemeris::~SGEphemeris( void ) {
68 // Update (recalculate) the positions of all objects for the specified
70 void SGEphemeris::update( double mjd, double lst, double lat ) {
71 // update object positions
72 our_sun->updatePosition( mjd );
73 moon->updatePosition( mjd, lst, lat, our_sun );
74 mercury->updatePosition( mjd, our_sun );
75 venus->updatePosition( mjd, our_sun );
76 mars->updatePosition( mjd, our_sun );
77 jupiter->updatePosition( mjd, our_sun );
78 saturn->updatePosition( mjd, our_sun );
79 uranus->updatePosition( mjd, our_sun );
80 neptune->updatePosition( mjd, our_sun );
82 // update planets list
84 mercury->getPos( &planets[0][0], &planets[0][1], &planets[0][2] );
85 venus ->getPos( &planets[1][0], &planets[1][1], &planets[1][2] );
86 mars ->getPos( &planets[2][0], &planets[2][1], &planets[2][2] );
87 jupiter->getPos( &planets[3][0], &planets[3][1], &planets[3][2] );
88 saturn ->getPos( &planets[4][0], &planets[4][1], &planets[4][2] );
89 uranus ->getPos( &planets[5][0], &planets[5][1], &planets[5][2] );
90 neptune->getPos( &planets[6][0], &planets[6][1], &planets[6][2] );