]> git.mxchange.org Git - flightgear.git/commitdiff
Rename FGInterface::_updatePosition() ->
authorcurt <curt>
Wed, 12 Dec 2001 05:18:46 +0000 (05:18 +0000)
committercurt <curt>
Wed, 12 Dec 2001 05:18:46 +0000 (05:18 +0000)
  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.

src/FDM/Balloon.cxx
src/FDM/JSBSim.cxx
src/FDM/flight.cxx
src/FDM/flight.hxx
src/Network/native_fdm.cxx
src/Network/raw_fdm.hxx

index 4bde1049f443bc9d1c2c092cf81678081e45db0d..6790df396ce5fc2042f118fecacc350a024dab60 100644 (file)
@@ -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] );
index d37caa6e769b97b14c3a5efd9bf545432d038bca..f661c39488134a1a701ecbe30594127e39dcd6c0 100644 (file)
@@ -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() );
 
index 348fe3aa33c88fa84502e09c4f8b7cd455ec55e3..9a857c6822d277b092192a86a537c382723ec47b 100644 (file)
@@ -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;
index 34f8c7a6a49a9e204f19107217e9f61cdd77d192..85a5f16ad36bf993d74ff899ea25e5c26f50bd6d 100644 (file)
@@ -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, 
index 0c7049c0dfe0ba173d433a49e95caece82ea4aa7..1ffe850c1cb4df65a62ec0efe4d2a2ebedfa5d64 100644 (file)
@@ -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 );
index e5f8b7ed33f309c97d1bfa6171cd9dd2b6f9b9bb..d635458f494448df0b94bc1e7c0337db7dab3449 100644 (file)
@@ -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