Updated for magvar calculations.
This commit is contained in:
parent
dec30d2090
commit
19d2b1a314
6 changed files with 59 additions and 7 deletions
|
@ -66,7 +66,7 @@ fgfs_LDADD = \
|
|||
$(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) \
|
||||
|
|
|
@ -198,7 +198,10 @@ FGBFI::setTimeGMT (time_t time)
|
|||
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();
|
||||
}
|
||||
|
||||
|
@ -848,4 +851,30 @@ FGBFI::setVisibility (double visibility)
|
|||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
||||
|
|
|
@ -139,6 +139,10 @@ public:
|
|||
|
||||
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.
|
||||
|
|
|
@ -830,7 +830,9 @@ static void fgMainLoop( void ) {
|
|||
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();
|
||||
|
@ -1332,7 +1334,7 @@ int main( int argc, char **argv ) {
|
|||
// 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()) {
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/magvar/magvar.hxx>
|
||||
#include <simgear/misc/fgpath.hxx>
|
||||
|
||||
#include <FDM/flight.hxx>
|
||||
|
@ -336,7 +337,7 @@ double FGTime::sidereal_course(double lng)
|
|||
|
||||
|
||||
// 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" );
|
||||
|
@ -393,6 +394,13 @@ void FGTime::update( double lon ) {
|
|||
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,
|
||||
|
|
|
@ -103,6 +103,10 @@ private:
|
|||
// Paused?
|
||||
bool pause;
|
||||
|
||||
// Local magnetic variation and dip in radians
|
||||
double magvar;
|
||||
double magdip;
|
||||
|
||||
void local_update_sky_and_lighting_params( void );
|
||||
|
||||
public:
|
||||
|
@ -110,6 +114,7 @@ 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; };
|
||||
|
@ -125,7 +130,7 @@ public:
|
|||
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);
|
||||
|
@ -143,6 +148,10 @@ public:
|
|||
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue