$(top_builddir)/src/Sky/libSky.a \
$(top_builddir)/src/Joystick/libJoystick.a \
$(SERIAL_LIBS) \
- -lsgscreen -lsgmath -lsgbucket -lsgdebug -lsgmisc \
+ -lsgscreen -lsgmath -lsgbucket -lsgdebug -lsgmagvar -lsgmisc \
-lplibpu -lplibfnt -lplibssg -lplibsg \
-lz \
$(opengl_LIBS) \
current_options.set_time_offset_type(fgOPTIONS::FG_TIME_GMT_ABSOLUTE);
FGTime::cur_time_params->init( cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude() );
- FGTime::cur_time_params->update( cur_fdm_state->get_Longitude() );
+ FGTime::cur_time_params->update( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Latitude(),
+ cur_fdm_state->get_Altitude()
+ * FEET_TO_METER );
needReinit();
}
}
+\f
+////////////////////////////////////////////////////////////////////////
+// Time
+////////////////////////////////////////////////////////////////////////
+
+/**
+ * Return the magnetic variation
+ */
+double
+FGBFI::getMagVar ()
+{
+ return FGTime::cur_time_params->getMagVar() * RAD_TO_DEG;
+}
+
+
+/**
+ * Return the magnetic variation
+ */
+double
+FGBFI::getMagDip ()
+{
+ return FGTime::cur_time_params->getMagDip() * RAD_TO_DEG;
+}
+
+
// end of bfi.cxx
+
static void setVisibility (double visiblity);
+ // Time (this varies with time) huh, huh
+ static double getMagVar ();
+ static double getMagDip ();
+
private:
// Will cause a linking error if invoked.
cur_fdm_state->get_Altitude() * FEET_TO_METER); */
// update "time"
- t->update( cur_fdm_state->get_Longitude() );
+ t->update( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Latitude(),
+ cur_fdm_state->get_Altitude()* FEET_TO_METER );
// Get elapsed time (in usec) for this past frame
elapsed = fgGetTimeInterval();
// cur_fdm_state->get_Latitude() );
// FGTime::cur_time_params->update( cur_fdm_state->get_Longitude() );
FGTime::cur_time_params->init( 0.0, 0.0 );
- FGTime::cur_time_params->update( 0.0 );
+ FGTime::cur_time_params->update( 0.0, 0.0, 0.0 );
// Do some quick general initializations
if( !fgInitGeneral()) {
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
+#include <simgear/magvar/magvar.hxx>
#include <simgear/misc/fgpath.hxx>
#include <FDM/flight.hxx>
// Update time variables such as gmt, julian date, and sidereal time
-void FGTime::update( double lon ) {
+void FGTime::update( double lon, double lat, double alt_m ) {
double gst_precise, gst_course;
FG_LOG( FG_EVENT, FG_DEBUG, "Updating time" );
gst = sidereal_course( 0.00 ) + gst_diff;
lst = sidereal_course( -(lon * RAD_TO_DEG)) + gst_diff;
}
+
+ // Calculate local magnetic variation
+ double field[6];
+ // cout << "alt_m = " << alt_m << endl;
+ magvar = SGMagVar( lat, lon, alt_m / 1000.0, jd, field );
+ magdip = atan(field[5]/pow(field[3]*field[3]+field[4]*field[4],0.5));
+
FG_LOG( FG_EVENT, FG_DEBUG,
" Current lon=0.00 Sidereal Time = " << gst );
FG_LOG( FG_EVENT, FG_DEBUG,
// Paused?
bool pause;
-
+
+ // Local magnetic variation and dip in radians
+ double magvar;
+ double magdip;
+
void local_update_sky_and_lighting_params( void );
public:
FGTime();
~FGTime();
+ inline double getJD() const { return jd; };
inline double getMjd() const { return mjd; };
inline double getLst() const { return lst; };
inline double getGst() const { return gst; };
void init( double lon, double lat );
// Update the time dependent variables
- void update( double lon );
+ void update( double lon, double lat, double alt_m );
void updateLocal();
void cal_mjd (int mn, double dy, int yr);
char* format_time( const struct tm* p, char* buf );
long int fix_up_timezone( long int timezone_orig );
+
+ // Return magnetic variations
+ double getMagVar() const { return magvar; }
+ double getMagDip() const { return magdip; }
};