]> git.mxchange.org Git - flightgear.git/blob - src/FDM/flight.hxx
3a724b562ebb973134dd46df62af1498280207d3
[flightgear.git] / src / FDM / flight.hxx
1 // flight.hxx -- define shared flight model parameters
2 //
3 // Written by Curtis Olson, started May 1997.
4 //
5 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _FLIGHT_HXX
25 #define _FLIGHT_HXX
26
27
28 #ifndef __cplusplus
29 # error This library requires C++
30 #endif
31
32
33 /* Required get_()
34
35    `FGInterface::get_Longitude ()'
36    `FGInterface::get_Latitude ()'
37    `FGInterface::get_Altitude ()'
38    `FGInterface::get_Phi ()'
39    `FGInterface::get_Theta ()'
40    `FGInterface::get_Psi ()'
41    `FGInterface::get_V_equiv_kts ()'
42
43    `FGInterface::get_Mass ()'
44    `FGInterface::get_I_xx ()'
45    `FGInterface::get_I_yy ()'
46    `FGInterface::get_I_zz ()'
47    `FGInterface::get_I_xz ()'
48    
49    `FGInterface::get_V_north ()'
50    `FGInterface::get_V_east ()'
51    `FGInterface::get_V_down ()'
52
53    `FGInterface::get_P_Body ()'
54    `FGInterface::get_Q_Body ()'
55    `FGInterface::get_R_Body ()'
56
57    `FGInterface::get_Gamma_vert_rad ()'
58    `FGInterface::get_Climb_Rate ()'
59    `FGInterface::get_Alpha ()'
60    `FGInterface::get_Beta ()'
61
62    `FGInterface::get_Runway_altitude ()'
63
64    `FGInterface::get_Lon_geocentric ()'
65    `FGInterface::get_Lat_geocentric ()'
66    `FGInterface::get_Sea_level_radius ()'
67    `FGInterface::get_Earth_position_angle ()'
68
69    `FGInterface::get_Latitude_dot()'
70    `FGInterface::get_Longitude_dot()'
71    `FGInterface::get_Radius_dot()'
72
73    `FGInterface::get_Dx_cg ()'
74    `FGInterface::get_Dy_cg ()'
75    `FGInterface::get_Dz_cg ()'
76
77    `FGInterface::get_T_local_to_body_11 ()' ... `FGInterface::get_T_local_to_body_33 ()'
78
79    `FGInterface::get_Radius_to_vehicle ()'
80
81  */
82
83
84 #include <simgear/compiler.h>
85
86 #include <math.h>
87
88 #include <list>
89 #include <vector>
90
91 #include <Time/timestamp.hxx>
92
93 FG_USING_STD(list);
94 FG_USING_STD(vector);
95
96
97 typedef double FG_VECTOR_3[3];
98
99
100 class FGEngInterface {
101
102 private:
103
104     // inputs
105     double Throttle;
106     double Mixture;
107     double Prop_Advance;
108
109     // outputs
110     double RPM;
111     double Manifold_Pressure;
112     double MaxHP;
113     double Percentage_Power;
114     double EGT;
115     double prop_thrust;
116
117 public:
118
119     inline double get_Throttle() const { return Throttle; }
120     inline double get_Mixture() const { return Mixture; }
121     inline double get_Prop_Advance() const { return Prop_Advance; }
122     inline double get_RPM() const { return RPM; }
123     inline double get_Manifold_Pressure() const { return Manifold_Pressure; }
124     inline double get_MaxHP() const { return MaxHP; }
125     inline double get_Percentage_Power() const { return Percentage_Power; }
126     inline double get_EGT() const { return EGT; }
127     inline double get_prop_thrust() const { return prop_thrust; }
128
129     inline void set_Throttle( double t ) { Throttle = t; }
130     inline void set_Mixture( double m ) { Mixture = m; }
131     inline void set_Prop_Advance( double p ) { Prop_Advance = p; }
132     inline void set_RPM( double r ) { RPM = r; }
133     inline void set_Manifold_Pressure( double mp ) { Manifold_Pressure = mp; }
134     inline void set_MaxHP( double hp ) { MaxHP = hp; }
135     inline void set_Percentage_Power( double p ) { Percentage_Power = p; }
136     inline void set_EGT( double e ) { EGT = e; }
137     inline void set_prop_thrust( double t ) { prop_thrust = t; }
138
139 };
140
141 typedef vector < FGEngInterface > engine_list;
142
143
144 // This is based heavily on LaRCsim/ls_generic.h
145 class FGInterface {
146
147 private:
148   
149     // Pilot location rel to ref pt
150     FG_VECTOR_3 d_pilot_rp_body_v;
151
152     // CG position w.r.t. ref. point
153     FG_VECTOR_3 d_cg_rp_body_v;
154
155     // Forces
156     FG_VECTOR_3 f_body_total_v;
157     FG_VECTOR_3 f_local_total_v;
158     FG_VECTOR_3 f_aero_v;
159     FG_VECTOR_3 f_engine_v;
160     FG_VECTOR_3 f_gear_v;
161
162     // Moments
163     FG_VECTOR_3 m_total_rp_v;
164     FG_VECTOR_3 m_total_cg_v;
165     FG_VECTOR_3 m_aero_v;
166     FG_VECTOR_3 m_engine_v;
167     FG_VECTOR_3 m_gear_v;
168
169     // Accelerations
170     FG_VECTOR_3 v_dot_local_v;
171     FG_VECTOR_3 v_dot_body_v;
172     FG_VECTOR_3 a_cg_body_v;
173     FG_VECTOR_3 a_pilot_body_v;
174     FG_VECTOR_3 n_cg_body_v;
175     FG_VECTOR_3 n_pilot_body_v;
176     FG_VECTOR_3 omega_dot_body_v;
177
178     // Velocities
179     FG_VECTOR_3 v_local_v;
180     FG_VECTOR_3 v_local_rel_ground_v; // V rel w.r.t. earth surface
181     FG_VECTOR_3 v_local_airmass_v;    // velocity of airmass (steady winds)
182     FG_VECTOR_3 v_local_rel_airmass_v;  // velocity of veh. relative to airmass
183     FG_VECTOR_3 v_local_gust_v;       // linear turbulence components, L frame
184     FG_VECTOR_3 v_wind_body_v;        // Wind-relative velocities in body axis
185
186     FG_VECTOR_3 omega_body_v;         // Angular B rates
187     FG_VECTOR_3 omega_local_v;        // Angular L rates
188     FG_VECTOR_3 omega_total_v;        // Diff btw B & L
189     FG_VECTOR_3 euler_rates_v;
190     FG_VECTOR_3 geocentric_rates_v;   // Geocentric linear velocities
191
192     // Positions
193     FG_VECTOR_3 geocentric_position_v;
194     FG_VECTOR_3 geodetic_position_v;
195     FG_VECTOR_3 euler_angles_v;
196
197     // Miscellaneous Quantities
198     FG_VECTOR_3 d_cg_rwy_local_v;     // CG rel. to rwy in local coords
199     FG_VECTOR_3 d_cg_rwy_rwy_v;       // CG relative to rwy, in rwy coordinates
200     FG_VECTOR_3 d_pilot_rwy_local_v;  // pilot rel. to rwy in local coords
201     FG_VECTOR_3 d_pilot_rwy_rwy_v;    // pilot rel. to rwy, in rwy coords.
202
203     // Inertias
204     double mass, i_xx, i_yy, i_zz, i_xz;
205
206     // Normal Load Factor
207     double nlf;
208
209     // Velocities
210     double v_rel_wind, v_true_kts, v_rel_ground, v_inertial;
211     double v_ground_speed, v_equiv, v_equiv_kts;
212     double v_calibrated, v_calibrated_kts;
213
214     // Miscellaneious Quantities
215     double t_local_to_body_m[3][3];   // Transformation matrix L to B
216     double gravity;                   // Local acceleration due to G
217     double centrifugal_relief;        // load factor reduction due to speed
218     double alpha, beta, alpha_dot, beta_dot;  // in radians
219     double cos_alpha, sin_alpha, cos_beta, sin_beta;
220     double cos_phi, sin_phi, cos_theta, sin_theta, cos_psi, sin_psi;
221     double gamma_vert_rad, gamma_horiz_rad;  // Flight path angles
222     double sigma, density, v_sound, mach_number;
223     double static_pressure, total_pressure, impact_pressure;
224     double dynamic_pressure;
225     double static_temperature, total_temperature;
226     double sea_level_radius, earth_position_angle;
227     double runway_altitude, runway_latitude, runway_longitude;
228     double runway_heading;
229     double radius_to_rwy;
230     double climb_rate;                // in feet per second
231     double sin_lat_geocentric, cos_lat_geocentric;
232     double sin_longitude, cos_longitude;
233     double sin_latitude, cos_latitude;
234
235     // Engine list
236     engine_list engines;
237
238     FGTimeStamp valid_stamp;          // time this record is valid
239     FGTimeStamp next_stamp;           // time this record is valid
240
241 public:
242   
243     FGInterface(void);
244     virtual ~FGInterface();
245
246     virtual bool init( double dt );
247     virtual bool update( int multi_loop );
248
249     // Define the various supported flight models (many not yet implemented)
250     enum {
251         // Magic Carpet mode
252         FG_MAGICCARPET = 0,
253
254         // The NASA LaRCsim (Navion) flight model
255         FG_LARCSIM = 1,
256
257         // Jon S. Berndt's new FDM written from the ground up in C++
258         FG_JSBSIM = 2,
259
260         // Christian's hot air balloon simulation
261         FG_BALLOONSIM = 3,
262
263         // The following aren't implemented but are here to spark
264         // thoughts and discussions, and maybe even action.
265         FG_ACM = 4,
266         FG_SUPER_SONIC = 5,
267         FG_HELICOPTER = 6,
268         FG_AUTOGYRO = 7,
269         FG_PARACHUTE = 8,
270
271         // Driven externally via a serial port, net, file, etc.
272         FG_EXTERNAL = 9
273     };
274
275     // ========== Mass properties and geometry values ==========
276
277     // Inertias
278     inline double get_Mass() const { return mass; }
279     inline double get_I_xx() const { return i_xx; }
280     inline double get_I_yy() const { return i_yy; }
281     inline double get_I_zz() const { return i_zz; }
282     inline double get_I_xz() const { return i_xz; }
283     inline void set_Inertias( double m, double xx, double yy, 
284                               double zz, double xz)
285     {
286         mass = m;
287         i_xx = xx;
288         i_yy = yy;
289         i_zz = zz;
290         i_xz = xz;
291     }
292
293     // Pilot location rel to ref pt
294     // inline double * get_D_pilot_rp_body_v() {
295     //  return d_pilot_rp_body_v;
296     // }
297     // inline double get_Dx_pilot() const { return d_pilot_rp_body_v[0]; }
298     // inline double get_Dy_pilot() const { return d_pilot_rp_body_v[1]; }
299     // inline double get_Dz_pilot() const { return d_pilot_rp_body_v[2]; }
300     /* inline void set_Pilot_Location( double dx, double dy, double dz ) {
301         d_pilot_rp_body_v[0] = dx;
302         d_pilot_rp_body_v[1] = dy;
303         d_pilot_rp_body_v[2] = dz;
304     } */
305
306     // CG position w.r.t. ref. point
307     // inline double * get_D_cg_rp_body_v() { return d_cg_rp_body_v; }
308     inline double get_Dx_cg() const { return d_cg_rp_body_v[0]; }
309     inline double get_Dy_cg() const { return d_cg_rp_body_v[1]; }
310     inline double get_Dz_cg() const { return d_cg_rp_body_v[2]; }
311     inline void set_CG_Position( double dx, double dy, double dz ) {
312         d_cg_rp_body_v[0] = dx;
313         d_cg_rp_body_v[1] = dy;
314         d_cg_rp_body_v[2] = dz;
315     }
316
317     // ========== Forces ==========
318
319     // inline double * get_F_body_total_v() { return f_body_total_v; }
320     // inline double get_F_X() const { return f_body_total_v[0]; }
321     // inline double get_F_Y() const { return f_body_total_v[1]; }
322     // inline double get_F_Z() const { return f_body_total_v[2]; }
323     /* inline void set_Forces_Body_Total( double x, double y, double z ) {
324         f_body_total_v[0] = x;
325         f_body_total_v[1] = y;
326         f_body_total_v[2] = z;
327     } */
328
329     // inline double * get_F_local_total_v() { return f_local_total_v; }
330     // inline double get_F_north() const { return f_local_total_v[0]; }
331     // inline double get_F_east() const { return f_local_total_v[1]; }
332     // inline double get_F_down() const { return f_local_total_v[2]; }
333     /* inline void set_Forces_Local_Total( double x, double y, double z ) {
334         f_local_total_v[0] = x;
335         f_local_total_v[1] = y;
336         f_local_total_v[2] = z;
337     } */
338
339     // inline double * get_F_aero_v() { return f_aero_v; }
340     // inline double get_F_X_aero() const { return f_aero_v[0]; }
341     // inline double get_F_Y_aero() const { return f_aero_v[1]; }
342     // inline double get_F_Z_aero() const { return f_aero_v[2]; }
343     /* inline void set_Forces_Aero( double x, double y, double z ) {
344         f_aero_v[0] = x;
345         f_aero_v[1] = y;
346         f_aero_v[2] = z;
347     } */
348     
349     // inline double * get_F_engine_v() { return f_engine_v; }
350     // inline double get_F_X_engine() const { return f_engine_v[0]; }
351     // inline double get_F_Y_engine() const { return f_engine_v[1]; }
352     // inline double get_F_Z_engine() const { return f_engine_v[2]; }
353     /* inline void set_Forces_Engine( double x, double y, double z ) {
354         f_engine_v[0] = x;
355         f_engine_v[1] = y;
356         f_engine_v[2] = z;
357     } */
358
359     // inline double * get_F_gear_v() { return f_gear_v; }
360     // inline double get_F_X_gear() const { return f_gear_v[0]; }
361     // inline double get_F_Y_gear() const { return f_gear_v[1]; }
362     // inline double get_F_Z_gear() const { return f_gear_v[2]; }
363     /* inline void set_Forces_Gear( double x, double y, double z ) {
364         f_gear_v[0] = x;
365         f_gear_v[1] = y;
366         f_gear_v[2] = z;
367     } */
368
369     // ========== Moments ==========
370
371     // inline double * get_M_total_rp_v() { return m_total_rp_v; }
372     // inline double get_M_l_rp() const { return m_total_rp_v[0]; }
373     // inline double get_M_m_rp() const { return m_total_rp_v[1]; }
374     // inline double get_M_n_rp() const { return m_total_rp_v[2]; }
375     /* inline void set_Moments_Total_RP( double l, double m, double n ) {
376         m_total_rp_v[0] = l;
377         m_total_rp_v[1] = m;
378         m_total_rp_v[2] = n;
379     } */
380
381     // inline double * get_M_total_cg_v() { return m_total_cg_v; }
382     // inline double get_M_l_cg() const { return m_total_cg_v[0]; }
383     // inline double get_M_m_cg() const { return m_total_cg_v[1]; }
384     // inline double get_M_n_cg() const { return m_total_cg_v[2]; }
385     /* inline void set_Moments_Total_CG( double l, double m, double n ) {
386         m_total_cg_v[0] = l;
387         m_total_cg_v[1] = m;
388         m_total_cg_v[2] = n;
389     } */
390
391     // inline double * get_M_aero_v() { return m_aero_v; }
392     // inline double get_M_l_aero() const { return m_aero_v[0]; }
393     // inline double get_M_m_aero() const { return m_aero_v[1]; }
394     // inline double get_M_n_aero() const { return m_aero_v[2]; }
395     /* inline void set_Moments_Aero( double l, double m, double n ) {
396         m_aero_v[0] = l;
397         m_aero_v[1] = m;
398         m_aero_v[2] = n;
399     } */
400
401     // inline double * get_M_engine_v() { return m_engine_v; }
402     // inline double get_M_l_engine() const { return m_engine_v[0]; }
403     // inline double get_M_m_engine() const { return m_engine_v[1]; }
404     // inline double get_M_n_engine() const { return m_engine_v[2]; }
405     /* inline void set_Moments_Engine( double l, double m, double n ) {
406         m_engine_v[0] = l;
407         m_engine_v[1] = m;
408         m_engine_v[2] = n;
409     } */
410
411     // inline double * get_M_gear_v() { return m_gear_v; }
412     // inline double get_M_l_gear() const { return m_gear_v[0]; }
413     // inline double get_M_m_gear() const { return m_gear_v[1]; }
414     // inline double get_M_n_gear() const { return m_gear_v[2]; }
415     /* inline void set_Moments_Gear( double l, double m, double n ) {
416         m_gear_v[0] = l;
417         m_gear_v[1] = m;
418         m_gear_v[2] = n;
419     } */
420
421     // ========== Accelerations ==========
422
423     // inline double * get_V_dot_local_v() { return v_dot_local_v; }
424     inline double get_V_dot_north() const { return v_dot_local_v[0]; }
425     inline double get_V_dot_east() const { return v_dot_local_v[1]; }
426     inline double get_V_dot_down() const { return v_dot_local_v[2]; }
427     inline void set_Accels_Local( double north, double east, double down ) {
428         v_dot_local_v[0] = north;
429         v_dot_local_v[1] = east;
430         v_dot_local_v[2] = down;
431     }
432
433     // inline double * get_V_dot_body_v() { return v_dot_body_v; }
434     inline double get_U_dot_body() const { return v_dot_body_v[0]; }
435     inline double get_V_dot_body() const { return v_dot_body_v[1]; }
436     inline double get_W_dot_body() const { return v_dot_body_v[2]; }
437     inline void set_Accels_Body( double u, double v, double w ) {
438         v_dot_body_v[0] = u;
439         v_dot_body_v[1] = v;
440         v_dot_body_v[2] = w;
441     }
442
443     // inline double * get_A_cg_body_v() { return a_cg_body_v; }
444     inline double get_A_X_cg() const { return a_cg_body_v[0]; }
445     inline double get_A_Y_cg() const { return a_cg_body_v[1]; }
446     inline double get_A_Z_cg() const { return a_cg_body_v[2]; }
447     inline void set_Accels_CG_Body( double x, double y, double z ) {
448         a_cg_body_v[0] = x;
449         a_cg_body_v[1] = y;
450         a_cg_body_v[2] = z;
451     }
452
453     // inline double * get_A_pilot_body_v() { return a_pilot_body_v; }
454     inline double get_A_X_pilot() const { return a_pilot_body_v[0]; }
455     inline double get_A_Y_pilot() const { return a_pilot_body_v[1]; }
456     inline double get_A_Z_pilot() const { return a_pilot_body_v[2]; }
457     inline void set_Accels_Pilot_Body( double x, double y, double z ) {
458         a_pilot_body_v[0] = x;
459         a_pilot_body_v[1] = y;
460         a_pilot_body_v[2] = z;
461     }
462
463     // inline double * get_N_cg_body_v() { return n_cg_body_v; }
464     // inline double get_N_X_cg() const { return n_cg_body_v[0]; }
465     // inline double get_N_Y_cg() const { return n_cg_body_v[1]; }
466     // inline double get_N_Z_cg() const { return n_cg_body_v[2]; }
467     // inline void set_Accels_CG_Body_N( double x, double y, double z ) {
468     //    n_cg_body_v[0] = x;
469     //    n_cg_body_v[1] = y;
470     //    n_cg_body_v[2] = z;
471     // }
472
473     // inline double * get_N_pilot_body_v() { return n_pilot_body_v; }
474     // inline double get_N_X_pilot() const { return n_pilot_body_v[0]; }
475     // inline double get_N_Y_pilot() const { return n_pilot_body_v[1]; }
476     // inline double get_N_Z_pilot() const { return n_pilot_body_v[2]; }
477     // inline void set_Accels_Pilot_Body_N( double x, double y, double z ) {
478     //    n_pilot_body_v[0] = x;
479     //    n_pilot_body_v[1] = y;
480     //    n_pilot_body_v[2] = z;
481     // }
482
483     double get_Nlf(void) { return nlf; }
484     void set_Nlf(double n) { nlf=n;  }
485
486     // inline double * get_Omega_dot_body_v() { return omega_dot_body_v; }
487     // inline double get_P_dot_body() const { return omega_dot_body_v[0]; }
488     // inline double get_Q_dot_body() const { return omega_dot_body_v[1]; }
489     // inline double get_R_dot_body() const { return omega_dot_body_v[2]; }
490     /* inline void set_Accels_Omega( double p, double q, double r ) {
491         omega_dot_body_v[0] = p;
492         omega_dot_body_v[1] = q;
493         omega_dot_body_v[2] = r;
494     } */
495
496
497     // ========== Velocities ==========
498
499     // inline double * get_V_local_v() { return v_local_v; }
500     inline double get_V_north() const { return v_local_v[0]; }
501     inline double get_V_east() const { return v_local_v[1]; }
502     inline double get_V_down() const { return v_local_v[2]; }
503     inline void set_Velocities_Local( double north, double east, double down ) {
504         v_local_v[0] = north;
505         v_local_v[1] = east;
506         v_local_v[2] = down;
507     }
508
509     // inline double * get_V_local_rel_ground_v() {
510     //     return v_local_rel_ground_v;
511     // }
512     // inline double get_V_north_rel_ground() const {
513     //     return v_local_rel_ground_v[0];
514     // }
515     // inline double get_V_east_rel_ground() const {
516     //     return v_local_rel_ground_v[1];
517     // }
518     // inline double get_V_down_rel_ground() const {
519     //     return v_local_rel_ground_v[2];
520     // }
521     // inline void set_Velocities_Ground(double north, double east, double down)
522     // {
523     //     v_local_rel_ground_v[0] = north;
524     //     v_local_rel_ground_v[1] = east;
525     //     v_local_rel_ground_v[2] = down;
526     // }
527
528     // inline double * get_V_local_airmass_v() { return v_local_airmass_v; }
529     inline double get_V_north_airmass() const { return v_local_airmass_v[0]; }
530     inline double get_V_east_airmass() const { return v_local_airmass_v[1]; }
531     inline double get_V_down_airmass() const { return v_local_airmass_v[2]; }
532     inline void set_Velocities_Local_Airmass( double north, double east, 
533                                               double down)
534     {
535         v_local_airmass_v[0] = north;
536         v_local_airmass_v[1] = east;
537         v_local_airmass_v[2] = down;
538     }
539
540     // airmass
541     // inline double * get_V_local_rel_airmass_v() {
542     //   return v_local_rel_airmass_v;
543     // }
544     // inline double get_V_north_rel_airmass() const {
545     //   return v_local_rel_airmass_v[0];
546     // }
547     // inline double get_V_east_rel_airmass() const {
548     //   return v_local_rel_airmass_v[1];
549     // }
550     // inline double get_V_down_rel_airmass() const {
551     //   return v_local_rel_airmass_v[2];
552     // }
553     /* inline void set_Velocities_Local_Rel_Airmass( double north, double east, 
554                                                   double down)
555     {
556         v_local_rel_airmass_v[0] = north;
557         v_local_rel_airmass_v[1] = east;
558         v_local_rel_airmass_v[2] = down;
559     } */
560
561     // inline double * get_V_local_gust_v() { return v_local_gust_v; }
562     // inline double get_U_gust() const { return v_local_gust_v[0]; }
563     // inline double get_V_gust() const { return v_local_gust_v[1]; }
564     // inline double get_W_gust() const { return v_local_gust_v[2]; }
565     /* inline void set_Velocities_Gust( double u, double v, double w)
566     {
567         v_local_gust_v[0] = u;
568         v_local_gust_v[1] = v;
569         v_local_gust_v[2] = w;
570     } */
571     
572     // inline double * get_V_wind_body_v() { return v_wind_body_v; }
573     inline double get_U_body() const { return v_wind_body_v[0]; }
574     inline double get_V_body() const { return v_wind_body_v[1]; }
575     inline double get_W_body() const { return v_wind_body_v[2]; }
576     inline void set_Velocities_Wind_Body( double u, double v, double w) {
577         v_wind_body_v[0] = u;
578         v_wind_body_v[1] = v;
579         v_wind_body_v[2] = w;
580     }
581
582     // inline double get_V_rel_wind() const { return v_rel_wind; }
583     // inline void set_V_rel_wind(double wind) { v_rel_wind = wind; }
584
585     // inline double get_V_true_kts() const { return v_true_kts; }
586     // inline void set_V_true_kts(double kts) { v_true_kts = kts; }
587
588     // inline double get_V_rel_ground() const { return v_rel_ground; }
589     // inline void set_V_rel_ground( double v ) { v_rel_ground = v; }
590
591     // inline double get_V_inertial() const { return v_inertial; }
592     // inline void set_V_inertial(double v) { v_inertial = v; }
593
594     inline double get_V_ground_speed() const { return v_ground_speed; }
595     inline void set_V_ground_speed( double v) { v_ground_speed = v; }
596
597     // inline double get_V_equiv() const { return v_equiv; }
598     // inline void set_V_equiv( double v ) { v_equiv = v; }
599
600     inline double get_V_equiv_kts() const { return v_equiv_kts; }
601     inline void set_V_equiv_kts( double kts ) { v_equiv_kts = kts; }
602
603     //inline double get_V_calibrated() const { return v_calibrated; }
604     //inline void set_V_calibrated( double v ) { v_calibrated = v; }
605
606     inline double get_V_calibrated_kts() const { return v_calibrated_kts; }
607     inline void set_V_calibrated_kts( double kts ) { v_calibrated_kts = kts; }
608
609     // inline double * get_Omega_body_v() { return omega_body_v; }
610     inline double get_P_body() const { return omega_body_v[0]; }
611     inline double get_Q_body() const { return omega_body_v[1]; }
612     inline double get_R_body() const { return omega_body_v[2]; }
613     inline void set_Omega_Body( double p, double q, double r ) {
614         omega_body_v[0] = p;
615         omega_body_v[1] = q;
616         omega_body_v[2] = r;
617     }
618
619     // inline double * get_Omega_local_v() { return omega_local_v; }
620     // inline double get_P_local() const { return omega_local_v[0]; }
621     // inline double get_Q_local() const { return omega_local_v[1]; }
622     // inline double get_R_local() const { return omega_local_v[2]; }
623     /* inline void set_Omega_Local( double p, double q, double r ) {
624         omega_local_v[0] = p;
625         omega_local_v[1] = q;
626         omega_local_v[2] = r;
627     } */
628
629     // inline double * get_Omega_total_v() { return omega_total_v; }
630     // inline double get_P_total() const { return omega_total_v[0]; }
631     // inline double get_Q_total() const { return omega_total_v[1]; }
632     // inline double get_R_total() const { return omega_total_v[2]; }
633     /* inline void set_Omega_Total( double p, double q, double r ) {
634         omega_total_v[0] = p;
635         omega_total_v[1] = q;
636         omega_total_v[2] = r;
637     } */
638
639     // inline double * get_Euler_rates_v() { return euler_rates_v; }
640     inline double get_Phi_dot() const { return euler_rates_v[0]; }
641     inline double get_Theta_dot() const { return euler_rates_v[1]; }
642     inline double get_Psi_dot() const { return euler_rates_v[2]; }
643     inline void set_Euler_Rates( double phi, double theta, double psi ) {
644         euler_rates_v[0] = phi;
645         euler_rates_v[1] = theta;
646         euler_rates_v[2] = psi;
647     }
648
649     // inline double * get_Geocentric_rates_v() { return geocentric_rates_v; }
650     inline double get_Latitude_dot() const { return geocentric_rates_v[0]; }
651     inline double get_Longitude_dot() const { return geocentric_rates_v[1]; }
652     inline double get_Radius_dot() const { return geocentric_rates_v[2]; }
653     inline void set_Geocentric_Rates( double lat, double lon, double rad ) {
654         geocentric_rates_v[0] = lat;
655         geocentric_rates_v[1] = lon;
656         geocentric_rates_v[2] = rad;
657     }
658
659     // ========== Positions ==========
660
661     // inline double * get_Geocentric_position_v() {
662     //    return geocentric_position_v;
663     // }
664     inline double get_Lat_geocentric() const {
665         return geocentric_position_v[0];
666     }
667     inline double get_Lon_geocentric() const {
668         return geocentric_position_v[1];
669     }
670     inline double get_Radius_to_vehicle() const {
671         return geocentric_position_v[2];
672     }
673     inline void set_Radius_to_vehicle(double radius) {
674         geocentric_position_v[2] = radius;
675     }
676
677     inline void set_Geocentric_Position( double lat, double lon, double rad ) {
678         geocentric_position_v[0] = lat;
679         geocentric_position_v[1] = lon;
680         geocentric_position_v[2] = rad;
681     }
682
683     // inline double * get_Geodetic_position_v() { return geodetic_position_v; }
684     inline double get_Latitude() const { return geodetic_position_v[0]; }
685     inline void set_Latitude(double lat) { geodetic_position_v[0] = lat; }
686     inline double get_Longitude() const { return geodetic_position_v[1]; }
687     inline void set_Longitude(double lon) { geodetic_position_v[1] = lon; }
688     inline double get_Altitude() const { return geodetic_position_v[2]; }
689     inline void set_Altitude(double altitude) {
690         geodetic_position_v[2] = altitude;
691     }
692     inline void set_Geodetic_Position( double lat, double lon, double alt ) {
693         geodetic_position_v[0] = lat;
694         geodetic_position_v[1] = lon;
695         geodetic_position_v[2] = alt;
696     }
697
698     // inline double * get_Euler_angles_v() { return euler_angles_v; }
699     inline double get_Phi() const { return euler_angles_v[0]; }
700     inline double get_Theta() const { return euler_angles_v[1]; }
701     inline double get_Psi() const { return euler_angles_v[2]; }
702     inline void set_Euler_Angles( double phi, double theta, double psi ) {
703         euler_angles_v[0] = phi;
704         euler_angles_v[1] = theta;
705         euler_angles_v[2] = psi;
706     }
707
708
709     // ========== Miscellaneous quantities ==========
710
711     // inline double * get_T_local_to_body_m() { return t_local_to_body_m; }
712     inline double get_T_local_to_body_11() const {
713         return t_local_to_body_m[0][0];
714     }
715     inline double get_T_local_to_body_12() const {
716         return t_local_to_body_m[0][1];
717     }
718     inline double get_T_local_to_body_13() const {
719         return t_local_to_body_m[0][2];
720     }
721     inline double get_T_local_to_body_21() const {
722         return t_local_to_body_m[1][0];
723     }
724     inline double get_T_local_to_body_22() const {
725         return t_local_to_body_m[1][1];
726     }
727     inline double get_T_local_to_body_23() const {
728         return t_local_to_body_m[1][2];
729     }
730     inline double get_T_local_to_body_31() const {
731         return t_local_to_body_m[2][0];
732     }
733     inline double get_T_local_to_body_32() const {
734         return t_local_to_body_m[2][1];
735     }
736     inline double get_T_local_to_body_33() const {
737         return t_local_to_body_m[2][2];
738     }
739     inline void set_T_Local_to_Body( int i, int j, double value) {
740         t_local_to_body_m[i-1][j-1] = value;
741     }
742     inline void set_T_Local_to_Body( double m[3][3] ) {
743         int i, j;
744         for ( i = 0; i < 3; i++ ) {
745             for ( j = 0; j < 3; j++ ) {
746                 t_local_to_body_m[i][j] = m[i][j];
747             }
748         }
749     }
750
751     // inline double get_Gravity() const { return gravity; }
752     // inline void set_Gravity(double g) { gravity = g; }
753
754     // inline double get_Centrifugal_relief() const {
755     //   return centrifugal_relief;
756     // }
757     // inline void set_Centrifugal_relief(double cr) {
758     //   centrifugal_relief = cr;
759     // }
760
761     inline double get_Alpha() const { return alpha; }
762     inline void set_Alpha( double a ) { alpha = a; }
763     inline double get_Beta() const { return beta; }
764     inline void set_Beta( double b ) { beta = b; }
765     // inline double get_Alpha_dot() const { return alpha_dot; }
766     // inline void set_Alpha_dot( double ad ) { alpha_dot = ad; }
767     // inline double get_Beta_dot() const { return beta_dot; }
768     // inline void set_Beta_dot( double bd ) { beta_dot = bd; }
769
770     // inline double get_Cos_alpha() const { return cos_alpha; }
771     // inline void set_Cos_alpha( double ca ) { cos_alpha = ca; }
772     // inline double get_Sin_alpha() const { return sin_alpha; }
773     // inline void set_Sin_alpha( double sa ) { sin_alpha = sa; }
774     // inline double get_Cos_beta() const { return cos_beta; }
775     // inline void set_Cos_beta( double cb ) { cos_beta = cb; }
776     // inline double get_Sin_beta() const { return sin_beta; }
777     // inline void set_Sin_beta( double sb ) { sin_beta = sb; }
778
779     inline double get_Cos_phi() const { return cos_phi; }
780     inline void set_Cos_phi( double cp ) { cos_phi = cp; }
781     // inline double get_Sin_phi() const { return sin_phi; }
782     // inline void set_Sin_phi( double sp ) { sin_phi = sp; }
783     inline double get_Cos_theta() const { return cos_theta; }
784     inline void set_Cos_theta( double ct ) { cos_theta = ct; }
785     // inline double get_Sin_theta() const { return sin_theta; }
786     // inline void set_Sin_theta( double st ) { sin_theta = st; }
787     // inline double get_Cos_psi() const { return cos_psi; }
788     // inline void set_Cos_psi( double cp ) { cos_psi = cp; }
789     // inline double get_Sin_psi() const { return sin_psi; }
790     // inline void set_Sin_psi( double sp ) { sin_psi = sp; }
791
792     inline double get_Gamma_vert_rad() const { return gamma_vert_rad; }
793     inline void set_Gamma_vert_rad( double gv ) { gamma_vert_rad = gv; }
794     // inline double get_Gamma_horiz_rad() const { return gamma_horiz_rad; }
795     // inline void set_Gamma_horiz_rad( double gh ) { gamma_horiz_rad = gh; }
796
797     // inline double get_Sigma() const { return sigma; }
798     // inline void set_Sigma( double s ) { sigma = s; }
799     inline double get_Density() const { return density; }
800     inline void set_Density( double d ) { density = d; }
801     // inline double get_V_sound() const { return v_sound; }
802     // inline void set_V_sound( double v ) { v_sound = v; }
803     inline double get_Mach_number() const { return mach_number; }
804     inline void set_Mach_number( double m ) { mach_number = m; }
805
806     inline double get_Static_pressure() const { return static_pressure; }
807     inline void set_Static_pressure( double sp ) { static_pressure = sp; }
808     // inline double get_Total_pressure() const { return total_pressure; }
809     // inline void set_Total_pressure( double tp ) { total_pressure = tp; }
810     // inline double get_Impact_pressure() const { return impact_pressure; }
811     // inline void set_Impact_pressure( double ip ) { impact_pressure = ip; }
812     // inline double get_Dynamic_pressure() const { return dynamic_pressure; }
813     // inline void set_Dynamic_pressure( double dp ) { dynamic_pressure = dp; }
814
815     inline double get_Static_temperature() const { return static_temperature; }
816     inline void set_Static_temperature( double t ) { static_temperature = t; }
817     // inline double get_Total_temperature() const { return total_temperature; }
818     // inline void set_Total_temperature( double t ) { total_temperature = t; }
819
820     inline double get_Sea_level_radius() const { return sea_level_radius; }
821     inline void set_Sea_level_radius( double r ) { sea_level_radius = r; }
822     inline double get_Earth_position_angle() const {
823         return earth_position_angle;
824     }
825     inline void set_Earth_position_angle(double a) {
826         earth_position_angle = a;
827     }
828
829     inline double get_Runway_altitude() const { return runway_altitude; }
830     inline void set_Runway_altitude( double alt ) { runway_altitude = alt; }
831     // inline double get_Runway_latitude() const { return runway_latitude; }
832     // inline void set_Runway_latitude( double lat ) { runway_latitude = lat; }
833     // inline double get_Runway_longitude() const { return runway_longitude; }
834     // inline void set_Runway_longitude( double lon ) {
835     //   runway_longitude = lon;
836     // }
837     // inline double get_Runway_heading() const { return runway_heading; }
838     // inline void set_Runway_heading( double h ) { runway_heading = h; }
839
840     // inline double get_Radius_to_rwy() const { return radius_to_rwy; }
841     // inline void set_Radius_to_rwy( double r ) { radius_to_rwy = r; }
842
843     // inline double * get_D_cg_rwy_local_v() { return d_cg_rwy_local_v; }
844     // inline double get_D_cg_north_of_rwy() const {
845     //   return d_cg_rwy_local_v[0];
846     // }
847     // inline double get_D_cg_east_of_rwy() const {
848     //   return d_cg_rwy_local_v[1];
849     // }
850     // inline double get_D_cg_above_rwy() const { return d_cg_rwy_local_v[2]; }
851     /* inline void set_CG_Rwy_Local( double north, double east, double above )
852     {
853         d_cg_rwy_local_v[0] = north;
854         d_cg_rwy_local_v[1] = east;
855         d_cg_rwy_local_v[2] = above;
856     } */
857
858     // inline double * get_D_cg_rwy_rwy_v() { return d_cg_rwy_rwy_v; }
859     // inline double get_X_cg_rwy() const { return d_cg_rwy_rwy_v[0]; }
860     // inline double get_Y_cg_rwy() const { return d_cg_rwy_rwy_v[1]; }
861     // inline double get_H_cg_rwy() const { return d_cg_rwy_rwy_v[2]; }
862     /* inline void set_CG_Rwy_Rwy( double x, double y, double h )
863     {
864         d_cg_rwy_rwy_v[0] = x;
865         d_cg_rwy_rwy_v[1] = y;
866         d_cg_rwy_rwy_v[2] = h;
867     } */
868
869     // inline double * get_D_pilot_rwy_local_v() { return d_pilot_rwy_local_v; }
870     // inline double get_D_pilot_north_of_rwy() const {
871     //   return d_pilot_rwy_local_v[0];
872     // }
873     // inline double get_D_pilot_east_of_rwy() const {
874     //   return d_pilot_rwy_local_v[1];
875     // }
876     // inline double get_D_pilot_above_rwy() const {
877     //   return d_pilot_rwy_local_v[2];
878     // }
879     /* inline void set_Pilot_Rwy_Local( double north, double east, double above )
880     {
881         d_pilot_rwy_local_v[0] = north;
882         d_pilot_rwy_local_v[1] = east;
883         d_pilot_rwy_local_v[2] = above;
884     } */
885
886     // inline double * get_D_pilot_rwy_rwy_v() { return d_pilot_rwy_rwy_v; }
887     // inline double get_X_pilot_rwy() const { return d_pilot_rwy_rwy_v[0]; }
888     // inline double get_Y_pilot_rwy() const { return d_pilot_rwy_rwy_v[1]; }
889     // inline double get_H_pilot_rwy() const { return d_pilot_rwy_rwy_v[2]; }
890     /* inline void set_Pilot_Rwy_Rwy( double x, double y, double h )
891     {
892         d_pilot_rwy_rwy_v[0] = x;
893         d_pilot_rwy_rwy_v[1] = y;
894         d_pilot_rwy_rwy_v[2] = h;
895     } */
896
897     inline double get_Climb_Rate() const { return climb_rate; }
898     inline void set_Climb_Rate(double rate) { climb_rate = rate; }
899
900     inline FGTimeStamp get_time_stamp() const { return valid_stamp; }
901     inline void stamp_time() { valid_stamp = next_stamp; next_stamp.stamp(); }
902
903     // Extrapolate FDM based on time_offset (in usec)
904     void extrapolate( int time_offset );
905
906     // sin/cos lat_geocentric
907     inline void set_sin_lat_geocentric(double parm) {
908         sin_lat_geocentric = sin(parm);
909     }
910     inline void set_cos_lat_geocentric(double parm) {
911         cos_lat_geocentric = cos(parm);
912     }
913     inline double get_sin_lat_geocentric(void) const {
914         return sin_lat_geocentric;
915     }
916     inline double get_cos_lat_geocentric(void) const {
917         return cos_lat_geocentric;
918     }
919
920     inline void set_sin_cos_longitude(double parm) {
921         sin_longitude = sin(parm);
922         cos_longitude = cos(parm);
923     }
924     inline double get_sin_longitude(void) const {
925         return sin_longitude;
926     }
927     inline double get_cos_longitude(void) const {
928         return cos_longitude;
929     }
930
931     inline void set_sin_cos_latitude(double parm) {
932         sin_latitude = sin(parm);
933         cos_latitude = cos(parm);
934     }
935     inline double get_sin_latitude(void) const {
936         return sin_latitude;
937     }
938     inline double get_cos_latitude(void) const {
939         return cos_latitude;
940     }
941
942     // engines
943     inline double get_num_engines() const {
944         return engines.size();
945     }
946
947     inline FGEngInterface* get_engine( int i ) {
948         return &engines[i];
949     }
950
951     inline void add_engine( FGEngInterface e ) {
952         engines.push_back( e );
953     }
954 };
955
956
957 typedef list < FGInterface > fdm_state_list;
958 typedef fdm_state_list::iterator fdm_state_list_iterator;
959 typedef fdm_state_list::const_iterator const_fdm_state_list_iterator;
960
961
962 extern FGInterface * cur_fdm_state;
963
964
965 // General interface to the flight model routines
966
967 // Initialize the flight model parameters
968 int fgFDMInit(int model, FGInterface& f, double dt);
969
970 // Run multiloop iterations of the flight model
971 int fgFDMUpdate(int model, FGInterface& f, int multiloop, int jitter);
972
973 // Set the altitude (force)
974 void fgFDMForceAltitude(int model, double alt_meters);
975
976 // Set the local ground elevation
977 void fgFDMSetGroundElevation(int model, double alt_meters);
978
979
980 #endif // _FLIGHT_HXX