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