From 3c0ab43b43ebcbed58b063295b11da941444f238 Mon Sep 17 00:00:00 2001 From: ehofman Date: Fri, 19 Nov 2004 12:33:08 +0000 Subject: [PATCH] =?UTF-8?q?Mathias=20Fr=F6hlich:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The moving ai models will jump around realtive to the moving aircraft model. I can see that with the carrier but others have noticed that too with ai aircraft before. The reason is that all SGSystems are called with a dt value which is not necessarily a multiple of 1/hz. In contrast, most FDM's use the _calc_multiloop function from FGInterface which forces the time update to be a multiple of 1/hz for the FDM aircraft. As a result, in the worst case, the FDM aircraft has moved nearly 1/hz seconds further than the rest of flightgear (1/120sec*300kts that is about 1.3m). That patch forces the time update to be a multiple of 1/hz. --- src/AIModel/AIBase.cxx | 4 ++-- src/AIModel/AIShip.cxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 1ef585b6e..cadc6af63 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -78,8 +78,8 @@ FGAIBase::~FGAIBase() { } void FGAIBase::update(double dt) { - ft_per_deg_lat = 366468.96 - 3717.12 * cos(pos.lat()/SG_RADIANS_TO_DEGREES); - ft_per_deg_lon = 365228.16 * cos(pos.lat() / SG_RADIANS_TO_DEGREES); + 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); // Calculate rho at altitude, using standard atmosphere // For the temperature T and the pressure p, diff --git a/src/AIModel/AIShip.cxx b/src/AIModel/AIShip.cxx index 5542be683..1aabe5875 100644 --- a/src/AIModel/AIShip.cxx +++ b/src/AIModel/AIShip.cxx @@ -84,9 +84,9 @@ void FGAIShip::Run(double dt) { } // convert speed to degrees per second - speed_north_deg_sec = cos( hdg / SG_RADIANS_TO_DEGREES ) + speed_north_deg_sec = cos( hdg / SGD_RADIANS_TO_DEGREES ) * speed * 1.686 / ft_per_deg_lat; - speed_east_deg_sec = sin( hdg / SG_RADIANS_TO_DEGREES ) + speed_east_deg_sec = sin( hdg / SGD_RADIANS_TO_DEGREES ) * speed * 1.686 / ft_per_deg_lon; // set new position