]> git.mxchange.org Git - flightgear.git/commitdiff
Mathias Fröhlich:
authorehofman <ehofman>
Fri, 19 Nov 2004 12:33:08 +0000 (12:33 +0000)
committerehofman <ehofman>
Fri, 19 Nov 2004 12:33:08 +0000 (12:33 +0000)
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
src/AIModel/AIShip.cxx

index 1ef585b6e3e4a7466f002aebf373e08a0c788e89..cadc6af63ffe4044dc8c82fbe2c3c8682837cf4c 100644 (file)
@@ -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,
index 5542be683193423a8a2e2f5e2b9414a98d5e33d8..1aabe5875ecb24a1f39fc0e58920481110e6371d 100644 (file)
@@ -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