From: curt Date: Wed, 12 Dec 2001 05:18:46 +0000 (+0000) Subject: Rename FGInterface::_updatePosition() -> X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=37c2b6002ceef5019ec730935c4235b1c019f018;p=flightgear.git Rename FGInterface::_updatePosition() -> FGInterface::_updateGeocentricPosition() for clarity. Also added an FGInterface::_updateGeodeticPosition() since it is useful. A few clean ups to native_fdm.cxx and raw_fdm.hxx. --- diff --git a/src/FDM/Balloon.cxx b/src/FDM/Balloon.cxx index 4bde1049f..6790df396 100644 --- a/src/FDM/Balloon.cxx +++ b/src/FDM/Balloon.cxx @@ -192,7 +192,7 @@ bool FGBalloonSim::copy_from_BalloonSim() { //temp[1]: longitude //temp[2]: altitude (meters) - _updatePosition( temp[0], temp[1], temp[2] * SG_METER_TO_FEET ); + _updateGeocentricPosition( temp[0], temp[1], temp[2] * SG_METER_TO_FEET ); current_balloon.getHPR( temp ); set_Euler_Angles( temp[0], temp[1], temp[2] ); diff --git a/src/FDM/JSBSim.cxx b/src/FDM/JSBSim.cxx index d37caa6e7..f661c3948 100644 --- a/src/FDM/JSBSim.cxx +++ b/src/FDM/JSBSim.cxx @@ -425,9 +425,9 @@ bool FGJSBsim::copy_from_JSBsim() { _set_Mach_number( Translation->GetMach() ); // Positions - _updatePosition( Position->GetLatitude(), - Position->GetLongitude(), - Position->Geth() ); + _updateGeocentricPosition( Position->GetLatitude(), + Position->GetLongitude(), + Position->Geth() ); _set_Altitude_AGL( Position->GetDistanceAGL() ); diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index 348fe3aa3..9a857c682 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -507,7 +507,60 @@ bool FGInterface::update( int multi_loop ) { } -void FGInterface::_updatePosition( double lat_geoc, double lon, double alt ) { +void FGInterface::_updateGeodeticPosition( double lat, double lon, double alt ) +{ + double lat_geoc, sl_radius; + + // cout << "starting sea level rad = " << get_Sea_level_radius() << endl; + + sgGeodToGeoc( lat, alt * SG_FEET_TO_METER, &sl_radius, &lat_geoc ); + + SG_LOG( SG_FLIGHT, SG_DEBUG, "lon = " << lon + << " lat_geod = " << lat + << " lat_geoc = " << lat_geoc + << " alt = " << alt + << " sl_radius = " << sl_radius * SG_METER_TO_FEET + << " Equator = " << SG_EQUATORIAL_RADIUS_FT ); + + _set_Geocentric_Position( lat_geoc, lon, + sl_radius * SG_METER_TO_FEET + alt ); + + _set_Geodetic_Position( lat, lon, alt ); + + _set_Sea_level_radius( sl_radius * SG_METER_TO_FEET ); + _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET ); + + _set_sin_lat_geocentric( lat_geoc ); + _set_cos_lat_geocentric( lat_geoc ); + + _set_sin_cos_longitude( lon ); + + _set_sin_cos_latitude( lat ); + + /* Norman's code for slope of the terrain */ + /* needs to be tested -- get it on the HUD and taxi around */ + /* double *tnorm = scenery.cur_normal; + + double sy = sin ( -get_Psi() ) ; + double cy = cos ( -get_Psi() ) ; + + double phitb, thetatb, psitb; + if ( tnorm[1] != 0.0 ) { + psitb = -atan2 ( tnorm[0], tnorm[1] ); + } + if ( tnorm[2] != 0.0 ) { + thetatb = atan2 ( tnorm[0] * cy - tnorm[1] * sy, tnorm[2] ); + phitb = -atan2 ( tnorm[1] * cy + tnorm[0] * sy, tnorm[2] ); + } + + _set_terrain_slope(phitb, thetatb, psitb) + */ +} + + +void FGInterface::_updateGeocentricPosition( double lat_geoc, double lon, + double alt ) +{ double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc; // cout << "starting sea level rad = " << get_Sea_level_radius() << endl; diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index 34f8c7a6a..85a5f16ad 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -355,7 +355,8 @@ public: void _setup(); void _busdump(void); - void _updatePosition( double lat_geoc, double lon, double alt ); + void _updateGeodeticPosition( double lat, double lon, double alt ); + void _updateGeocentricPosition( double lat_geoc, double lon, double alt ); void _updateWeather( void ); inline void _set_Inertias( double m, double xx, double yy, diff --git a/src/Network/native_fdm.cxx b/src/Network/native_fdm.cxx index 0c7049c0d..1ffe850c1 100644 --- a/src/Network/native_fdm.cxx +++ b/src/Network/native_fdm.cxx @@ -64,7 +64,7 @@ static void global2raw( const FGInterface *global, FGRawFDM *raw ) { // positions raw->longitude = cur_fdm_state->get_Longitude(); raw->latitude = cur_fdm_state->get_Latitude(); - raw->altitude = cur_fdm_state->get_Altitude(); + raw->altitude = cur_fdm_state->get_Altitude() * SG_FEET_TO_METER; raw->phi = cur_fdm_state->get_Phi(); raw->theta = cur_fdm_state->get_Theta(); raw->psi = cur_fdm_state->get_Psi(); @@ -79,8 +79,10 @@ static void raw2global( const FGRawFDM *raw, FGInterface *global ) { if ( raw->version == FG_RAW_FDM_VERSION ) { // cout << "pos = " << raw->longitude << " " << raw->latitude << endl; // cout << "sea level rad = " << cur_fdm_state->get_Sea_level_radius() << endl; - cur_fdm_state->_updatePosition( raw->latitude, raw->longitude, - raw->altitude * SG_METER_TO_FEET ); + cur_fdm_state->_updateGeodeticPosition( raw->latitude, + raw->longitude, + raw->altitude + * SG_METER_TO_FEET ); cur_fdm_state->_set_Euler_Angles( raw->phi, raw->theta, raw->psi ); diff --git a/src/Network/raw_fdm.hxx b/src/Network/raw_fdm.hxx index e5f8b7ed3..d635458f4 100644 --- a/src/Network/raw_fdm.hxx +++ b/src/Network/raw_fdm.hxx @@ -42,13 +42,13 @@ public: int version; // increment when data values change // Positions - double longitude; // radians - double latitude; // radians - double altitude; // meters (above sea level) - double agl; // meters (altitude above ground level) - double phi; // radians - double theta; // radians - double psi; // radians + double longitude; // geodetic (radians) + double latitude; // geodetic (radians) + double altitude; // above sea level (meters) + double agl; // above ground level (meters) + double phi; // roll (radians) + double theta; // pitch (radians) + double psi; // yaw or true heading (radians) // Velocities double vcas; // calibrated airspeed