From c2d8dcc18baf88176ad48f0b7163dcb4aee51f90 Mon Sep 17 00:00:00 2001 From: frohlich Date: Thu, 15 Jun 2006 08:29:43 +0000 Subject: [PATCH] More use of SGGeo[dc]. --- src/AIModel/AIAircraft.cxx | 26 ++++++++--------- src/AIModel/AIBallistic.cxx | 8 +++--- src/AIModel/AIBallistic.hxx | 1 - src/AIModel/AIBase.cxx | 29 ++++++++++--------- src/AIModel/AIBase.hxx | 9 +++--- src/AIModel/AICarrier.cxx | 54 ++++++++++++++--------------------- src/AIModel/AICarrier.hxx | 3 +- src/AIModel/AIMultiplayer.cxx | 11 +++---- src/AIModel/AIShip.cxx | 4 +-- src/AIModel/AIStorm.cxx | 8 +++--- src/AIModel/AIThermal.cxx | 4 +-- src/FDM/SP/ACMS.cxx | 20 ++++++------- src/Network/multiplay.cxx | 2 +- 13 files changed, 81 insertions(+), 98 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 5c560d9bc..6062f8dbe 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -180,7 +180,7 @@ void FGAIAircraft::Run(double dt) { doGroundAltitude(); //cerr << " Actual altitude " << altitude << endl; // Transform(); - pos.setelev(altitude * SG_FEET_TO_METER); + pos.setElevationFt(altitude); } return; } @@ -219,8 +219,8 @@ void FGAIAircraft::Run(double dt) { * speed * 1.686 / ft_per_deg_lon; // set new position - pos.setlat( pos.lat() + speed_north_deg_sec * dt); - pos.setlon( pos.lon() + speed_east_deg_sec * dt); + pos.setLatitudeDeg( pos.getLatitudeDeg() + speed_north_deg_sec * dt); + pos.setLongitudeDeg( pos.getLongitudeDeg() + speed_east_deg_sec * dt); //if (!(finite(pos.lat()) && finite(pos.lon()))) // { // cerr << "Position is not finite" << endl; @@ -361,7 +361,7 @@ void FGAIAircraft::Run(double dt) { // adjust altitude (meters) based on current vertical speed (fpm) altitude += vs / 60.0 * dt; - pos.setelev(altitude * SG_FEET_TO_METER); + pos.setElevationFt(altitude); double altitude_ft = altitude; // adjust target Altitude, based on ground elevation when on ground @@ -564,7 +564,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) { if (curr->crossat > -1000.0) { //use a calculated descent/climb rate use_perf_vs = false; tgt_vs = (curr->crossat - prev->altitude) - / (fp->getDistanceToGo(pos.lat(), pos.lon(), curr) + / (fp->getDistanceToGo(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr) / 6076.0 / prev->speed*60.0); tgt_altitude = curr->crossat; } else { @@ -597,7 +597,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) { dt_count = 0; } // check to see if we've reached the lead point for our next turn - double dist_to_go = fp->getDistanceToGo(pos.lat(), pos.lon(), curr); + double dist_to_go = fp->getDistanceToGo(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr); //cerr << "2" << endl; double lead_dist = fp->getLeadDistance(); @@ -666,7 +666,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) { double userLatitude = fgGetDouble("/position/latitude-deg"); double userLongitude = fgGetDouble("/position/longitude-deg"); double course, distance; - SGWayPoint current (pos.lon(), pos.lat(), 0); + SGWayPoint current(pos.getLongitudeDeg(), pos.getLatitudeDeg(), 0); SGWayPoint user (userLongitude, userLatitude, 0); user.CourseAndDistance(current, &course, &distance); if ((distance * SG_METER_TO_NM) > TRAFFICTOAIDIST) { @@ -736,7 +736,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) { if (curr->crossat > -1000.0) { //cerr << "5.1a" << endl; use_perf_vs = false; - tgt_vs = (curr->crossat - altitude) / (fp->getDistanceToGo(pos.lat(), pos.lon(), curr) + tgt_vs = (curr->crossat - altitude) / (fp->getDistanceToGo(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr) / 6076.0 / speed*60.0); //cerr << "5.1b" << endl; tgt_altitude = curr->crossat; @@ -757,7 +757,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) { //cout << " Target heading: " << tgt_heading << endl << endl; } else { - double calc_bearing = fp->getBearing(pos.lat(), pos.lon(), curr); + double calc_bearing = fp->getBearing(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr); //cerr << "Bearing = " << calc_bearing << endl; if (speed < 0) { calc_bearing +=180; @@ -774,7 +774,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) { } else { cerr << "calc_bearing is not a finite number : " << "Speed " << speed - << "pos : " << pos.lat() << ", " << pos.lon() + << "pos : " << pos.getLatitudeDeg() << ", " << pos.getLongitudeDeg() << "waypoint " << curr->latitude << ", " << curr->longitude << endl; cerr << "waypoint name " << curr->name; exit(1); // FIXME @@ -924,7 +924,7 @@ void FGAIAircraft::getGroundElev(double dt) { //Point3D currView(vw->getLongitude_deg(), // vw->getLatitude_deg(), 0.0); - SGWayPoint current (pos.lon(), pos.lat(), 0); + SGWayPoint current(pos.getLongitudeDeg(), pos.getLatitudeDeg(), 0); SGWayPoint view (vw->getLongitude_deg(), vw->getLatitude_deg(), 0); view.CourseAndDistance(current, &course, &distance); if(distance > visibility_meters) { @@ -934,14 +934,14 @@ void FGAIAircraft::getGroundElev(double dt) { // FIXME: make sure the pos.lat/pos.lon values are in degrees ... double range = 500.0; - if (!globals->get_tile_mgr()->scenery_available(pos.lat(), pos.lon(), range)) { + if (!globals->get_tile_mgr()->scenery_available(pos.getLatitudeDeg(), pos.getLongitudeDeg(), range)) { // Try to shedule tiles for that position. globals->get_tile_mgr()->update( aip.getSGLocation(), range ); } // FIXME: make sure the pos.lat/pos.lon values are in degrees ... double alt; - if (globals->get_scenery()->get_elevation_m(pos.lat(), pos.lon(), 20000.0, alt, 0)) + if (globals->get_scenery()->get_elevation_m(pos.getLatitudeDeg(), pos.getLongitudeDeg(), 20000.0, alt, 0)) tgt_altitude = alt * SG_METER_TO_FEET; //cerr << "Target altitude : " << tgt_altitude << endl; diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 165eb903a..a91e440fe 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -169,7 +169,7 @@ void FGAIBallistic::Run(double dt) { // calculate vertical and horizontal speed components vs = sin( pitch * SG_DEGREES_TO_RADIANS ) * speed; - hs = cos( pitch * SG_DEGREES_TO_RADIANS ) * speed; + double hs = cos( pitch * SG_DEGREES_TO_RADIANS ) * speed; // convert horizontal speed (fps) to degrees per second speed_north_deg_sec = cos(hdg / SG_RADIANS_TO_DEGREES) * hs / ft_per_deg_lat; @@ -186,15 +186,15 @@ void FGAIBallistic::Run(double dt) { wind_speed_from_east_deg_sec = wind_from_east / ft_per_deg_lon; // set new position - pos.setlat( pos.lat() + (speed_north_deg_sec - wind_speed_from_north_deg_sec) * dt ); - pos.setlon( pos.lon() + (speed_east_deg_sec - wind_speed_from_east_deg_sec) * dt ); + pos.setLatitudeDeg( pos.getLatitudeDeg() + (speed_north_deg_sec - wind_speed_from_north_deg_sec) * dt ); + pos.setLongitudeDeg( pos.getLongitudeDeg() + (speed_east_deg_sec - wind_speed_from_east_deg_sec) * dt ); // adjust vertical speed for acceleration of gravity and buoyancy vs -= (gravity - buoyancy) * dt; // adjust altitude (feet) altitude += vs * dt; - pos.setelev(altitude * SG_FEET_TO_METER); + pos.setElevationFt(altitude); // recalculate pitch (velocity vector) if aerostabilized // cout << "aero_stabilised " << aero_stabilised << endl ; diff --git a/src/AIModel/AIBallistic.hxx b/src/AIModel/AIBallistic.hxx index efa52a557..6b5441304 100644 --- a/src/AIModel/AIBallistic.hxx +++ b/src/AIModel/AIBallistic.hxx @@ -60,7 +60,6 @@ private: double azimuth; // degrees true double elevation; // degrees double rotation; // degrees - double hs; // horizontal speed (fps) bool aero_stabilised; // if true, object will align wit trajectory double drag_area; // equivalent drag area in ft2 double life_timer; // seconds diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 20bc20520..8746af4c1 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -106,13 +106,13 @@ void FGAIBase::update(double dt) { if (_otype == otBallistic) CalculateMach(); - ft_per_deg_lat = 366468.96 - 3717.12 * cos(pos.lat()*SGD_DEGREES_TO_RADIANS); - ft_per_deg_lon = 365228.16 * cos(pos.lat()*SGD_DEGREES_TO_RADIANS); + ft_per_deg_lat = 366468.96 - 3717.12 * cos(pos.getLatitudeRad()); + ft_per_deg_lon = 365228.16 * cos(pos.getLatitudeRad()); } void FGAIBase::Transform() { if (!invisible) { - aip.setPosition(pos.lon(), pos.lat(), pos.elev() * SG_METER_TO_FEET); + aip.setPosition(pos); if (no_roll) { aip.setOrientation(0.0, pitch, hdg); } else { @@ -260,8 +260,8 @@ double FGAIBase::UpdateRadar(FGAIManager* manager) double user_latitude = manager->get_user_latitude(); double user_longitude = manager->get_user_longitude(); - double lat_range = fabs(pos.lat() - user_latitude) * ft_per_deg_lat; - double lon_range = fabs(pos.lon() - user_longitude) * ft_per_deg_lon; + double lat_range = fabs(pos.getLatitudeDeg() - user_latitude) * ft_per_deg_lat; + double lon_range = fabs(pos.getLongitudeDeg() - user_longitude) * ft_per_deg_lon; double range_ft2 = lat_range*lat_range + lon_range*lon_range; // @@ -284,16 +284,16 @@ double FGAIBase::UpdateRadar(FGAIManager* manager) range = range_ft / 6076.11549; // calculate bearing to target - if (pos.lat() >= user_latitude) { + if (pos.getLatitudeDeg() >= user_latitude) { bearing = atan2(lat_range, lon_range) * SG_RADIANS_TO_DEGREES; - if (pos.lon() >= user_longitude) { + if (pos.getLongitudeDeg() >= user_longitude) { bearing = 90.0 - bearing; } else { bearing = 270.0 + bearing; } } else { bearing = atan2(lon_range, lat_range) * SG_RADIANS_TO_DEGREES; - if (pos.lon() >= user_longitude) { + if (pos.getLongitudeDeg() >= user_longitude) { bearing = 180.0 - bearing; } else { bearing = 180.0 + bearing; @@ -341,7 +341,8 @@ SGVec3d FGAIBase::getCartPosAt(const SGVec3d& _off) const { // Transform that one to the horizontal local coordinate system. - SGQuatd hlTrans = SGQuatd::fromLonLatDeg(pos.lon(), pos.lat()); + + SGQuatd hlTrans = SGQuatd::fromLonLat(pos); // and postrotate the orientation of the AIModel wrt the horizontal // local frame hlTrans *= SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll); @@ -351,7 +352,7 @@ FGAIBase::getCartPosAt(const SGVec3d& _off) const SGVec3d off = hlTrans.backTransform(_off); // Add the position offset of the AIModel to gain the earth centered position - SGVec3d cartPos = SGGeod::fromDegFt(pos.lon(), pos.lat(), pos.elev()); + SGVec3d cartPos = SGVec3d::fromGeod(pos); return cartPos + off; } @@ -360,17 +361,17 @@ FGAIBase::getCartPosAt(const SGVec3d& _off) const * getters and Setters */ void FGAIBase::_setLongitude( double longitude ) { - pos.setlon(longitude); + pos.setLongitudeDeg(longitude); } void FGAIBase::_setLatitude ( double latitude ) { - pos.setlat(latitude); + pos.setLatitudeDeg(latitude); } double FGAIBase::_getLongitude() const { - return pos.lon(); + return pos.getLongitudeDeg(); } double FGAIBase::_getLatitude () const { - return pos.lat(); + return pos.getLatitudeDeg(); } double FGAIBase::_getRdot() const { return rdot; diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index c24113445..d21414486 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -48,7 +48,6 @@ public: FGAIBase(object_type ot); virtual ~FGAIBase(); - inline const Point3D& GetPos() const { return(pos); } virtual void readFromScenario(SGPropertyNode* scFileNode); @@ -84,7 +83,7 @@ protected: FGAIManager* manager; // these describe the model's actual state - Point3D pos; // WGS84 lat & lon in degrees, elev above sea-level in meters + SGGeod pos; // WGS84 lat & lon in degrees, elev above sea-level in meters double hdg; // True heading in degrees double roll; // degrees, left is negative double pitch; // degrees, nose-down is negative @@ -205,7 +204,7 @@ inline void FGAIBase::setHeading( double heading ) { inline void FGAIBase::setAltitude( double altitude_ft ) { altitude = tgt_altitude = altitude_ft; - pos.setelev(altitude * SG_FEET_TO_METER); + pos.setElevationFt(altitude); } inline void FGAIBase::setBank( double bank ) { @@ -218,10 +217,10 @@ inline void FGAIBase::setPitch( double newpitch ) { } inline void FGAIBase::setLongitude( double longitude ) { - pos.setlon( longitude ); + pos.setLongitudeDeg( longitude ); } inline void FGAIBase::setLatitude ( double latitude ) { - pos.setlat( latitude ); + pos.setLatitudeDeg( latitude ); } inline void FGAIBase::setDie( bool die ) { delete_me = die; } diff --git a/src/AIModel/AICarrier.cxx b/src/AIModel/AICarrier.cxx index 3dd427ce0..7fa08422b 100644 --- a/src/AIModel/AICarrier.cxx +++ b/src/AIModel/AICarrier.cxx @@ -152,14 +152,14 @@ void FGAICarrier::update(double dt) { // but by just apply discrete changes at its velocity variables. // Update the velocity information stored in those nodes. // Transform that one to the horizontal local coordinate system. - SGQuatd ec2hl = SGQuatd::fromLonLatDeg(pos.lon(), pos.lat()); + SGQuatd ec2hl = SGQuatd::fromLonLat(pos); // The orientation of the carrier wrt the horizontal local frame SGQuatd hl2body = SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll); // and postrotate the orientation of the AIModel wrt the horizontal // local frame SGQuatd ec2body = ec2hl*hl2body; // The cartesian position of the carrier in the wgs84 world - SGVec3d cartPos = SGGeod::fromDegFt(pos.lon(), pos.lat(), pos.elev()); + SGVec3d cartPos = SGVec3d::fromGeod(pos); // Store for later use by the groundcache rot_pivot_wrt_earth = cartPos; @@ -189,7 +189,7 @@ void FGAICarrier::update(double dt) { // Now here is the finite difference ... // Transform that one to the horizontal local coordinate system. - SGQuatd ec2hlNew = SGQuatd::fromLonLatDeg(pos.lon(), pos.lat()); + SGQuatd ec2hlNew = SGQuatd::fromLonLat(pos); // compute the new orientation SGQuatd hl2bodyNew = SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll); // The rotation difference @@ -287,7 +287,7 @@ bool FGAICarrier::init() { turn_to_launch_hdg = false; returning = false; - initialpos = pos; + mOpBoxPos = pos; base_course = hdg; base_speed = speed; @@ -322,9 +322,9 @@ void FGAICarrier::bind() { props->tie("controls/base-speed-kts", SGRawValuePointer(&base_speed)); props->tie("controls/start-pos-lat-deg", - SGRawValuePointer(&initialpos[1])); + SGRawValueMethods(pos, &SGGeod::getLatitudeDeg)); props->tie("controls/start-pos-long-deg", - SGRawValuePointer(&initialpos[0])); + SGRawValueMethods(pos, &SGGeod::getLongitudeDeg)); props->tie("velocities/speed-kts", SGRawValuePointer(&speed)); props->tie("environment/surface-wind-speed-true-kts", @@ -402,7 +402,7 @@ bool FGAICarrier::getParkPosition(const string& id, SGGeod& geodPos, if ((*it).name == id || id.empty()) { ParkPosition ppos = *it; SGVec3d cartPos = getCartPosAt(ppos.offset); - geodPos = cartPos; + geodPos = SGGeod::fromCart(cartPos); hdng = hdg + ppos.heading_deg; double shdng = sin(ppos.heading_deg * SGD_DEGREES_TO_RADIANS); double chdng = cos(ppos.heading_deg * SGD_DEGREES_TO_RADIANS); @@ -579,14 +579,14 @@ bool FGAICarrier::mark_cat(ssgEntity* e, const list& cat_objects, bool m // care for transforms ... short v[2]; l->getLine(0, v, v+1 ); - sgVec3 ends[2]; + SGVec3f ends[2]; for (int k=0; k<2; ++k) - sgCopyVec3( ends[k], l->getVertex( v[k] ) ); + sgCopyVec3( ends[k].sg(), l->getVertex( v[k] ) ); // When the 1 end is behind the 0 end, swap the coordinates. if (ends[0][0] < ends[1][0]) { - sgCopyVec3( l->getVertex( v[0] ), ends[1] ); - sgCopyVec3( l->getVertex( v[1] ), ends[0] ); + sgCopyVec3( l->getVertex( v[0] ), ends[1].sg() ); + sgCopyVec3( l->getVertex( v[1] ), ends[0].sg() ); } found = true; } @@ -685,18 +685,8 @@ void FGAICarrier::TurnToBase(){ void FGAICarrier::ReturnToBox(){ double course, distance, az2; - //get the carrier position - carrierpos = pos; - - //cout << "lat: " << carrierpos[1] << " lon: " << carrierpos[0] << endl; - //calculate the bearing and range of the initial position from the carrier - geo_inverse_wgs_84(carrierpos[2], - carrierpos[1], - carrierpos[0], - initialpos[1], - initialpos[0], - &course, &az2, &distance); + geo_inverse_wgs_84(pos, mOpBoxPos, &course, &az2, &distance); distance *= SG_METER_TO_NM; @@ -720,33 +710,33 @@ bool FGAICarrier::OutsideBox() { //returns true if the carrier is outside operat return false; } - if (initialpos[1] >= 0) { //northern hemisphere - if (pos[1] >= initialpos[1] + max_lat) + if (mOpBoxPos.getLatitudeDeg() >= 0) { //northern hemisphere + if (pos.getLatitudeDeg() >= mOpBoxPos.getLatitudeDeg() + max_lat) return true; - if (pos[1] <= initialpos[1] - min_lat) + if (pos.getLatitudeDeg() <= mOpBoxPos.getLatitudeDeg() - min_lat) return true; } else { //southern hemisphere - if (pos[1] <= initialpos[1] - max_lat) + if (pos.getLatitudeDeg() <= mOpBoxPos.getLatitudeDeg() - max_lat) return true; - if (pos[1] >= initialpos[1] + min_lat) + if (pos.getLatitudeDeg() >= mOpBoxPos.getLatitudeDeg() + min_lat) return true; } - if (initialpos[0] >=0) { //eastern hemisphere - if (pos[0] >= initialpos[0] + max_long) + if (mOpBoxPos.getLongitudeDeg() >=0) { //eastern hemisphere + if (pos.getLongitudeDeg() >= mOpBoxPos.getLongitudeDeg() + max_long) return true; - if (pos[0] <= initialpos[0] - min_long) + if (pos.getLongitudeDeg() <= mOpBoxPos.getLongitudeDeg() - min_long) return true; } else { //western hemisphere - if (pos[0] <= initialpos[0] - max_long) + if (pos.getLongitudeDeg() <= mOpBoxPos.getLongitudeDeg() - max_long) return true; - if (pos[0] >= initialpos[0] + min_long) + if (pos.getLongitudeDeg() >= mOpBoxPos.getLongitudeDeg() + min_long) return true; } diff --git a/src/AIModel/AICarrier.hxx b/src/AIModel/AICarrier.hxx index 4a823358a..9a3d52f41 100644 --- a/src/AIModel/AICarrier.hxx +++ b/src/AIModel/AICarrier.hxx @@ -155,8 +155,7 @@ private: bool wave_off_lights; // these are for maneuvering the carrier - Point3D carrierpos; - Point3D initialpos; + SGGeod mOpBoxPos; double wind_speed_from_north_kts ; double wind_speed_from_east_kts ; diff --git a/src/AIModel/AIMultiplayer.cxx b/src/AIModel/AIMultiplayer.cxx index 89d90b593..e4bb79176 100755 --- a/src/AIModel/AIMultiplayer.cxx +++ b/src/AIModel/AIMultiplayer.cxx @@ -291,15 +291,12 @@ void FGAIMultiplayer::update(double dt) } // extract the position - SGGeod geod = ecPos; - pos.setlat(geod.getLatitudeDeg()); - pos.setlon(geod.getLongitudeDeg()); - pos.setelev(geod.getElevationM()); + pos = SGGeod::fromCart(ecPos); // The quaternion rotating from the earth centered frame to the // horizontal local frame - SGQuatf qEc2Hl = SGQuatf::fromLonLatRad((float)geod.getLongitudeRad(), - (float)geod.getLatitudeRad()); + SGQuatf qEc2Hl = SGQuatf::fromLonLatRad((float)pos.getLongitudeRad(), + (float)pos.getLatitudeRad()); // The orientation wrt the horizontal local frame SGQuatf hlOr = conj(qEc2Hl)*ecOrient; float hDeg, pDeg, rDeg; @@ -309,7 +306,7 @@ void FGAIMultiplayer::update(double dt) pitch = pDeg; SG_LOG(SG_GENERAL, SG_DEBUG, "Multiplayer position and orientation: " - << geod << ", " << hlOr); + << ecPos << ", " << hlOr); //###########################// // do calculations for radar // diff --git a/src/AIModel/AIShip.cxx b/src/AIModel/AIShip.cxx index ba903d07c..2c8e3993f 100644 --- a/src/AIModel/AIShip.cxx +++ b/src/AIModel/AIShip.cxx @@ -135,8 +135,8 @@ void FGAIShip::Run(double dt) { * speed * 1.686 / ft_per_deg_lon; // set new position - pos.setlat( pos.lat() + speed_north_deg_sec * dt); - pos.setlon( pos.lon() + speed_east_deg_sec * dt); + pos.setLatitudeDeg( pos.getLatitudeDeg() + speed_north_deg_sec * dt); + pos.setLongitudeDeg( pos.getLongitudeDeg() + speed_east_deg_sec * dt); // adjust heading based on current rudder angle diff --git a/src/AIModel/AIStorm.cxx b/src/AIModel/AIStorm.cxx index 5814d2895..0fafd7055 100644 --- a/src/AIModel/AIStorm.cxx +++ b/src/AIModel/AIStorm.cxx @@ -106,8 +106,8 @@ void FGAIStorm::Run(double dt) { * speed * 1.686 / ft_per_deg_lon; // set new position - pos.setlat( pos.lat() + speed_north_deg_sec * dt); - pos.setlon( pos.lon() + speed_east_deg_sec * dt); + pos.setLatitudeDeg( pos.getLatitudeDeg() + speed_north_deg_sec * dt); + pos.setLongitudeDeg( pos.getLongitudeDeg() + speed_east_deg_sec * dt); // do calculations for weather radar display UpdateRadar(manager); @@ -159,8 +159,8 @@ void FGAIStorm::Run(double dt) { double user_altitude = manager->get_user_altitude(); // calculate range to target in feet and nautical miles - double lat_range = fabs(pos.lat() - user_latitude) * ft_per_deg_lat; - double lon_range = fabs(pos.lon() - user_longitude) * ft_per_deg_lon; + double lat_range = fabs(pos.getLatitudeDeg() - user_latitude) * ft_per_deg_lat; + double lon_range = fabs(pos.getLongitudeDeg() - user_longitude) * ft_per_deg_lon; double range_ft = sqrt(lat_range*lat_range + lon_range*lon_range); range = range_ft / 6076.11549; diff --git a/src/AIModel/AIThermal.cxx b/src/AIModel/AIThermal.cxx index f79c780b8..0253a0f8b 100644 --- a/src/AIModel/AIThermal.cxx +++ b/src/AIModel/AIThermal.cxx @@ -88,8 +88,8 @@ void FGAIThermal::Run(double dt) { double user_altitude = manager->get_user_altitude(); // calculate range to target in feet and nautical miles - double lat_range = fabs(pos.lat() - user_latitude) * ft_per_deg_lat; - double lon_range = fabs(pos.lon() - user_longitude) * ft_per_deg_lon; + double lat_range = fabs(pos.getLatitudeDeg() - user_latitude) * ft_per_deg_lat; + double lon_range = fabs(pos.getLongitudeDeg() - user_longitude) * ft_per_deg_lon; double range_ft = sqrt(lat_range*lat_range + lon_range*lon_range); range = range_ft / 6076.11549; diff --git a/src/FDM/SP/ACMS.cxx b/src/FDM/SP/ACMS.cxx index 0a37f5864..ad36f28cf 100644 --- a/src/FDM/SP/ACMS.cxx +++ b/src/FDM/SP/ACMS.cxx @@ -23,6 +23,7 @@ # include #endif +#include #include #include
@@ -78,9 +79,7 @@ void FGACMS::update( double dt ) { double acc_down = _acc_down->getDoubleValue(); _set_Accels_Local( acc_lon, acc_lat, acc_down ); - sgVec3 accel_ned; - sgSetVec3(accel_ned, acc_lon, acc_lat, acc_down); - double accel = sgLengthVec3 (accel_ned) * SG_FEET_TO_METER; + double accel = norm(SGVec3d(acc_lon, acc_lat, acc_down)) * SG_FEET_TO_METER; double velocity = (_speed->getDoubleValue() * SG_KT_TO_MPS) + accel * dt; double dist = cos (pitch) * velocity * dt; @@ -89,16 +88,15 @@ void FGACMS::update( double dt ) { _set_V_calibrated_kts( kts ); _set_V_ground_speed( kts ); + SGGeod pos = SGGeod::fromDegM(get_Longitude(), get_Latitude(), get_Altitude()); // update (lon/lat) position - double lat2, lon2, az2; - geo_direct_wgs_84 ( get_Altitude(), - get_Latitude() * SGD_RADIANS_TO_DEGREES, - get_Longitude() * SGD_RADIANS_TO_DEGREES, - heading * SGD_RADIANS_TO_DEGREES, - dist, &lat2, &lon2, &az2 ); + SGGeod pos2; + double az2; + geo_direct_wgs_84 ( pos, heading * SGD_RADIANS_TO_DEGREES, + dist, pos2, &az2 ); - _set_Longitude( lon2 * SGD_DEGREES_TO_RADIANS ); - _set_Latitude( lat2 * SGD_DEGREES_TO_RADIANS ); + _set_Longitude( pos2.getLongitudeRad() ); + _set_Latitude( pos2.getLatitudeRad() ); double sl_radius, lat_geoc; sgGeodToGeoc( get_Latitude(), get_Altitude(), &sl_radius, &lat_geoc ); diff --git a/src/Network/multiplay.cxx b/src/Network/multiplay.cxx index a55de0ead..4db3fb11e 100644 --- a/src/Network/multiplay.cxx +++ b/src/Network/multiplay.cxx @@ -156,7 +156,7 @@ bool FGMultiplay::process() { // first the aprioriate structure for the geodetic one SGGeod geod = SGGeod::fromRadFt(lon, lat, ifce->get_Altitude()); // Convert to cartesion coordinate - motionInfo.position = geod; + motionInfo.position = SGVec3d::fromGeod(geod); // The quaternion rotating from the earth centered frame to the // horizontal local frame