33 Autopilot::Autopilot(
int actor_id):
100 else if (rat <= -1.0)
103 bank = 57.3 * asin(rat);
115 float curdir = atan2(vel.x, -vel.z) * 57.295779513082;
116 float want_bank = curdir - (float)
heading;
117 if (want_bank < -180.0)
119 want_bank = want_bank * 2.0;
120 if (want_bank > 45.0)
122 if (want_bank < -45.0)
124 val = (bank - want_bank) / 100.0;
134 if (error_heading > 1.0)
136 if (error_heading < -1.0)
137 error_heading = -1.0;
139 if (offcourse_tolerance > 60.0)
140 offcourse_tolerance = 60.0;
143 float curdir = atan2(vel.x, -vel.z) * 57.295779513082;
144 float want_bank = curdir - intercept_heading;
145 if (want_bank < -180.0)
147 want_bank = want_bank * 2.0;
148 if (want_bank > 45.0)
150 if (want_bank < -45.0)
152 val = (bank - want_bank) / 100.0;
168 float wanted_vs = (float)
vs / 196.87;
178 wanted_vs = 5000.0 / 196.87;
179 float wanted_vs2 = (-ch + oh) / 5.0;
180 if (wanted_vs2 < -wanted_vs)
181 wanted_vs2 = -wanted_vs;
182 if (wanted_vs2 > wanted_vs)
183 wanted_vs2 = wanted_vs;
184 val = (wanted_vs2 - current_vs) / 40.0 + pitch_var / 40.0;
192 val = (wanted_vs - current_vs) / 40.0 + pitch_var / 40.0;
201 float wanted_alt = (float)
alt * 0.3048;
204 wanted_vs = -wanted_vs;
205 float wanted_vs2 = (wanted_alt - current_alt) / 8.0;
206 if (wanted_vs2 < -wanted_vs)
207 wanted_vs2 = -wanted_vs;
208 if (wanted_vs2 > wanted_vs)
209 wanted_vs2 = wanted_vs;
210 val = (wanted_vs2 - current_vs) / 40.0 + pitch_var / 40.0;
235 float sea_level_pressure = 101325;
237 float airpressure = sea_level_pressure * pow(1.0 - 0.0065 * altitude / 288.15, 5.24947);
238 float airdensity = airpressure * 0.0000120896;
242 float spd = gspd * sqrt(airdensity / 1.225);
244 if (spd > (
float)
ias)
245 val = val - dt / 15.0;
246 if (spd < (
float)
ias)
247 val = val + dt / 15.0;
336 if (height < 10 && last_gpws_height > 10)
338 if (height < 20 && last_gpws_height > 20)
340 if (height < 30 && last_gpws_height > 30)
342 if (height < 40 && last_gpws_height > 40)
344 if (height < 50 && last_gpws_height > 50)
346 if (height < 100 && last_gpws_height > 100)
357 if (yVel * 10.0f < -height && yVel < -10.0f)
368 float closest_hdist = -1;
369 float closest_hangle = -90;
370 float closest_vdist = -1;
371 float closest_vangle = -90;
373 for (std::vector<TerrainObjectManager::localizer_t>::size_type i = 0; i < localizers.size(); i++)
375 Plane hplane = Plane(Vector3::UNIT_Y, 0);
376 Vector3 plocd = hplane.projectVector(localizers[i].rotation * Vector3::UNIT_Z);
377 float loc = atan2(plocd.z, plocd.x);
378 Vector3 posd = hplane.projectVector(position - localizers[i].position);
379 float dir = atan2(posd.z, posd.x);
380 float diff = (dir - loc) * 57.295779513082;
385 if (diff < 80 && diff > -80)
388 float dist = (localizers[i].position - position).length();
392 if (closest_hdist < 0 || closest_hdist > dist)
394 closest_hdist = dist;
395 closest_hangle = diff;
405 if (closest_vdist < 0 || closest_vdist > dist)
407 Vector3 normv = (localizers[i].rotation * Vector3::UNIT_Z).crossProduct(Vector3::UNIT_Y);
408 Plane vplane = Plane(normv, 0);
409 float glideslope = 4;
410 Vector3 posd2 = vplane.projectVector(position - localizers[i].position);
411 float d = posd2.length();
421 dir2 = asin(d) * 57.295779513082;
422 float diff2 = dir2 - glideslope;
423 closest_vdist = dist;
424 closest_vangle = diff2;
444 if (closest_hdist < 20.0 || closest_vdist < 20.0)