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] =
{
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
$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.
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 */
/* 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);
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 */
$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.
/* SCALAR inv_radius_ratio; */
SCALAR cos_rwy_hdg, sin_rwy_hdg;
SCALAR mach2, temp_ratio, pres_ratio;
+ SCALAR tmp;
/* update geodetic position */
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;
$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
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 */
/* 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 */
/* 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 */