Updated to eliminate rendering component and allow initialization without a

known time.
This commit is contained in:
curt
2000-03-16 03:00:58 +00:00
parent 80cf74d85f
commit 09b67e9440
18 changed files with 138 additions and 7 deletions

View File

@@ -87,8 +87,8 @@ void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
ze = yg * sin(ecl) + zg * cos(ecl);
rightAscension = atan2(ye, xe);
declination = atan2(ze, sqrt(xe*xe + ye*ye));
FG_LOG(FG_GENERAL, FG_INFO, "Planet found at : "
<< rightAscension << " (ra), " << declination << " (dec)" );
/* FG_LOG(FG_GENERAL, FG_INFO, "Planet found at : "
<< rightAscension << " (ra), " << declination << " (dec)" ); */
//calculate some variables specific to calculating the magnitude
//of the planet

View File

@@ -29,6 +29,13 @@
FGEphemeris::FGEphemeris( void ) {
our_sun = new Star;
moon = new Moon;
mercury = new Mercury;
venus = new Venus;
mars = new Mars;
jupiter = new Jupiter;
saturn = new Saturn;
uranus = new Uranus;
neptune = new Neptune;
}
@@ -36,13 +43,38 @@ FGEphemeris::FGEphemeris( void ) {
FGEphemeris::~FGEphemeris( void ) {
delete our_sun;
delete moon;
delete mercury;
delete venus;
delete mars;
delete jupiter;
delete saturn;
delete uranus;
delete neptune;
}
// Update (recalculate) the positions of all objects for the specified
// time
void FGEphemeris::update( FGTime *t ) {
// update object positions
our_sun->updatePosition( t );
moon->updatePosition( t, our_sun );
mercury->updatePosition( t, our_sun );
venus->updatePosition( t, our_sun );
mars->updatePosition( t, our_sun );
jupiter->updatePosition( t, our_sun );
saturn->updatePosition( t, our_sun );
uranus->updatePosition( t, our_sun );
neptune->updatePosition( t, our_sun );
// update planets list
mercury->getPos( &planets[0][0], &planets[0][1], &planets[0][2] );
venus ->getPos( &planets[1][0], &planets[1][1], &planets[1][2] );
mars ->getPos( &planets[2][0], &planets[2][1], &planets[2][2] );
jupiter->getPos( &planets[3][0], &planets[3][1], &planets[3][2] );
saturn ->getPos( &planets[4][0], &planets[4][1], &planets[4][2] );
uranus ->getPos( &planets[5][0], &planets[5][1], &planets[5][2] );
neptune->getPos( &planets[6][0], &planets[6][1], &planets[6][2] );
}

View File

@@ -26,16 +26,38 @@
#define _EPHEMERIS_HXX
#include <plib/sg.h>
#include <Time/fg_time.hxx>
#include "star.hxx"
#include "moon.hxx"
#include "mercury.hxx"
#include "venus.hxx"
#include "mars.hxx"
#include "jupiter.hxx"
#include "saturn.hxx"
#include "uranus.hxx"
#include "neptune.hxx"
class FGEphemeris {
Star *our_sun;
Moon *moon;
Mercury *mercury;
Venus *venus;
Mars *mars;
Jupiter *jupiter;
Saturn *saturn;
Uranus *uranus;
Neptune *neptune;
// 9 planets - earth - pluto which we don't draw = 7
// planets[i][0] = Right Ascension
// planets[i][1] = Declination
// planets[i][2] = Magnitude
sgdVec3 planets[7];
public:
@@ -50,20 +72,25 @@ public:
void update(FGTime *t);
// sun position
inline double getSunRightAscension() {
inline double getSunRightAscension() const {
return our_sun->getRightAscension();
}
inline double getSunDeclination() {
inline double getSunDeclination() const {
return our_sun->getDeclination();
}
// moon position
inline double getMoonRightAscension() {
inline double getMoonRightAscension() const {
return moon->getRightAscension();
}
inline double getMoonDeclination() {
inline double getMoonDeclination() const {
return moon->getDeclination();
}
// planets
inline sgdVec3 *getPlanets() const {
return planets;
}
};

View File

@@ -47,6 +47,16 @@ Jupiter::Jupiter(FGTime *t) :
{
}
Jupiter::Jupiter() :
CelestialBody(100.4542, 2.7685400E-5,
1.3030, -1.557E-7,
273.8777, 1.6450500E-5,
5.2025600, 0.000000,
0.048498, 4.469E-9,
19.89500, 0.08308530010)
{
}
/*************************************************************************
* void Jupiter::updatePosition(FGTime *t, Star *ourSun)
*

View File

@@ -32,6 +32,7 @@ class Jupiter : public CelestialBody
{
public:
Jupiter (FGTime *t);
Jupiter ();
void updatePosition(FGTime *t, Star *ourSun);
};

View File

@@ -45,6 +45,15 @@ Mars::Mars(FGTime *t) :
18.60210, 0.52402077660, t)
{
}
Mars::Mars() :
CelestialBody(49.55740, 2.1108100E-5,
1.8497, -1.78E-8,
286.5016, 2.9296100E-5,
1.5236880, 0.000000,
0.093405, 2.516E-9,
18.60210, 0.52402077660)
{
}
/*************************************************************************
* void Mars::updatePosition(FGTime *t, Star *ourSun)
*

View File

@@ -32,6 +32,7 @@ class Mars : public CelestialBody
{
public:
Mars ( FGTime *t);
Mars ();
void updatePosition(FGTime *t, Star *ourSun);
};

View File

@@ -45,6 +45,15 @@ Mercury::Mercury(FGTime *t) :
168.6562, 4.09233443680, t)
{
}
Mercury::Mercury() :
CelestialBody (48.33130, 3.2458700E-5,
7.0047, 5.00E-8,
29.12410, 1.0144400E-5,
0.3870980, 0.000000,
0.205635, 5.59E-10,
168.6562, 4.09233443680)
{
}
/*************************************************************************
* void Mercury::updatePosition(FGTime *t, Star *ourSun)
*

View File

@@ -32,6 +32,7 @@ class Mercury : public CelestialBody
{
public:
Mercury ( FGTime *t);
Mercury ();
void updatePosition(FGTime *t, Star* ourSun);
};

View File

@@ -45,6 +45,15 @@ Neptune::Neptune(FGTime *t) :
260.2471, 0.00599514700, t)
{
}
Neptune::Neptune() :
CelestialBody(131.7806, 3.0173000E-5,
1.7700, -2.550E-7,
272.8461, -6.027000E-6,
30.058260, 3.313E-8,
0.008606, 2.150E-9,
260.2471, 0.00599514700)
{
}
/*************************************************************************
* void Neptune::updatePosition(FGTime *t, Star *ourSun)
*

View File

@@ -32,6 +32,7 @@ class Neptune : public CelestialBody
{
public:
Neptune ( FGTime *t);
Neptune ();
void updatePosition(FGTime *t, Star *ourSun);
};

View File

@@ -30,7 +30,8 @@
class Pluto : public CelestialBody
{
public:
Pluto ( FGTime t);
Pluto ( FGTime *t);
Pluto ();
};
#endif // _PLUTO_HXX_

View File

@@ -45,6 +45,15 @@ Saturn::Saturn(FGTime *t) :
316.9670, 0.03344422820, t)
{
}
Saturn::Saturn() :
CelestialBody(113.6634, 2.3898000E-5,
2.4886, -1.081E-7,
339.3939, 2.9766100E-5,
9.5547500, 0.000000,
0.055546, -9.499E-9,
316.9670, 0.03344422820)
{
}
/*************************************************************************
* void Saturn::updatePosition(FGTime *t, Star *ourSun)

View File

@@ -32,6 +32,7 @@ class Saturn : public CelestialBody
{
public:
Saturn ( FGTime *t);
Saturn ();
void updatePosition(FGTime *t, Star *ourSun);
};

View File

@@ -45,6 +45,15 @@ Uranus::Uranus(FGTime *t) :
142.5905, 0.01172580600, t)
{
}
Uranus::Uranus() :
CelestialBody(74.00050, 1.3978000E-5,
0.7733, 1.900E-8,
96.66120, 3.0565000E-5,
19.181710, -1.55E-8,
0.047318, 7.450E-9,
142.5905, 0.01172580600)
{
}
/*************************************************************************
* void Uranus::updatePosition(FGTime *t, Star *ourSun)

View File

@@ -32,6 +32,7 @@ class Uranus : public CelestialBody
{
public:
Uranus ( FGTime *t);
Uranus ();
void updatePosition(FGTime *t, Star *ourSun);
};

View File

@@ -45,6 +45,15 @@ Venus::Venus(FGTime *t) :
48.00520, 1.60213022440, t)
{
}
Venus::Venus() :
CelestialBody(76.67990, 2.4659000E-5,
3.3946, 2.75E-8,
54.89100, 1.3837400E-5,
0.7233300, 0.000000,
0.006773, -1.302E-9,
48.00520, 1.60213022440)
{
}
/*************************************************************************
* void Venus::updatePosition(FGTime *t, Star *ourSun)

View File

@@ -32,6 +32,7 @@ class Venus : public CelestialBody
{
public:
Venus ( FGTime *t);
Venus ();
void updatePosition(FGTime *t, Star *ourSun);
};