]> git.mxchange.org Git - flightgear.git/commitdiff
Code optimization tweaks from Norman Vine.
authorcurt <curt>
Mon, 24 Aug 1998 20:09:25 +0000 (20:09 +0000)
committercurt <curt>
Mon, 24 Aug 1998 20:09:25 +0000 (20:09 +0000)
LaRCsim/atmos_62.c
LaRCsim/ls_accel.c
LaRCsim/ls_aux.c
LaRCsim/ls_step.c

index 3415c529c8c2b235eabe76bba6ddeaeacefb7520..3c351882c6212dd4a8bc0952a4d1170a380ba447 100644 (file)
@@ -89,7 +89,7 @@ void ls_atmos( SCALAR altitude, SCALAR * sigma, SCALAR * v_sound,
     int                index;
     SCALAR     daltp, daltn, daltp3, daltn3, density;
     SCALAR     t_amb_r, p_amb_r;
-    int         nonconstant_const_param = 5.256;
+    SCALAR      tmp;
 
     static SCALAR      d_a_table[MAX_ALT_INDEX][5] =
     {
@@ -254,7 +254,8 @@ void ls_atmos( SCALAR altitude, SCALAR * sigma, SCALAR * v_sound,
        t_amb_r = 1. - 6.875e-6*altitude;
        // printf("index = %d  t_amb_r = %.2f\n", index, t_amb_r);
        // p_amb_r = pow( t_amb_r, 5.256 );
-       p_amb_r = pow( t_amb_r, nonconstant_const_param );
+       tmp = 5.256; // avoid a segfault (?)
+       p_amb_r = pow( t_amb_r, tmp );
        // printf("p_amb_r = %.2f\n", p_amb_r);
       }
     else
index fb091b0fe071e637c6457ab571aa606d9f76e006..7e419fdef1d405b7c0549784566ef9d800722f4d 100644 (file)
@@ -38,6 +38,9 @@
            
 $Header$
 $Log$
+Revision 1.4  1998/08/24 20:09:26  curt
+Code optimization tweaks from Norman Vine.
+
 Revision 1.3  1998/08/06 12:46:38  curt
 Header change.
 
@@ -102,6 +105,7 @@ void ls_accel( void ) {
   SCALAR       inv_Mass, inv_Radius;
   SCALAR       ixz2, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10;
   SCALAR       dx_pilot_from_cg, dy_pilot_from_cg, dz_pilot_from_cg;
+  SCALAR       tan_Lat_geocentric;
   
   
   /* Sum forces and moments at reference point */
@@ -132,12 +136,13 @@ void ls_accel( void ) {
   
   /* Calculate linear accelerations */
   
+  tan_Lat_geocentric = tan(Lat_geocentric);
   inv_Mass = 1/Mass;
   inv_Radius = 1/Radius_to_vehicle;
   V_dot_north = inv_Mass*F_north + 
-    inv_Radius*(V_north*V_down - V_east*V_east*tan(Lat_geocentric));
+    inv_Radius*(V_north*V_down - V_east*V_east*tan_Lat_geocentric);
   V_dot_east  = inv_Mass*F_east  + 
-    inv_Radius*(V_east*V_down + V_north*V_east*tan(Lat_geocentric));
+    inv_Radius*(V_east*V_down + V_north*V_east*tan_Lat_geocentric);
   V_dot_down  = inv_Mass*(F_down) + Gravity -
     inv_Radius*(V_north*V_north + V_east*V_east);
   
@@ -146,14 +151,16 @@ void ls_accel( void ) {
   ixz2 = I_xz*I_xz;
   c0  = 1/(I_xx*I_zz - ixz2);
   c1  = c0*((I_yy-I_zz)*I_zz - ixz2);
-  c2  = c0*I_xz*(I_xx - I_yy + I_zz);
-  c3  = c0*I_zz;
   c4  = c0*I_xz;
+  /* c2  = c0*I_xz*(I_xx - I_yy + I_zz); */
+  c2  = c4*(I_xx - I_yy + I_zz);
+  c3  = c0*I_zz;
   c7  = 1/I_yy;
   c5  = c7*(I_zz - I_xx);
   c6  = c7*I_xz;
   c8  = c0*((I_xx - I_yy)*I_xx + ixz2);
-  c9  = c0*I_xz*(I_yy - I_zz - I_xx);
+  /* c9  = c0*I_xz*(I_yy - I_zz - I_xx); */
+  c9  = c4*(I_yy - I_zz - I_xx);
   c10 = c0*I_xx;
   
   /* Calculate the rotational body axis accelerations */
index 58ddc766052a2d2390f182134fc6d75da97bc724..448448cf6ab9b2110048971c31891b8c4b096252 100644 (file)
@@ -47,6 +47,9 @@
 
 $Header$
 $Log$
+Revision 1.4  1998/08/24 20:09:26  curt
+Code optimization tweaks from Norman Vine.
+
 Revision 1.3  1998/08/06 12:46:38  curt
 Header change.
 
@@ -140,6 +143,7 @@ void ls_aux( void ) {
        /* SCALAR inv_radius_ratio; */
        SCALAR  cos_rwy_hdg, sin_rwy_hdg;
        SCALAR  mach2, temp_ratio, pres_ratio;
+       SCALAR  tmp;
        
     /* update geodetic position */
 
@@ -261,7 +265,8 @@ void ls_aux( void ) {
 
        mach2 = Mach_number*Mach_number;
        temp_ratio = 1.0 + 0.2*mach2; 
-       pres_ratio = pow( temp_ratio, 3.5 );
+       tmp = 3.5;
+       pres_ratio = pow( temp_ratio, tmp );
 
        Total_temperature = temp_ratio*Static_temperature;
        Total_pressure    = pres_ratio*Static_pressure;
index 66f0ca23011183f389247106f0099bbf17a7ee86..58838e8d3692538ca88379b20287c3354d3f366d 100644 (file)
@@ -50,6 +50,9 @@
 
 $Header$
 $Log$
+Revision 1.4  1998/08/24 20:09:27  curt
+Code optimization tweaks from Norman Vine.
+
 Revision 1.3  1998/07/12 03:11:04  curt
 Removed some printf()'s.
 Fixed the autopilot integration so it should be able to update it's control
@@ -140,6 +143,7 @@ void ls_step( SCALAR dt, int Initialize ) {
                SCALAR  e_dot_0, e_dot_1, e_dot_2, e_dot_3;
        static  SCALAR  e_0, e_1, e_2, e_3;
        static  SCALAR  e_dot_0_past, e_dot_1_past, e_dot_2_past, e_dot_3_past;
+               SCALAR  cos_Lat_geocentric, inv_Radius_to_vehicle;
 
 /*  I N I T I A L I Z A T I O N   */
 
@@ -233,10 +237,14 @@ void ls_step( SCALAR dt, int Initialize ) {
     
 /* Calculate trajectory rate (geocentric coordinates) */
 
-    if (cos(Lat_geocentric) != 0)
-       Longitude_dot = V_east/(Radius_to_vehicle*cos(Lat_geocentric));
+    inv_Radius_to_vehicle = 1.0/Radius_to_vehicle;
+    cos_Lat_geocentric = cos(Lat_geocentric);
+
+    if ( cos_Lat_geocentric != 0) {
+       Longitude_dot = V_east/(Radius_to_vehicle*cos_Lat_geocentric);
+    }
        
-    Latitude_dot = V_north/Radius_to_vehicle;
+    Latitude_dot = V_north*inv_Radius_to_vehicle;
     Radius_dot = -V_down;
        
 /*  A N G U L A R   V E L O C I T I E S   A N D   P O S I T I O N S  */
@@ -255,9 +263,9 @@ void ls_step( SCALAR dt, int Initialize ) {
     
 /* Calculate local axis frame rates due to travel over curved earth */
 
-    P_local =  V_east/Radius_to_vehicle;
-    Q_local = -V_north/Radius_to_vehicle;
-    R_local = -V_east*tan(Lat_geocentric)/Radius_to_vehicle;
+    P_local =  V_east*inv_Radius_to_vehicle;
+    Q_local = -V_north*inv_Radius_to_vehicle;
+    R_local = -V_east*tan(Lat_geocentric)*inv_Radius_to_vehicle;
     
 /* Transform local axis frame rates to body axis rates */