]> git.mxchange.org Git - simgear.git/blob - simgear/ephemeris/ephemeris.cxx
Merge branch 'next' of git.mxchange.org:/var/cache/git/repos/simgear into next
[simgear.git] / simgear / ephemeris / ephemeris.cxx
1 // ephemeris.cxx -- Top level class for calculating current positions of
2 //                  astronomical objects
3 //
4 // Written by Curtis Olson, started March 2000.
5 //
6 // Copyright (C) 2000  Curtis L. Olson - http://www.flightgear.org/~curt
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 General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 //
22 // $Id$
23
24 #ifdef HAVE_CONFIG_H
25 #  include <simgear_config.h>
26 #endif
27
28 #include <iostream>
29
30 #include "ephemeris.hxx"
31
32
33 // Constructor
34 SGEphemeris::SGEphemeris( const std::string &path ) {
35     our_sun = new Star;
36     moon = new MoonPos;
37     mercury = new Mercury;
38     venus = new Venus;
39     mars = new Mars;
40     jupiter = new Jupiter;
41     saturn = new Saturn;
42     uranus = new Uranus;
43     neptune = new Neptune;
44     nplanets = 7;
45     for ( int i = 0; i < nplanets; ++i )
46       planets[i] = SGVec3d::zeros();
47     stars = new SGStarData( SGPath(path) );
48 }
49
50
51 // Destructor
52 SGEphemeris::~SGEphemeris( void ) {
53     delete our_sun;
54     delete moon;
55     delete mercury;
56     delete venus;
57     delete mars;
58     delete jupiter;
59     delete saturn;
60     delete uranus;
61     delete neptune;
62     delete stars;
63 }
64
65
66 // Update (recalculate) the positions of all objects for the specified
67 // time
68 void SGEphemeris::update( double mjd, double lst, double lat ) {
69     // update object positions
70     our_sun->updatePosition( mjd );
71     moon->updatePosition( mjd, lst, lat, our_sun );
72     mercury->updatePosition( mjd, our_sun );
73     venus->updatePosition( mjd, our_sun );
74     mars->updatePosition( mjd, our_sun );
75     jupiter->updatePosition( mjd, our_sun );
76     saturn->updatePosition( mjd, our_sun );
77     uranus->updatePosition( mjd, our_sun );
78     neptune->updatePosition( mjd, our_sun );
79
80     // update planets list
81     nplanets = 7;
82     mercury->getPos( &planets[0][0], &planets[0][1], &planets[0][2] );
83     venus  ->getPos( &planets[1][0], &planets[1][1], &planets[1][2] );
84     mars   ->getPos( &planets[2][0], &planets[2][1], &planets[2][2] );
85     jupiter->getPos( &planets[3][0], &planets[3][1], &planets[3][2] );
86     saturn ->getPos( &planets[4][0], &planets[4][1], &planets[4][2] );
87     uranus ->getPos( &planets[5][0], &planets[5][1], &planets[5][2] );
88     neptune->getPos( &planets[6][0], &planets[6][1], &planets[6][2] );
89 }
90