]> git.mxchange.org Git - flightgear.git/commitdiff
Tweaks to reduce module interdependencies.
authorcurt <curt>
Thu, 16 Mar 2000 04:18:24 +0000 (04:18 +0000)
committercurt <curt>
Thu, 16 Mar 2000 04:18:24 +0000 (04:18 +0000)
Additional sun and moon position values calculated from new FGEphemeris class.

src/Time/fg_time.cxx
src/Time/fg_time.hxx
src/Time/moonpos.cxx
src/Time/sunpos.cxx

index 21379092c0d3a7a393095062f1851a0272fab9a9..32ce53063b881f0cbd82cc21ae7ec18c78494c69 100644 (file)
@@ -61,6 +61,8 @@
 #include "fg_time.hxx"
 #include "timezone.h"
 #include "lowleveltime.h"
+#include "moonpos.hxx"
+#include "sunpos.hxx"
 
 
 #define DEGHR(x)        ((x)/15.)
@@ -121,8 +123,7 @@ void FGTime::updateLocal()
 
 // Initialize the time dependent variables (maybe I'll put this in the
 // constructor later)
-void FGTime::init(const FGInterface& f) 
-{
+void FGTime::init( double lon, double lat ) {
     FG_LOG( FG_EVENT, FG_INFO, "Initializing Time" );
     gst_diff = -9999.0;
     FG_LOG( FG_EVENT, FG_DEBUG, 
@@ -142,8 +143,7 @@ void FGTime::init(const FGInterface& f)
     // printf ("Current greenwich mean time = %24s", asctime(gmtime(&cur_time)));
     // printf ("Current local time          = %24s", asctime(localtime(&cur_time)));
     // time_t tmp = cur_time;
-    GeoCoord location(RAD_TO_DEG * f.get_Latitude(), 
-                     RAD_TO_DEG * f.get_Longitude());
+    GeoCoord location( RAD_TO_DEG * lat, RAD_TO_DEG * lon );
 
     GeoCoord* nearestTz = tzContainer->getNearest(location);
 
@@ -337,8 +337,7 @@ double FGTime::sidereal_course(double lng)
 
 
 // Update time variables such as gmt, julian date, and sidereal time
-void FGTime::update(const FGInterface& f) 
-{
+void FGTime::update( double lon ) {
     double gst_precise, gst_course;
 
     FG_LOG( FG_EVENT, FG_DEBUG, "Updating time" );
@@ -389,17 +388,17 @@ void FGTime::update(const FGInterface& f)
       
        gst_diff = gst_precise - gst_course;
 
-       lst = sidereal_course(-(f.get_Longitude() * RAD_TO_DEG)) + gst_diff;
+       lst = sidereal_course(-(lon * RAD_TO_DEG)) + gst_diff;
     } else {
        // course + difference should drift off very slowly
-       gst = sidereal_course( 0.00                              ) + gst_diff;
-       lst = sidereal_course( -(f.get_Longitude() * RAD_TO_DEG)) + gst_diff;
+       gst = sidereal_course( 0.00 ) + gst_diff;
+       lst = sidereal_course( -(lon * RAD_TO_DEG)) + gst_diff;
     }
     FG_LOG( FG_EVENT, FG_DEBUG,
            "  Current lon=0.00 Sidereal Time = " << gst );
     FG_LOG( FG_EVENT, FG_DEBUG,
            "  Current LOCAL Sidereal Time = " << lst << " (" 
-           << sidereal_precise(-(f.get_Longitude() * RAD_TO_DEG)) 
+           << sidereal_precise(-(lon * RAD_TO_DEG)) 
            << ") (diff = " << gst_diff << ")" );
 }
 
@@ -530,12 +529,9 @@ char* FGTime::format_time( const struct tm* p, char* buf )
 
 // Force an update of the sky and lighting parameters
 void FGTime::local_update_sky_and_lighting_params( void ) {
-    // fgSunInit();
-    SolarSystem::theSolarSystem->rebuild();
+    fgUpdateSunPos();
+    fgUpdateMoonPos();
     cur_light_params.Update();
-    /* current_sky.repaint( cur_light_params.sky_color,
-                        cur_light_params.fog_color,
-                        cur_light_params.sun_angle ); */
 }
 
 
index d73c58f3394f6964811deeef507b8274ad54d9cc..bc97a7bd18f6d33cc4691484e6e6e3b0054e48c4 100644 (file)
@@ -122,10 +122,10 @@ public:
     void togglePauseMode() { pause = !pause; }; 
 
     // Initialize the time dependent variables
-    void init(const FGInterface& f);
+    void init( double lon, double lat );
 
     // Update the time dependent variables
-    void update(const FGInterface& f);
+    void update( double lon );
     void updateLocal();
 
     void cal_mjd (int mn, double dy, int yr);
index 2c64927c9421e783a2c645c3b9afc7cc47a40e19..7f0512e525590b9f8770c0e94038f3aa4200e7a7 100644 (file)
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/vector.hxx>
 
-#include <Astro/solarsystem.hxx>
+#include <Astro/ephemeris.hxx>
 #include <Main/views.hxx>
 #include <Scenery/scenery.hxx>
 
 #include "fg_time.hxx"
 #include "moonpos.hxx"
 
-extern SolarSystem *solarSystem;
+// extern SolarSystem *solarSystem;
+extern FGEphemeris *ephem;
 
 #undef E
 
@@ -282,7 +283,7 @@ void fgMoonPosition(time_t ssue, double *lon, double *lat) {
      * every ten minutes. (Comment added by Durk Talsma).
      ************************************************************************/
 
-    ecliptic_to_equatorial( SolarSystem::theSolarSystem->getMoon()->getLon(),
+    ecliptic_to_equatorial( ephem->get_moon()->getLon(),
                            0.0, &alpha, &delta );
     tmp = alpha - (FG_2PI/24)*GST(ssue);
     if (tmp < -FG_PI) {
@@ -314,8 +315,8 @@ static void fgMoonPositionGST(double gst, double *lon, double *lat) {
     /* lambda = moon_ecliptic_longitude(ssue); */
     /* ecliptic_to_equatorial(lambda, 0.0, &alpha, &delta); */
     //ecliptic_to_equatorial (solarPosition.lonMoon, 0.0, &alpha, &delta);
-    ecliptic_to_equatorial( SolarSystem::theSolarSystem->getMoon()->getLon(),
-                           SolarSystem::theSolarSystem->getMoon()->getLat(), 
+    ecliptic_to_equatorial( ephem->get_moon()->getLon(),
+                           ephem->get_moon()->getLat(), 
                            &alpha,  &delta );
 
 //    tmp = alpha - (FG_2PI/24)*GST(ssue);
index 07d943ca8fde4732dab89cac9eaa51ab0bed29cc..2ba54b7473be94e58f7c39835955dacf650f4140 100644 (file)
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/vector.hxx>
 
-#include <Astro/solarsystem.hxx>
+#include <Astro/ephemeris.hxx>
 #include <Main/views.hxx>
 #include <Scenery/scenery.hxx>
 
 #include "fg_time.hxx"
 #include "sunpos.hxx"
 
-extern SolarSystem *solarSystem;
+// extern SolarSystem *solarSystem;
+extern FGEphemeris *ephem;
 
 #undef E
 #define MeanObliquity (23.440592*(FG_2PI/360))
@@ -188,7 +189,7 @@ void fgSunPosition(time_t ssue, double *lon, double *lat) {
      * every ten minutes. (Comment added by Durk Talsma).
      ************************************************************************/
 
-    ecliptic_to_equatorial( SolarSystem::theSolarSystem->getSun()->getLon(),
+    ecliptic_to_equatorial( ephem->get_sun()->getLon(),
                            0.0, &alpha, &delta );
     tmp = alpha - (FG_2PI/24)*GST(ssue);
     if (tmp < -FG_PI) {
@@ -220,9 +221,9 @@ static void fgSunPositionGST(double gst, double *lon, double *lat) {
     /* lambda = sun_ecliptic_longitude(ssue); */
     /* ecliptic_to_equatorial(lambda, 0.0, &alpha, &delta); */
     //ecliptic_to_equatorial (solarPosition.lonSun, 0.0, &alpha, &delta);
-    ecliptic_to_equatorial( SolarSystem::theSolarSystem->getSun()->getLon(),
-                           SolarSystem::theSolarSystem->getSun()->getLat(),
-                           &alpha,  &delta );
+    ecliptic_to_equatorial( ephem->get_sun()->getLon(),
+                           ephem->get_sun()->getLat(),
+                           &alpha, &delta );
 
 //    tmp = alpha - (FG_2PI/24)*GST(ssue);
     tmp = alpha - (FG_2PI/24)*gst;