]> git.mxchange.org Git - simgear.git/blob - simgear/ephemeris/ephemeris.cxx
Tweaks to follow flightgear STL standard coding procedure.
[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 - curt@flightgear.org
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 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.
22 //
23 // $Id$
24
25
26 #include "ephemeris.hxx"
27
28
29 // Constructor
30 SGEphemeris::SGEphemeris( const string &path ) {
31     our_sun = new Star;
32     moon = new MoonPos;
33     mercury = new Mercury;
34     venus = new Venus;
35     mars = new Mars;
36     jupiter = new Jupiter;
37     saturn = new Saturn;
38     uranus = new Uranus;
39     neptune = new Neptune;
40     stars = new SGStarData( FGPath(path) );
41 }
42
43
44 // Destructor
45 SGEphemeris::~SGEphemeris( void ) {
46     delete our_sun;
47     delete moon;
48     delete mercury;
49     delete venus;
50     delete mars;
51     delete jupiter;
52     delete saturn;
53     delete uranus;
54     delete neptune;
55     delete stars;
56 }
57
58
59 // Update (recalculate) the positions of all objects for the specified
60 // time
61 void SGEphemeris::update( double mjd, double lst, double lat ) {
62     // update object positions
63     our_sun->updatePosition( mjd );
64     moon->updatePosition( mjd, lst, lat, our_sun );
65     mercury->updatePosition( mjd, our_sun );
66     venus->updatePosition( mjd, our_sun );
67     mars->updatePosition( mjd, our_sun );
68     jupiter->updatePosition( mjd, our_sun );
69     saturn->updatePosition( mjd, our_sun );
70     uranus->updatePosition( mjd, our_sun );
71     neptune->updatePosition( mjd, our_sun );
72
73     // update planets list
74     nplanets = 7;
75     mercury->getPos( &planets[0][0], &planets[0][1], &planets[0][2] );
76     venus  ->getPos( &planets[1][0], &planets[1][1], &planets[1][2] );
77     mars   ->getPos( &planets[2][0], &planets[2][1], &planets[2][2] );
78     jupiter->getPos( &planets[3][0], &planets[3][1], &planets[3][2] );
79     saturn ->getPos( &planets[4][0], &planets[4][1], &planets[4][2] );
80     uranus ->getPos( &planets[5][0], &planets[5][1], &planets[5][2] );
81     neptune->getPos( &planets[6][0], &planets[6][1], &planets[6][2] );
82 }
83