]> git.mxchange.org Git - simgear.git/blob - simgear/ephemeris/ephemeris.cxx
Added gdbm to SimGear. Many systems will already have gdbm installed so
[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 program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // 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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 // $Id$
23
24
25 #include "ephemeris.hxx"
26
27
28 // Constructor
29 FGEphemeris::FGEphemeris( const string &path ) {
30     our_sun = new Star;
31     moon = new Moon;
32     mercury = new Mercury;
33     venus = new Venus;
34     mars = new Mars;
35     jupiter = new Jupiter;
36     saturn = new Saturn;
37     uranus = new Uranus;
38     neptune = new Neptune;
39     stars = new FGStars( FGPath(path) );
40 }
41
42
43 // Destructor
44 FGEphemeris::~FGEphemeris( void ) {
45     delete our_sun;
46     delete moon;
47     delete mercury;
48     delete venus;
49     delete mars;
50     delete jupiter;
51     delete saturn;
52     delete uranus;
53     delete neptune;
54     delete stars;
55 }
56
57
58 // Update (recalculate) the positions of all objects for the specified
59 // time
60 void FGEphemeris::update( FGTime *t, double lat ) {
61     // update object positions
62     our_sun->updatePosition( t );
63     moon->updatePosition( t, lat, our_sun );
64     mercury->updatePosition( t, our_sun );
65     venus->updatePosition( t, our_sun );
66     mars->updatePosition( t, our_sun );
67     jupiter->updatePosition( t, our_sun );
68     saturn->updatePosition( t, our_sun );
69     uranus->updatePosition( t, our_sun );
70     neptune->updatePosition( t, our_sun );
71
72     // update planets list
73     nplanets = 7;
74     mercury->getPos( &planets[0][0], &planets[0][1], &planets[0][2] );
75     venus  ->getPos( &planets[1][0], &planets[1][1], &planets[1][2] );
76     mars   ->getPos( &planets[2][0], &planets[2][1], &planets[2][2] );
77     jupiter->getPos( &planets[3][0], &planets[3][1], &planets[3][2] );
78     saturn ->getPos( &planets[4][0], &planets[4][1], &planets[4][2] );
79     uranus ->getPos( &planets[5][0], &planets[5][1], &planets[5][2] );
80     neptune->getPos( &planets[6][0], &planets[6][1], &planets[6][2] );
81 }
82