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