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.
This commit is contained in:
parent
4f5d70144a
commit
37c2b6002c
6 changed files with 72 additions and 16 deletions
|
@ -192,7 +192,7 @@ bool FGBalloonSim::copy_from_BalloonSim() {
|
||||||
//temp[1]: longitude
|
//temp[1]: longitude
|
||||||
//temp[2]: altitude (meters)
|
//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 );
|
current_balloon.getHPR( temp );
|
||||||
set_Euler_Angles( temp[0], temp[1], temp[2] );
|
set_Euler_Angles( temp[0], temp[1], temp[2] );
|
||||||
|
|
|
@ -425,9 +425,9 @@ bool FGJSBsim::copy_from_JSBsim() {
|
||||||
_set_Mach_number( Translation->GetMach() );
|
_set_Mach_number( Translation->GetMach() );
|
||||||
|
|
||||||
// Positions
|
// Positions
|
||||||
_updatePosition( Position->GetLatitude(),
|
_updateGeocentricPosition( Position->GetLatitude(),
|
||||||
Position->GetLongitude(),
|
Position->GetLongitude(),
|
||||||
Position->Geth() );
|
Position->Geth() );
|
||||||
|
|
||||||
_set_Altitude_AGL( Position->GetDistanceAGL() );
|
_set_Altitude_AGL( Position->GetDistanceAGL() );
|
||||||
|
|
||||||
|
|
|
@ -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;
|
double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
|
||||||
|
|
||||||
// cout << "starting sea level rad = " << get_Sea_level_radius() << endl;
|
// cout << "starting sea level rad = " << get_Sea_level_radius() << endl;
|
||||||
|
|
|
@ -355,7 +355,8 @@ public:
|
||||||
void _setup();
|
void _setup();
|
||||||
|
|
||||||
void _busdump(void);
|
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 );
|
void _updateWeather( void );
|
||||||
|
|
||||||
inline void _set_Inertias( double m, double xx, double yy,
|
inline void _set_Inertias( double m, double xx, double yy,
|
||||||
|
|
|
@ -64,7 +64,7 @@ static void global2raw( const FGInterface *global, FGRawFDM *raw ) {
|
||||||
// positions
|
// positions
|
||||||
raw->longitude = cur_fdm_state->get_Longitude();
|
raw->longitude = cur_fdm_state->get_Longitude();
|
||||||
raw->latitude = cur_fdm_state->get_Latitude();
|
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->phi = cur_fdm_state->get_Phi();
|
||||||
raw->theta = cur_fdm_state->get_Theta();
|
raw->theta = cur_fdm_state->get_Theta();
|
||||||
raw->psi = cur_fdm_state->get_Psi();
|
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 ) {
|
if ( raw->version == FG_RAW_FDM_VERSION ) {
|
||||||
// cout << "pos = " << raw->longitude << " " << raw->latitude << endl;
|
// cout << "pos = " << raw->longitude << " " << raw->latitude << endl;
|
||||||
// cout << "sea level rad = " << cur_fdm_state->get_Sea_level_radius() << endl;
|
// cout << "sea level rad = " << cur_fdm_state->get_Sea_level_radius() << endl;
|
||||||
cur_fdm_state->_updatePosition( raw->latitude, raw->longitude,
|
cur_fdm_state->_updateGeodeticPosition( raw->latitude,
|
||||||
raw->altitude * SG_METER_TO_FEET );
|
raw->longitude,
|
||||||
|
raw->altitude
|
||||||
|
* SG_METER_TO_FEET );
|
||||||
cur_fdm_state->_set_Euler_Angles( raw->phi,
|
cur_fdm_state->_set_Euler_Angles( raw->phi,
|
||||||
raw->theta,
|
raw->theta,
|
||||||
raw->psi );
|
raw->psi );
|
||||||
|
|
|
@ -42,13 +42,13 @@ public:
|
||||||
int version; // increment when data values change
|
int version; // increment when data values change
|
||||||
|
|
||||||
// Positions
|
// Positions
|
||||||
double longitude; // radians
|
double longitude; // geodetic (radians)
|
||||||
double latitude; // radians
|
double latitude; // geodetic (radians)
|
||||||
double altitude; // meters (above sea level)
|
double altitude; // above sea level (meters)
|
||||||
double agl; // meters (altitude above ground level)
|
double agl; // above ground level (meters)
|
||||||
double phi; // radians
|
double phi; // roll (radians)
|
||||||
double theta; // radians
|
double theta; // pitch (radians)
|
||||||
double psi; // radians
|
double psi; // yaw or true heading (radians)
|
||||||
|
|
||||||
// Velocities
|
// Velocities
|
||||||
double vcas; // calibrated airspeed
|
double vcas; // calibrated airspeed
|
||||||
|
|
Loading…
Add table
Reference in a new issue