]> git.mxchange.org Git - flightgear.git/blob - src/FDM/flight.hxx
81a15cabbafe6af924f52977005d1422060cc832
[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         // AEronautical DEvelopment AGEncy, Bangalore India
264         FG_ADA = 4,
265
266         // The following aren't implemented but are here to spark
267         // thoughts and discussions, and maybe even action.
268         FG_ACM = 5,
269         FG_SUPER_SONIC = 6,
270         FG_HELICOPTER = 7,
271         FG_AUTOGYRO = 8,
272         FG_PARACHUTE = 9,
273
274         // Driven externally via a serial port, net, file, etc.
275         FG_EXTERNAL = 10
276     };
277
278     // ========== Mass properties and geometry values ==========
279
280     // Inertias
281     inline double get_Mass() const { return mass; }
282     inline double get_I_xx() const { return i_xx; }
283     inline double get_I_yy() const { return i_yy; }
284     inline double get_I_zz() const { return i_zz; }
285     inline double get_I_xz() const { return i_xz; }
286     inline void set_Inertias( double m, double xx, double yy, 
287                               double zz, double xz)
288     {
289         mass = m;
290         i_xx = xx;
291         i_yy = yy;
292         i_zz = zz;
293         i_xz = xz;
294     }
295
296     // Pilot location rel to ref pt
297     // inline double * get_D_pilot_rp_body_v() {
298     //  return d_pilot_rp_body_v;
299     // }
300     // inline double get_Dx_pilot() const { return d_pilot_rp_body_v[0]; }
301     // inline double get_Dy_pilot() const { return d_pilot_rp_body_v[1]; }
302     // inline double get_Dz_pilot() const { return d_pilot_rp_body_v[2]; }
303     /* inline void set_Pilot_Location( double dx, double dy, double dz ) {
304         d_pilot_rp_body_v[0] = dx;
305         d_pilot_rp_body_v[1] = dy;
306         d_pilot_rp_body_v[2] = dz;
307     } */
308
309     // CG position w.r.t. ref. point
310     // inline double * get_D_cg_rp_body_v() { return d_cg_rp_body_v; }
311     inline double get_Dx_cg() const { return d_cg_rp_body_v[0]; }
312     inline double get_Dy_cg() const { return d_cg_rp_body_v[1]; }
313     inline double get_Dz_cg() const { return d_cg_rp_body_v[2]; }
314     inline void set_CG_Position( double dx, double dy, double dz ) {
315         d_cg_rp_body_v[0] = dx;
316         d_cg_rp_body_v[1] = dy;
317         d_cg_rp_body_v[2] = dz;
318     }
319
320     // ========== Forces ==========
321
322     // inline double * get_F_body_total_v() { return f_body_total_v; }
323     // inline double get_F_X() const { return f_body_total_v[0]; }
324     // inline double get_F_Y() const { return f_body_total_v[1]; }
325     // inline double get_F_Z() const { return f_body_total_v[2]; }
326     /* inline void set_Forces_Body_Total( double x, double y, double z ) {
327         f_body_total_v[0] = x;
328         f_body_total_v[1] = y;
329         f_body_total_v[2] = z;
330     } */
331
332     // inline double * get_F_local_total_v() { return f_local_total_v; }
333     // inline double get_F_north() const { return f_local_total_v[0]; }
334     // inline double get_F_east() const { return f_local_total_v[1]; }
335     // inline double get_F_down() const { return f_local_total_v[2]; }
336     /* inline void set_Forces_Local_Total( double x, double y, double z ) {
337         f_local_total_v[0] = x;
338         f_local_total_v[1] = y;
339         f_local_total_v[2] = z;
340     } */
341
342     // inline double * get_F_aero_v() { return f_aero_v; }
343     // inline double get_F_X_aero() const { return f_aero_v[0]; }
344     // inline double get_F_Y_aero() const { return f_aero_v[1]; }
345     // inline double get_F_Z_aero() const { return f_aero_v[2]; }
346     /* inline void set_Forces_Aero( double x, double y, double z ) {
347         f_aero_v[0] = x;
348         f_aero_v[1] = y;
349         f_aero_v[2] = z;
350     } */
351     
352     // inline double * get_F_engine_v() { return f_engine_v; }
353     // inline double get_F_X_engine() const { return f_engine_v[0]; }
354     // inline double get_F_Y_engine() const { return f_engine_v[1]; }
355     // inline double get_F_Z_engine() const { return f_engine_v[2]; }
356     /* inline void set_Forces_Engine( double x, double y, double z ) {
357         f_engine_v[0] = x;
358         f_engine_v[1] = y;
359         f_engine_v[2] = z;
360     } */
361
362     // inline double * get_F_gear_v() { return f_gear_v; }
363     // inline double get_F_X_gear() const { return f_gear_v[0]; }
364     // inline double get_F_Y_gear() const { return f_gear_v[1]; }
365     // inline double get_F_Z_gear() const { return f_gear_v[2]; }
366     /* inline void set_Forces_Gear( double x, double y, double z ) {
367         f_gear_v[0] = x;
368         f_gear_v[1] = y;
369         f_gear_v[2] = z;
370     } */
371
372     // ========== Moments ==========
373
374     // inline double * get_M_total_rp_v() { return m_total_rp_v; }
375     // inline double get_M_l_rp() const { return m_total_rp_v[0]; }
376     // inline double get_M_m_rp() const { return m_total_rp_v[1]; }
377     // inline double get_M_n_rp() const { return m_total_rp_v[2]; }
378     /* inline void set_Moments_Total_RP( double l, double m, double n ) {
379         m_total_rp_v[0] = l;
380         m_total_rp_v[1] = m;
381         m_total_rp_v[2] = n;
382     } */
383
384     // inline double * get_M_total_cg_v() { return m_total_cg_v; }
385     // inline double get_M_l_cg() const { return m_total_cg_v[0]; }
386     // inline double get_M_m_cg() const { return m_total_cg_v[1]; }
387     // inline double get_M_n_cg() const { return m_total_cg_v[2]; }
388     /* inline void set_Moments_Total_CG( double l, double m, double n ) {
389         m_total_cg_v[0] = l;
390         m_total_cg_v[1] = m;
391         m_total_cg_v[2] = n;
392     } */
393
394     // inline double * get_M_aero_v() { return m_aero_v; }
395     // inline double get_M_l_aero() const { return m_aero_v[0]; }
396     // inline double get_M_m_aero() const { return m_aero_v[1]; }
397     // inline double get_M_n_aero() const { return m_aero_v[2]; }
398     /* inline void set_Moments_Aero( double l, double m, double n ) {
399         m_aero_v[0] = l;
400         m_aero_v[1] = m;
401         m_aero_v[2] = n;
402     } */
403
404     // inline double * get_M_engine_v() { return m_engine_v; }
405     // inline double get_M_l_engine() const { return m_engine_v[0]; }
406     // inline double get_M_m_engine() const { return m_engine_v[1]; }
407     // inline double get_M_n_engine() const { return m_engine_v[2]; }
408     /* inline void set_Moments_Engine( double l, double m, double n ) {
409         m_engine_v[0] = l;
410         m_engine_v[1] = m;
411         m_engine_v[2] = n;
412     } */
413
414     // inline double * get_M_gear_v() { return m_gear_v; }
415     // inline double get_M_l_gear() const { return m_gear_v[0]; }
416     // inline double get_M_m_gear() const { return m_gear_v[1]; }
417     // inline double get_M_n_gear() const { return m_gear_v[2]; }
418     /* inline void set_Moments_Gear( double l, double m, double n ) {
419         m_gear_v[0] = l;
420         m_gear_v[1] = m;
421         m_gear_v[2] = n;
422     } */
423
424     // ========== Accelerations ==========
425
426     // inline double * get_V_dot_local_v() { return v_dot_local_v; }
427     inline double get_V_dot_north() const { return v_dot_local_v[0]; }
428     inline double get_V_dot_east() const { return v_dot_local_v[1]; }
429     inline double get_V_dot_down() const { return v_dot_local_v[2]; }
430     inline void set_Accels_Local( double north, double east, double down ) {
431         v_dot_local_v[0] = north;
432         v_dot_local_v[1] = east;
433         v_dot_local_v[2] = down;
434     }
435
436     // inline double * get_V_dot_body_v() { return v_dot_body_v; }
437     inline double get_U_dot_body() const { return v_dot_body_v[0]; }
438     inline double get_V_dot_body() const { return v_dot_body_v[1]; }
439     inline double get_W_dot_body() const { return v_dot_body_v[2]; }
440     inline void set_Accels_Body( double u, double v, double w ) {
441         v_dot_body_v[0] = u;
442         v_dot_body_v[1] = v;
443         v_dot_body_v[2] = w;
444     }
445
446     // inline double * get_A_cg_body_v() { return a_cg_body_v; }
447     inline double get_A_X_cg() const { return a_cg_body_v[0]; }
448     inline double get_A_Y_cg() const { return a_cg_body_v[1]; }
449     inline double get_A_Z_cg() const { return a_cg_body_v[2]; }
450     inline void set_Accels_CG_Body( double x, double y, double z ) {
451         a_cg_body_v[0] = x;
452         a_cg_body_v[1] = y;
453         a_cg_body_v[2] = z;
454     }
455
456     // inline double * get_A_pilot_body_v() { return a_pilot_body_v; }
457     inline double get_A_X_pilot() const { return a_pilot_body_v[0]; }
458     inline double get_A_Y_pilot() const { return a_pilot_body_v[1]; }
459     inline double get_A_Z_pilot() const { return a_pilot_body_v[2]; }
460     inline void set_Accels_Pilot_Body( double x, double y, double z ) {
461         a_pilot_body_v[0] = x;
462         a_pilot_body_v[1] = y;
463         a_pilot_body_v[2] = z;
464     }
465
466     // inline double * get_N_cg_body_v() { return n_cg_body_v; }
467     inline double get_N_X_cg() const { return n_cg_body_v[0]; }
468     inline double get_N_Y_cg() const { return n_cg_body_v[1]; }
469     inline double get_N_Z_cg() const { return n_cg_body_v[2]; }
470     inline void set_Accels_CG_Body_N( double x, double y, double z ) {
471         n_cg_body_v[0] = x;
472         n_cg_body_v[1] = y;
473         n_cg_body_v[2] = z;
474     }
475
476     // inline double * get_N_pilot_body_v() { return n_pilot_body_v; }
477     // inline double get_N_X_pilot() const { return n_pilot_body_v[0]; }
478     // inline double get_N_Y_pilot() const { return n_pilot_body_v[1]; }
479     // inline double get_N_Z_pilot() const { return n_pilot_body_v[2]; }
480     // inline void set_Accels_Pilot_Body_N( double x, double y, double z ) {
481     //    n_pilot_body_v[0] = x;
482     //    n_pilot_body_v[1] = y;
483     //    n_pilot_body_v[2] = z;
484     // }
485
486     double get_Nlf(void) { return nlf; }
487     void set_Nlf(double n) { nlf=n;  }
488
489     // inline double * get_Omega_dot_body_v() { return omega_dot_body_v; }
490     // inline double get_P_dot_body() const { return omega_dot_body_v[0]; }
491     // inline double get_Q_dot_body() const { return omega_dot_body_v[1]; }
492     // inline double get_R_dot_body() const { return omega_dot_body_v[2]; }
493     /* inline void set_Accels_Omega( double p, double q, double r ) {
494         omega_dot_body_v[0] = p;
495         omega_dot_body_v[1] = q;
496         omega_dot_body_v[2] = r;
497     } */
498
499
500     // ========== Velocities ==========
501
502     // inline double * get_V_local_v() { return v_local_v; }
503     inline double get_V_north() const { return v_local_v[0]; }
504     inline double get_V_east() const { return v_local_v[1]; }
505     inline double get_V_down() const { return v_local_v[2]; }
506     inline void set_Velocities_Local( double north, double east, double down ) {
507         v_local_v[0] = north;
508         v_local_v[1] = east;
509         v_local_v[2] = down;
510     }
511
512     // inline double * get_V_local_rel_ground_v() {
513     //     return v_local_rel_ground_v;
514     // }
515     inline double get_V_north_rel_ground() const {
516         return v_local_rel_ground_v[0];
517     }
518     inline double get_V_east_rel_ground() const {
519         return v_local_rel_ground_v[1];
520     }
521     inline double get_V_down_rel_ground() const {
522         return v_local_rel_ground_v[2];
523     }
524     inline void set_Velocities_Ground(double north, double east, double down) {
525         v_local_rel_ground_v[0] = north;
526         v_local_rel_ground_v[1] = east;
527         v_local_rel_ground_v[2] = down;
528     }
529
530     // inline double * get_V_local_airmass_v() { return v_local_airmass_v; }
531     inline double get_V_north_airmass() const { return v_local_airmass_v[0]; }
532     inline double get_V_east_airmass() const { return v_local_airmass_v[1]; }
533     inline double get_V_down_airmass() const { return v_local_airmass_v[2]; }
534     inline void set_Velocities_Local_Airmass( double north, double east, 
535                                               double down)
536     {
537         v_local_airmass_v[0] = north;
538         v_local_airmass_v[1] = east;
539         v_local_airmass_v[2] = down;
540     }
541
542     // airmass
543     // inline double * get_V_local_rel_airmass_v() {
544     //   return v_local_rel_airmass_v;
545     // }
546     // inline double get_V_north_rel_airmass() const {
547     //   return v_local_rel_airmass_v[0];
548     // }
549     // inline double get_V_east_rel_airmass() const {
550     //   return v_local_rel_airmass_v[1];
551     // }
552     // inline double get_V_down_rel_airmass() const {
553     //   return v_local_rel_airmass_v[2];
554     // }
555     /* inline void set_Velocities_Local_Rel_Airmass( double north, double east, 
556                                                   double down)
557     {
558         v_local_rel_airmass_v[0] = north;
559         v_local_rel_airmass_v[1] = east;
560         v_local_rel_airmass_v[2] = down;
561     } */
562
563     // inline double * get_V_local_gust_v() { return v_local_gust_v; }
564     // inline double get_U_gust() const { return v_local_gust_v[0]; }
565     // inline double get_V_gust() const { return v_local_gust_v[1]; }
566     // inline double get_W_gust() const { return v_local_gust_v[2]; }
567     /* inline void set_Velocities_Gust( double u, double v, double w)
568     {
569         v_local_gust_v[0] = u;
570         v_local_gust_v[1] = v;
571         v_local_gust_v[2] = w;
572     } */
573     
574     // inline double * get_V_wind_body_v() { return v_wind_body_v; }
575     inline double get_U_body() const { return v_wind_body_v[0]; }
576     inline double get_V_body() const { return v_wind_body_v[1]; }
577     inline double get_W_body() const { return v_wind_body_v[2]; }
578     inline void set_Velocities_Wind_Body( double u, double v, double w) {
579         v_wind_body_v[0] = u;
580         v_wind_body_v[1] = v;
581         v_wind_body_v[2] = w;
582     }
583
584     // inline double get_V_rel_wind() const { return v_rel_wind; }
585     // inline void set_V_rel_wind(double wind) { v_rel_wind = wind; }
586
587     // inline double get_V_true_kts() const { return v_true_kts; }
588     // inline void set_V_true_kts(double kts) { v_true_kts = kts; }
589
590     // inline double get_V_rel_ground() const { return v_rel_ground; }
591     // inline void set_V_rel_ground( double v ) { v_rel_ground = v; }
592
593     // inline double get_V_inertial() const { return v_inertial; }
594     // inline void set_V_inertial(double v) { v_inertial = v; }
595
596     inline double get_V_ground_speed() const { return v_ground_speed; }
597     inline void set_V_ground_speed( double v) { v_ground_speed = v; }
598
599     // inline double get_V_equiv() const { return v_equiv; }
600     // inline void set_V_equiv( double v ) { v_equiv = v; }
601
602     inline double get_V_equiv_kts() const { return v_equiv_kts; }
603     inline void set_V_equiv_kts( double kts ) { v_equiv_kts = kts; }
604
605     //inline double get_V_calibrated() const { return v_calibrated; }
606     //inline void set_V_calibrated( double v ) { v_calibrated = v; }
607
608     inline double get_V_calibrated_kts() const { return v_calibrated_kts; }
609     inline void set_V_calibrated_kts( double kts ) { v_calibrated_kts = kts; }
610
611     // inline double * get_Omega_body_v() { return omega_body_v; }
612     inline double get_P_body() const { return omega_body_v[0]; }
613     inline double get_Q_body() const { return omega_body_v[1]; }
614     inline double get_R_body() const { return omega_body_v[2]; }
615     inline void set_Omega_Body( double p, double q, double r ) {
616         omega_body_v[0] = p;
617         omega_body_v[1] = q;
618         omega_body_v[2] = r;
619     }
620
621     // inline double * get_Omega_local_v() { return omega_local_v; }
622     // inline double get_P_local() const { return omega_local_v[0]; }
623     // inline double get_Q_local() const { return omega_local_v[1]; }
624     // inline double get_R_local() const { return omega_local_v[2]; }
625     /* inline void set_Omega_Local( double p, double q, double r ) {
626         omega_local_v[0] = p;
627         omega_local_v[1] = q;
628         omega_local_v[2] = r;
629     } */
630
631     // inline double * get_Omega_total_v() { return omega_total_v; }
632     // inline double get_P_total() const { return omega_total_v[0]; }
633     // inline double get_Q_total() const { return omega_total_v[1]; }
634     // inline double get_R_total() const { return omega_total_v[2]; }
635     /* inline void set_Omega_Total( double p, double q, double r ) {
636         omega_total_v[0] = p;
637         omega_total_v[1] = q;
638         omega_total_v[2] = r;
639     } */
640
641     // inline double * get_Euler_rates_v() { return euler_rates_v; }
642     inline double get_Phi_dot() const { return euler_rates_v[0]; }
643     inline double get_Theta_dot() const { return euler_rates_v[1]; }
644     inline double get_Psi_dot() const { return euler_rates_v[2]; }
645     inline void set_Euler_Rates( double phi, double theta, double psi ) {
646         euler_rates_v[0] = phi;
647         euler_rates_v[1] = theta;
648         euler_rates_v[2] = psi;
649     }
650
651     // inline double * get_Geocentric_rates_v() { return geocentric_rates_v; }
652     inline double get_Latitude_dot() const { return geocentric_rates_v[0]; }
653     inline double get_Longitude_dot() const { return geocentric_rates_v[1]; }
654     inline double get_Radius_dot() const { return geocentric_rates_v[2]; }
655     inline void set_Geocentric_Rates( double lat, double lon, double rad ) {
656         geocentric_rates_v[0] = lat;
657         geocentric_rates_v[1] = lon;
658         geocentric_rates_v[2] = rad;
659     }
660
661     // ========== Positions ==========
662
663     // inline double * get_Geocentric_position_v() {
664     //    return geocentric_position_v;
665     // }
666     inline double get_Lat_geocentric() const {
667         return geocentric_position_v[0];
668     }
669     inline double get_Lon_geocentric() const {
670         return geocentric_position_v[1];
671     }
672     inline double get_Radius_to_vehicle() const {
673         return geocentric_position_v[2];
674     }
675     inline void set_Radius_to_vehicle(double radius) {
676         geocentric_position_v[2] = radius;
677     }
678
679     inline void set_Geocentric_Position( double lat, double lon, double rad ) {
680         geocentric_position_v[0] = lat;
681         geocentric_position_v[1] = lon;
682         geocentric_position_v[2] = rad;
683     }
684
685     // inline double * get_Geodetic_position_v() { return geodetic_position_v; }
686     inline double get_Latitude() const { return geodetic_position_v[0]; }
687     inline void set_Latitude(double lat) { geodetic_position_v[0] = lat; }
688     inline double get_Longitude() const { return geodetic_position_v[1]; }
689     inline void set_Longitude(double lon) { geodetic_position_v[1] = lon; }
690     inline double get_Altitude() const { return geodetic_position_v[2]; }
691     inline void set_Altitude(double altitude) {
692         geodetic_position_v[2] = altitude;
693     }
694     inline void set_Geodetic_Position( double lat, double lon, double alt ) {
695         geodetic_position_v[0] = lat;
696         geodetic_position_v[1] = lon;
697         geodetic_position_v[2] = alt;
698     }
699
700     // inline double * get_Euler_angles_v() { return euler_angles_v; }
701     inline double get_Phi() const { return euler_angles_v[0]; }
702     inline double get_Theta() const { return euler_angles_v[1]; }
703     inline double get_Psi() const { return euler_angles_v[2]; }
704     inline void set_Euler_Angles( double phi, double theta, double psi ) {
705         euler_angles_v[0] = phi;
706         euler_angles_v[1] = theta;
707         euler_angles_v[2] = psi;
708     }
709
710
711     // ========== Miscellaneous quantities ==========
712
713     // inline double * get_T_local_to_body_m() { return t_local_to_body_m; }
714     inline double get_T_local_to_body_11() const {
715         return t_local_to_body_m[0][0];
716     }
717     inline double get_T_local_to_body_12() const {
718         return t_local_to_body_m[0][1];
719     }
720     inline double get_T_local_to_body_13() const {
721         return t_local_to_body_m[0][2];
722     }
723     inline double get_T_local_to_body_21() const {
724         return t_local_to_body_m[1][0];
725     }
726     inline double get_T_local_to_body_22() const {
727         return t_local_to_body_m[1][1];
728     }
729     inline double get_T_local_to_body_23() const {
730         return t_local_to_body_m[1][2];
731     }
732     inline double get_T_local_to_body_31() const {
733         return t_local_to_body_m[2][0];
734     }
735     inline double get_T_local_to_body_32() const {
736         return t_local_to_body_m[2][1];
737     }
738     inline double get_T_local_to_body_33() const {
739         return t_local_to_body_m[2][2];
740     }
741     inline void set_T_Local_to_Body( int i, int j, double value) {
742         t_local_to_body_m[i-1][j-1] = value;
743     }
744     inline void set_T_Local_to_Body( double m[3][3] ) {
745         int i, j;
746         for ( i = 0; i < 3; i++ ) {
747             for ( j = 0; j < 3; j++ ) {
748                 t_local_to_body_m[i][j] = m[i][j];
749             }
750         }
751     }
752
753     // inline double get_Gravity() const { return gravity; }
754     // inline void set_Gravity(double g) { gravity = g; }
755
756     // inline double get_Centrifugal_relief() const {
757     //   return centrifugal_relief;
758     // }
759     // inline void set_Centrifugal_relief(double cr) {
760     //   centrifugal_relief = cr;
761     // }
762
763     inline double get_Alpha() const { return alpha; }
764     inline void set_Alpha( double a ) { alpha = a; }
765     inline double get_Beta() const { return beta; }
766     inline void set_Beta( double b ) { beta = b; }
767     // inline double get_Alpha_dot() const { return alpha_dot; }
768     // inline void set_Alpha_dot( double ad ) { alpha_dot = ad; }
769     // inline double get_Beta_dot() const { return beta_dot; }
770     // inline void set_Beta_dot( double bd ) { beta_dot = bd; }
771
772     // inline double get_Cos_alpha() const { return cos_alpha; }
773     // inline void set_Cos_alpha( double ca ) { cos_alpha = ca; }
774     // inline double get_Sin_alpha() const { return sin_alpha; }
775     // inline void set_Sin_alpha( double sa ) { sin_alpha = sa; }
776     // inline double get_Cos_beta() const { return cos_beta; }
777     // inline void set_Cos_beta( double cb ) { cos_beta = cb; }
778     // inline double get_Sin_beta() const { return sin_beta; }
779     // inline void set_Sin_beta( double sb ) { sin_beta = sb; }
780
781     inline double get_Cos_phi() const { return cos_phi; }
782     inline void set_Cos_phi( double cp ) { cos_phi = cp; }
783     // inline double get_Sin_phi() const { return sin_phi; }
784     // inline void set_Sin_phi( double sp ) { sin_phi = sp; }
785     inline double get_Cos_theta() const { return cos_theta; }
786     inline void set_Cos_theta( double ct ) { cos_theta = ct; }
787     // inline double get_Sin_theta() const { return sin_theta; }
788     // inline void set_Sin_theta( double st ) { sin_theta = st; }
789     // inline double get_Cos_psi() const { return cos_psi; }
790     // inline void set_Cos_psi( double cp ) { cos_psi = cp; }
791     // inline double get_Sin_psi() const { return sin_psi; }
792     // inline void set_Sin_psi( double sp ) { sin_psi = sp; }
793
794     inline double get_Gamma_vert_rad() const { return gamma_vert_rad; }
795     inline void set_Gamma_vert_rad( double gv ) { gamma_vert_rad = gv; }
796     // inline double get_Gamma_horiz_rad() const { return gamma_horiz_rad; }
797     // inline void set_Gamma_horiz_rad( double gh ) { gamma_horiz_rad = gh; }
798
799     // inline double get_Sigma() const { return sigma; }
800     // inline void set_Sigma( double s ) { sigma = s; }
801     inline double get_Density() const { return density; }
802     inline void set_Density( double d ) { density = d; }
803     // inline double get_V_sound() const { return v_sound; }
804     // inline void set_V_sound( double v ) { v_sound = v; }
805     inline double get_Mach_number() const { return mach_number; }
806     inline void set_Mach_number( double m ) { mach_number = m; }
807
808     inline double get_Static_pressure() const { return static_pressure; }
809     inline void set_Static_pressure( double sp ) { static_pressure = sp; }
810     // inline double get_Total_pressure() const { return total_pressure; }
811     // inline void set_Total_pressure( double tp ) { total_pressure = tp; }
812     // inline double get_Impact_pressure() const { return impact_pressure; }
813     // inline void set_Impact_pressure( double ip ) { impact_pressure = ip; }
814     // inline double get_Dynamic_pressure() const { return dynamic_pressure; }
815     // inline void set_Dynamic_pressure( double dp ) { dynamic_pressure = dp; }
816
817     inline double get_Static_temperature() const { return static_temperature; }
818     inline void set_Static_temperature( double t ) { static_temperature = t; }
819     // inline double get_Total_temperature() const { return total_temperature; }
820     // inline void set_Total_temperature( double t ) { total_temperature = t; }
821
822     inline double get_Sea_level_radius() const { return sea_level_radius; }
823     inline void set_Sea_level_radius( double r ) { sea_level_radius = r; }
824     inline double get_Earth_position_angle() const {
825         return earth_position_angle;
826     }
827     inline void set_Earth_position_angle(double a) {
828         earth_position_angle = a;
829     }
830
831     inline double get_Runway_altitude() const { return runway_altitude; }
832     inline void set_Runway_altitude( double alt ) { runway_altitude = alt; }
833     // inline double get_Runway_latitude() const { return runway_latitude; }
834     // inline void set_Runway_latitude( double lat ) { runway_latitude = lat; }
835     // inline double get_Runway_longitude() const { return runway_longitude; }
836     // inline void set_Runway_longitude( double lon ) {
837     //   runway_longitude = lon;
838     // }
839     // inline double get_Runway_heading() const { return runway_heading; }
840     // inline void set_Runway_heading( double h ) { runway_heading = h; }
841
842     // inline double get_Radius_to_rwy() const { return radius_to_rwy; }
843     // inline void set_Radius_to_rwy( double r ) { radius_to_rwy = r; }
844
845     // inline double * get_D_cg_rwy_local_v() { return d_cg_rwy_local_v; }
846     // inline double get_D_cg_north_of_rwy() const {
847     //   return d_cg_rwy_local_v[0];
848     // }
849     // inline double get_D_cg_east_of_rwy() const {
850     //   return d_cg_rwy_local_v[1];
851     // }
852     // inline double get_D_cg_above_rwy() const { return d_cg_rwy_local_v[2]; }
853     /* inline void set_CG_Rwy_Local( double north, double east, double above )
854     {
855         d_cg_rwy_local_v[0] = north;
856         d_cg_rwy_local_v[1] = east;
857         d_cg_rwy_local_v[2] = above;
858     } */
859
860     // inline double * get_D_cg_rwy_rwy_v() { return d_cg_rwy_rwy_v; }
861     // inline double get_X_cg_rwy() const { return d_cg_rwy_rwy_v[0]; }
862     // inline double get_Y_cg_rwy() const { return d_cg_rwy_rwy_v[1]; }
863     // inline double get_H_cg_rwy() const { return d_cg_rwy_rwy_v[2]; }
864     /* inline void set_CG_Rwy_Rwy( double x, double y, double h )
865     {
866         d_cg_rwy_rwy_v[0] = x;
867         d_cg_rwy_rwy_v[1] = y;
868         d_cg_rwy_rwy_v[2] = h;
869     } */
870
871     // inline double * get_D_pilot_rwy_local_v() { return d_pilot_rwy_local_v; }
872     // inline double get_D_pilot_north_of_rwy() const {
873     //   return d_pilot_rwy_local_v[0];
874     // }
875     // inline double get_D_pilot_east_of_rwy() const {
876     //   return d_pilot_rwy_local_v[1];
877     // }
878     // inline double get_D_pilot_above_rwy() const {
879     //   return d_pilot_rwy_local_v[2];
880     // }
881     /* inline void set_Pilot_Rwy_Local( double north, double east, double above )
882     {
883         d_pilot_rwy_local_v[0] = north;
884         d_pilot_rwy_local_v[1] = east;
885         d_pilot_rwy_local_v[2] = above;
886     } */
887
888     // inline double * get_D_pilot_rwy_rwy_v() { return d_pilot_rwy_rwy_v; }
889     // inline double get_X_pilot_rwy() const { return d_pilot_rwy_rwy_v[0]; }
890     // inline double get_Y_pilot_rwy() const { return d_pilot_rwy_rwy_v[1]; }
891     // inline double get_H_pilot_rwy() const { return d_pilot_rwy_rwy_v[2]; }
892     /* inline void set_Pilot_Rwy_Rwy( double x, double y, double h )
893     {
894         d_pilot_rwy_rwy_v[0] = x;
895         d_pilot_rwy_rwy_v[1] = y;
896         d_pilot_rwy_rwy_v[2] = h;
897     } */
898
899     inline double get_Climb_Rate() const { return climb_rate; }
900     inline void set_Climb_Rate(double rate) { climb_rate = rate; }
901
902     inline FGTimeStamp get_time_stamp() const { return valid_stamp; }
903     inline void stamp_time() { valid_stamp = next_stamp; next_stamp.stamp(); }
904
905     // Extrapolate FDM based on time_offset (in usec)
906     void extrapolate( int time_offset );
907
908     // sin/cos lat_geocentric
909     inline void set_sin_lat_geocentric(double parm) {
910         sin_lat_geocentric = sin(parm);
911     }
912     inline void set_cos_lat_geocentric(double parm) {
913         cos_lat_geocentric = cos(parm);
914     }
915     inline double get_sin_lat_geocentric(void) const {
916         return sin_lat_geocentric;
917     }
918     inline double get_cos_lat_geocentric(void) const {
919         return cos_lat_geocentric;
920     }
921
922     inline void set_sin_cos_longitude(double parm) {
923         sin_longitude = sin(parm);
924         cos_longitude = cos(parm);
925     }
926     inline double get_sin_longitude(void) const {
927         return sin_longitude;
928     }
929     inline double get_cos_longitude(void) const {
930         return cos_longitude;
931     }
932
933     inline void set_sin_cos_latitude(double parm) {
934         sin_latitude = sin(parm);
935         cos_latitude = cos(parm);
936     }
937     inline double get_sin_latitude(void) const {
938         return sin_latitude;
939     }
940     inline double get_cos_latitude(void) const {
941         return cos_latitude;
942     }
943
944     // engines
945     inline double get_num_engines() const {
946         return engines.size();
947     }
948
949     inline FGEngInterface* get_engine( int i ) {
950         return &engines[i];
951     }
952
953     inline void add_engine( FGEngInterface e ) {
954         engines.push_back( e );
955     }
956 };
957
958
959 typedef list < FGInterface > fdm_state_list;
960 typedef fdm_state_list::iterator fdm_state_list_iterator;
961 typedef fdm_state_list::const_iterator const_fdm_state_list_iterator;
962
963
964 extern FGInterface * cur_fdm_state;
965
966
967 // General interface to the flight model routines
968
969 // Initialize the flight model parameters
970 int fgFDMInit(int model, FGInterface& f, double dt);
971
972 // Run multiloop iterations of the flight model
973 int fgFDMUpdate(int model, FGInterface& f, int multiloop, int jitter);
974
975 // Set the altitude (force)
976 void fgFDMForceAltitude(int model, double alt_meters);
977
978 // Set the local ground elevation
979 void fgFDMSetGroundElevation(int model, double alt_meters);
980
981
982 #endif // _FLIGHT_HXX