//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] );
_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() );
}
-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;
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,
// 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();
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 );
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