]> git.mxchange.org Git - flightgear.git/blob - FDM/flight.hxx
4948bda9fce90342712434e84c70ef89e965629c
[flightgear.git] / 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 // (Log is kept at end of this file)
23
24
25 #ifndef _FLIGHT_HXX
26 #define _FLIGHT_HXX
27
28
29 #ifndef __cplusplus                                                          
30 # error This library requires C++
31 #endif                                   
32
33
34 /* Required get_()
35
36    `FGState::get_Longitude ()'
37    `FGState::get_Latitude ()'
38    `FGState::get_Altitude ()'
39    `FGState::get_Phi ()'
40    `FGState::get_Theta ()'
41    `FGState::get_Psi ()'
42    `FGState::get_V_equiv_kts ()'
43
44    `FGState::get_Mass ()'
45    `FGState::get_I_xx ()'
46    `FGState::get_I_yy ()'
47    `FGState::get_I_zz ()'
48    `FGState::get_I_xz ()'
49    
50    `FGState::get_V_north ()'
51    `FGState::get_V_east ()'
52    `FGState::get_V_down ()'
53
54    `FGState::get_P_Body ()'
55    `FGState::get_Q_Body ()'
56    `FGState::get_R_Body ()'
57
58    `FGState::get_Gamma_vert_rad ()'
59    `FGState::get_Climb_Rate ()'
60    `FGState::get_Alpha ()'
61    `FGState::get_Beta ()'
62
63    `FGState::get_Runway_altitude ()'
64
65    `FGState::get_Lon_geocentric ()'
66    `FGState::get_Lat_geocentric ()'
67    `FGState::get_Sea_level_radius ()'
68    `FGState::get_Earth_position_angle ()'
69
70    `FGState::get_Latitude_dot()'
71    `FGState::get_Longitude_dot()'
72    `FGState::get_Radius_dot()'
73
74    `FGState::get_Dx_cg ()'
75    `FGState::get_Dy_cg ()'
76    `FGState::get_Dz_cg ()'
77
78    `FGState::get_T_local_to_body_11 ()' ... `FGState::get_T_local_to_body_33 ()'
79
80    `FGState::get_Radius_to_vehicle ()'
81
82  */
83
84
85 #include <Time/timestamp.hxx>
86
87 #ifndef __cplusplus                                                          
88 # error This library requires C++
89 #endif                                   
90
91
92 typedef double FG_VECTOR_3[3];
93
94
95 // This is based heavily on LaRCsim/ls_generic.h
96 class FGState {
97
98 public:
99
100     // Define the various supported flight models (many not yet implemented)
101     enum {
102         // Slew (in MS terminology)
103         FG_SLEW = 0,
104         
105         // The only "real" model that is currently implemented
106         FG_LARCSIM = 1,
107
108         FG_ACM = 2,
109         FG_SUPER_SONIC = 3,
110         FG_HELICOPTER = 4,
111         FG_AUTOGYRO = 5,
112         FG_BALLOON = 6,
113         FG_PARACHUTE = 7,
114
115         // Driven externally via a serial port, net, file, etc.
116         FG_EXTERNAL = 8
117     };
118
119 /*================== Mass properties and geometry values ==================*/
120
121     // Inertias
122     double mass, i_xx, i_yy, i_zz, i_xz;
123     inline double get_Mass() const { return mass; }
124     inline double get_I_xx() const { return i_xx; }
125     inline double get_I_yy() const { return i_yy; }
126     inline double get_I_zz() const { return i_zz; }
127     inline double get_I_xz() const { return i_xz; }
128     inline void set_Inertias( double m, double xx, double yy, 
129                               double zz, double xz)
130     {
131         mass = m;
132         i_xx = xx;
133         i_yy = yy;
134         i_zz = zz;
135         i_xz = xz;
136     }
137     
138     // Pilot location rel to ref pt
139     FG_VECTOR_3 d_pilot_rp_body_v;
140     // inline double * get_D_pilot_rp_body_v() { 
141     //  return d_pilot_rp_body_v; 
142     // }
143     // inline double get_Dx_pilot() const { return d_pilot_rp_body_v[0]; }
144     // inline double get_Dy_pilot() const { return d_pilot_rp_body_v[1]; }
145     // inline double get_Dz_pilot() const { return d_pilot_rp_body_v[2]; }
146     /* inline void set_Pilot_Location( double dx, double dy, double dz ) {
147         d_pilot_rp_body_v[0] = dx;
148         d_pilot_rp_body_v[1] = dy;
149         d_pilot_rp_body_v[2] = dz;
150     } */
151
152     // CG position w.r.t. ref. point
153     FG_VECTOR_3 d_cg_rp_body_v;
154     // inline double * get_D_cg_rp_body_v() { return d_cg_rp_body_v; }
155     inline double get_Dx_cg() const { return d_cg_rp_body_v[0]; }
156     inline double get_Dy_cg() const { return d_cg_rp_body_v[1]; }
157     inline double get_Dz_cg() const { return d_cg_rp_body_v[2]; }
158     inline void set_CG_Position( double dx, double dy, double dz ) {
159         d_cg_rp_body_v[0] = dx;
160         d_cg_rp_body_v[1] = dy;
161         d_cg_rp_body_v[2] = dz;
162     }
163
164 /*================================ Forces =================================*/
165
166     FG_VECTOR_3 f_body_total_v;
167     // inline double * get_F_body_total_v() { return f_body_total_v; }
168     // inline double get_F_X() const { return f_body_total_v[0]; }
169     // inline double get_F_Y() const { return f_body_total_v[1]; }
170     // inline double get_F_Z() const { return f_body_total_v[2]; }
171     /* inline void set_Forces_Body_Total( double x, double y, double z ) {
172         f_body_total_v[0] = x;
173         f_body_total_v[1] = y;
174         f_body_total_v[2] = z;
175     } */
176
177     FG_VECTOR_3 f_local_total_v;
178     // inline double * get_F_local_total_v() { return f_local_total_v; }
179     // inline double get_F_north() const { return f_local_total_v[0]; }
180     // inline double get_F_east() const { return f_local_total_v[1]; }
181     // inline double get_F_down() const { return f_local_total_v[2]; }
182     /* inline void set_Forces_Local_Total( double x, double y, double z ) {
183         f_local_total_v[0] = x;
184         f_local_total_v[1] = y;
185         f_local_total_v[2] = z;
186     } */
187
188     FG_VECTOR_3 f_aero_v;
189     // inline double * get_F_aero_v() { return f_aero_v; }
190     // inline double get_F_X_aero() const { return f_aero_v[0]; }
191     // inline double get_F_Y_aero() const { return f_aero_v[1]; }
192     // inline double get_F_Z_aero() const { return f_aero_v[2]; }
193     /* inline void set_Forces_Aero( double x, double y, double z ) {
194         f_aero_v[0] = x;
195         f_aero_v[1] = y;
196         f_aero_v[2] = z;
197     } */
198     
199     FG_VECTOR_3 f_engine_v;
200     // inline double * get_F_engine_v() { return f_engine_v; }
201     // inline double get_F_X_engine() const { return f_engine_v[0]; }
202     // inline double get_F_Y_engine() const { return f_engine_v[1]; }
203     // inline double get_F_Z_engine() const { return f_engine_v[2]; }
204     /* inline void set_Forces_Engine( double x, double y, double z ) {
205         f_engine_v[0] = x;
206         f_engine_v[1] = y;
207         f_engine_v[2] = z;
208     } */
209
210     FG_VECTOR_3 f_gear_v;
211     // inline double * get_F_gear_v() { return f_gear_v; }
212     // inline double get_F_X_gear() const { return f_gear_v[0]; }
213     // inline double get_F_Y_gear() const { return f_gear_v[1]; }
214     // inline double get_F_Z_gear() const { return f_gear_v[2]; }
215     /* inline void set_Forces_Gear( double x, double y, double z ) {
216         f_gear_v[0] = x;
217         f_gear_v[1] = y;
218         f_gear_v[2] = z;
219     } */
220
221     /*================================ Moments ================================*/
222
223     FG_VECTOR_3 m_total_rp_v;
224     // inline double * get_M_total_rp_v() { return m_total_rp_v; }
225     // inline double get_M_l_rp() const { return m_total_rp_v[0]; }
226     // inline double get_M_m_rp() const { return m_total_rp_v[1]; }
227     // inline double get_M_n_rp() const { return m_total_rp_v[2]; }
228     /* inline void set_Moments_Total_RP( double l, double m, double n ) {
229         m_total_rp_v[0] = l;
230         m_total_rp_v[1] = m;
231         m_total_rp_v[2] = n;
232     } */
233
234     FG_VECTOR_3 m_total_cg_v;
235     // inline double * get_M_total_cg_v() { return m_total_cg_v; }
236     // inline double get_M_l_cg() const { return m_total_cg_v[0]; }
237     // inline double get_M_m_cg() const { return m_total_cg_v[1]; }
238     // inline double get_M_n_cg() const { return m_total_cg_v[2]; }
239     /* inline void set_Moments_Total_CG( double l, double m, double n ) {
240         m_total_cg_v[0] = l;
241         m_total_cg_v[1] = m;
242         m_total_cg_v[2] = n;
243     } */
244
245     FG_VECTOR_3 m_aero_v;
246     // inline double * get_M_aero_v() { return m_aero_v; }
247     // inline double get_M_l_aero() const { return m_aero_v[0]; }
248     // inline double get_M_m_aero() const { return m_aero_v[1]; }
249     // inline double get_M_n_aero() const { return m_aero_v[2]; }
250     /* inline void set_Moments_Aero( double l, double m, double n ) {
251         m_aero_v[0] = l;
252         m_aero_v[1] = m;
253         m_aero_v[2] = n;
254     } */
255
256     FG_VECTOR_3    m_engine_v;
257     // inline double * get_M_engine_v() { return m_engine_v; }
258     // inline double get_M_l_engine() const { return m_engine_v[0]; }
259     // inline double get_M_m_engine() const { return m_engine_v[1]; }
260     // inline double get_M_n_engine() const { return m_engine_v[2]; }
261     /* inline void set_Moments_Engine( double l, double m, double n ) {
262         m_engine_v[0] = l;
263         m_engine_v[1] = m;
264         m_engine_v[2] = n;
265     } */
266
267     FG_VECTOR_3    m_gear_v;
268     // inline double * get_M_gear_v() { return m_gear_v; }
269     // inline double get_M_l_gear() const { return m_gear_v[0]; }
270     // inline double get_M_m_gear() const { return m_gear_v[1]; }
271     // inline double get_M_n_gear() const { return m_gear_v[2]; }
272     /* inline void set_Moments_Gear( double l, double m, double n ) {
273         m_gear_v[0] = l;
274         m_gear_v[1] = m;
275         m_gear_v[2] = n;
276     } */
277
278     /*============================== Accelerations ============================*/
279
280     FG_VECTOR_3    v_dot_local_v;
281     // inline double * get_V_dot_local_v() { return v_dot_local_v; }
282     // inline double get_V_dot_north() const { return v_dot_local_v[0]; }
283     // inline double get_V_dot_east() const { return v_dot_local_v[1]; }
284     // inline double get_V_dot_down() const { return v_dot_local_v[2]; }
285     /* inline void set_Accels_Local( double north, double east, double down ) {
286         v_dot_local_v[0] = north;
287         v_dot_local_v[1] = east;
288         v_dot_local_v[2] = down;
289     } */
290
291     FG_VECTOR_3    v_dot_body_v;
292     // inline double * get_V_dot_body_v() { return v_dot_body_v; }
293     // inline double get_U_dot_body() const { return v_dot_body_v[0]; }
294     // inline double get_V_dot_body() const { return v_dot_body_v[1]; }
295     // inline double get_W_dot_body() const { return v_dot_body_v[2]; }
296     /* inline void set_Accels_Body( double u, double v, double w ) {
297         v_dot_local_v[0] = u;
298         v_dot_local_v[1] = v;
299         v_dot_local_v[2] = w;
300     } */
301
302     FG_VECTOR_3    a_cg_body_v;
303     // inline double * get_A_cg_body_v() { return a_cg_body_v; }
304     // inline double get_A_X_cg() const { return a_cg_body_v[0]; }
305     // inline double get_A_Y_cg() const { return a_cg_body_v[1]; }
306     // inline double get_A_Z_cg() const { return a_cg_body_v[2]; }
307     /* inline void set_Accels_CG_Body( double x, double y, double z ) {
308         a_cg_body_v[0] = x;
309         a_cg_body_v[1] = y;
310         a_cg_body_v[2] = z;
311     } */
312
313     FG_VECTOR_3    a_pilot_body_v;
314     // inline double * get_A_pilot_body_v() { return a_pilot_body_v; }
315     // inline double get_A_X_pilot() const { return a_pilot_body_v[0]; }
316     // inline double get_A_Y_pilot() const { return a_pilot_body_v[1]; }
317     // inline double get_A_Z_pilot() const { return a_pilot_body_v[2]; }
318     /* inline void set_Accels_Pilot_Body( double x, double y, double z ) {
319         a_pilot_body_v[0] = x;
320         a_pilot_body_v[1] = y;
321         a_pilot_body_v[2] = z;
322     } */
323
324     FG_VECTOR_3    n_cg_body_v;
325     // inline double * get_N_cg_body_v() { return n_cg_body_v; }
326     // inline double get_N_X_cg() const { return n_cg_body_v[0]; }
327     // inline double get_N_Y_cg() const { return n_cg_body_v[1]; }
328     // inline double get_N_Z_cg() const { return n_cg_body_v[2]; }
329     /* inline void set_Accels_CG_Body_N( double x, double y, double z ) {
330         n_cg_body_v[0] = x;
331         n_cg_body_v[1] = y;
332         n_cg_body_v[2] = z;
333     } */
334
335     FG_VECTOR_3    n_pilot_body_v;
336     // inline double * get_N_pilot_body_v() { return n_pilot_body_v; }
337     // inline double get_N_X_pilot() const { return n_pilot_body_v[0]; }
338     // inline double get_N_Y_pilot() const { return n_pilot_body_v[1]; }
339     // inline double get_N_Z_pilot() const { return n_pilot_body_v[2]; }
340     /* inline void set_Accels_Pilot_Body_N( double x, double y, double z ) {
341         n_pilot_body_v[0] = x;
342         n_pilot_body_v[1] = y;
343         n_pilot_body_v[2] = z;
344     } */
345
346     FG_VECTOR_3    omega_dot_body_v;
347     // inline double * get_Omega_dot_body_v() { return omega_dot_body_v; }
348     // inline double get_P_dot_body() const { return omega_dot_body_v[0]; }
349     // inline double get_Q_dot_body() const { return omega_dot_body_v[1]; }
350     // inline double get_R_dot_body() const { return omega_dot_body_v[2]; }
351     /* inline void set_Accels_Omega( double p, double q, double r ) {
352         omega_dot_body_v[0] = p;
353         omega_dot_body_v[1] = q;
354         omega_dot_body_v[2] = r;
355     } */
356
357
358     /*============================== Velocities ===============================*/
359
360     FG_VECTOR_3    v_local_v;
361     // inline double * get_V_local_v() { return v_local_v; }
362     inline double get_V_north() const { return v_local_v[0]; }
363     inline double get_V_east() const { return v_local_v[1]; }
364     inline double get_V_down() const { return v_local_v[2]; }
365     inline void set_Velocities_Local( double north, double east, double down ) {
366         v_local_v[0] = north;
367         v_local_v[1] = east;
368         v_local_v[2] = down;
369     }
370
371     FG_VECTOR_3    v_local_rel_ground_v; // V rel w.r.t. earth surface  
372     // inline double * get_V_local_rel_ground_v() { return v_local_rel_ground_v; }
373     // inline double get_V_north_rel_ground() const {
374     //  return v_local_rel_ground_v[0];
375     //    }
376     // inline double get_V_east_rel_ground() const {
377     //  return v_local_rel_ground_v[1];
378     //    }
379     // inline double get_V_down_rel_ground() const {
380     //  return v_local_rel_ground_v[2];
381     //    }
382     /* inline void set_Velocities_Ground(double north, double east, double down) {
383         v_local_rel_ground_v[0] = north;
384         v_local_rel_ground_v[1] = east;
385         v_local_rel_ground_v[2] = down;
386     } */
387
388     FG_VECTOR_3    v_local_airmass_v;   // velocity of airmass (steady winds)
389     // inline double * get_V_local_airmass_v() { return v_local_airmass_v; }
390     // inline double get_V_north_airmass() const { return v_local_airmass_v[0]; }
391     // inline double get_V_east_airmass() const { return v_local_airmass_v[1]; }
392     // inline double get_V_down_airmass() const { return v_local_airmass_v[2]; }
393     /* inline void set_Velocities_Local_Airmass( double north, double east, 
394                                               double down)
395     {
396         v_local_airmass_v[0] = north;
397         v_local_airmass_v[1] = east;
398         v_local_airmass_v[2] = down;
399     } */
400
401     FG_VECTOR_3    v_local_rel_airmass_v;  // velocity of veh. relative to
402     // airmass
403     // inline double * get_V_local_rel_airmass_v() {
404         //return v_local_rel_airmass_v;
405     //}
406     // inline double get_V_north_rel_airmass() const {
407         //return v_local_rel_airmass_v[0];
408     //}
409     // inline double get_V_east_rel_airmass() const {
410         //return v_local_rel_airmass_v[1];
411     //}
412     // inline double get_V_down_rel_airmass() const {
413         //return v_local_rel_airmass_v[2];
414     //}
415     /* inline void set_Velocities_Local_Rel_Airmass( double north, double east, 
416                                                   double down)
417     {
418         v_local_rel_airmass_v[0] = north;
419         v_local_rel_airmass_v[1] = east;
420         v_local_rel_airmass_v[2] = down;
421     } */
422
423     FG_VECTOR_3    v_local_gust_v; // linear turbulence components, L frame
424     // inline double * get_V_local_gust_v() { return v_local_gust_v; }
425     // inline double get_U_gust() const { return v_local_gust_v[0]; }
426     // inline double get_V_gust() const { return v_local_gust_v[1]; }
427     // inline double get_W_gust() const { return v_local_gust_v[2]; }
428     /* inline void set_Velocities_Gust( double u, double v, double w)
429     {
430         v_local_gust_v[0] = u;
431         v_local_gust_v[1] = v;
432         v_local_gust_v[2] = w;
433     } */
434     
435     FG_VECTOR_3    v_wind_body_v;  // Wind-relative velocities in body axis
436     // inline double * get_V_wind_body_v() { return v_wind_body_v; }
437     // inline double get_U_body() const { return v_wind_body_v[0]; }
438     // inline double get_V_body() const { return v_wind_body_v[1]; }
439     // inline double get_W_body() const { return v_wind_body_v[2]; }
440     /* inline void set_Velocities_Wind_Body( double u, double v, double w)
441     {
442         v_wind_body_v[0] = u;
443         v_wind_body_v[1] = v;
444         v_wind_body_v[2] = w;
445     } */
446
447     double    v_rel_wind, v_true_kts, v_rel_ground, v_inertial;
448     double    v_ground_speed, v_equiv, v_equiv_kts;
449     double    v_calibrated, v_calibrated_kts;
450
451     // inline double get_V_rel_wind() const { return v_rel_wind; }
452     // inline void set_V_rel_wind(double wind) { v_rel_wind = wind; }
453
454     // inline double get_V_true_kts() const { return v_true_kts; }
455     // inline void set_V_true_kts(double kts) { v_true_kts = kts; }
456
457     // inline double get_V_rel_ground() const { return v_rel_ground; }
458     // inline void set_V_rel_ground( double v ) { v_rel_ground = v; }
459
460     // inline double get_V_inertial() const { return v_inertial; }
461     // inline void set_V_inertial(double v) { v_inertial = v; }
462
463     // inline double get_V_ground_speed() const { return v_ground_speed; }
464     // inline void set_V_ground_speed( double v) { v_ground_speed = v; }
465
466     // inline double get_V_equiv() const { return v_equiv; }
467     // inline void set_V_equiv( double v ) { v_equiv = v; }
468
469     inline double get_V_equiv_kts() const { return v_equiv_kts; }
470     inline void set_V_equiv_kts( double kts ) { v_equiv_kts = kts; }
471
472     // inline double get_V_calibrated() const { return v_calibrated; }
473     // inline void set_V_calibrated( double v ) { v_calibrated = v; }
474
475     // inline double get_V_calibrated_kts() const { return v_calibrated_kts; }
476     // inline void set_V_calibrated_kts( double kts ) { v_calibrated_kts = kts; }
477
478     FG_VECTOR_3    omega_body_v;   // Angular B rates     
479     // inline double * get_Omega_body_v() { return omega_body_v; }
480     inline double get_P_body() const { return omega_body_v[0]; }
481     inline double get_Q_body() const { return omega_body_v[1]; }
482     inline double get_R_body() const { return omega_body_v[2]; }
483     inline void set_Omega_Body( double p, double q, double r ) {
484         omega_body_v[0] = p;
485         omega_body_v[1] = q;
486         omega_body_v[2] = r;
487     }
488
489     FG_VECTOR_3    omega_local_v;  // Angular L rates     
490     // inline double * get_Omega_local_v() { return omega_local_v; }
491     // inline double get_P_local() const { return omega_local_v[0]; }
492     // inline double get_Q_local() const { return omega_local_v[1]; }
493     // inline double get_R_local() const { return omega_local_v[2]; }
494     /* inline void set_Omega_Local( double p, double q, double r ) {
495         omega_local_v[0] = p;
496         omega_local_v[1] = q;
497         omega_local_v[2] = r;
498     } */
499
500     FG_VECTOR_3    omega_total_v;  // Diff btw B & L      
501     // inline double * get_Omega_total_v() { return omega_total_v; }
502     // inline double get_P_total() const { return omega_total_v[0]; }
503     // inline double get_Q_total() const { return omega_total_v[1]; }
504     // inline double get_R_total() const { return omega_total_v[2]; }
505     /* inline void set_Omega_Total( double p, double q, double r ) {
506         omega_total_v[0] = p;
507         omega_total_v[1] = q;
508         omega_total_v[2] = r;
509     } */
510
511     FG_VECTOR_3    euler_rates_v;
512     // inline double * get_Euler_rates_v() { return euler_rates_v; }
513     // inline double get_Phi_dot() const { return euler_rates_v[0]; }
514     // inline double get_Theta_dot() const { return euler_rates_v[1]; }
515     // inline double get_Psi_dot() const { return euler_rates_v[2]; }
516     /* inline void set_Euler_Rates( double phi, double theta, double psi ) {
517         euler_rates_v[0] = phi;
518         euler_rates_v[1] = theta;
519         euler_rates_v[2] = psi;
520     } */
521
522     FG_VECTOR_3    geocentric_rates_v;     // Geocentric linear velocities
523     // inline double * get_Geocentric_rates_v() { return geocentric_rates_v; }
524     inline double get_Latitude_dot() const { return geocentric_rates_v[0]; }
525     inline double get_Longitude_dot() const { return geocentric_rates_v[1]; }
526     inline double get_Radius_dot() const { return geocentric_rates_v[2]; }
527     inline void set_Geocentric_Rates( double lat, double lon, double rad ) {
528         geocentric_rates_v[0] = lat;
529         geocentric_rates_v[1] = lon;
530         geocentric_rates_v[2] = rad;
531     }
532     
533     /*=============================== Positions ===============================*/
534
535     FG_VECTOR_3    geocentric_position_v;
536     // inline double * get_Geocentric_position_v() {
537     //    return geocentric_position_v;
538     // }
539     inline double get_Lat_geocentric() const {
540         return geocentric_position_v[0];
541     }
542     inline double get_Lon_geocentric() const { 
543         return geocentric_position_v[1];
544     }
545     inline double get_Radius_to_vehicle() const {
546         return geocentric_position_v[2];
547     }
548     inline void set_Radius_to_vehicle(double radius) {
549         geocentric_position_v[2] = radius;
550     }
551
552     inline void set_Geocentric_Position( double lat, double lon, double rad ) {
553         geocentric_position_v[0] = lat;
554         geocentric_position_v[1] = lon;
555         geocentric_position_v[2] = rad;
556     }
557
558     FG_VECTOR_3    geodetic_position_v;
559     // inline double * get_Geodetic_position_v() { return geodetic_position_v; }
560     inline double get_Latitude() const { return geodetic_position_v[0]; }
561     inline void set_Latitude(double lat) { geodetic_position_v[0] = lat; }
562     inline double get_Longitude() const { return geodetic_position_v[1]; }
563     inline void set_Longitude(double lon) { geodetic_position_v[1] = lon; }
564     inline double get_Altitude() const { return geodetic_position_v[2]; }
565     inline void set_Altitude(double altitude) {
566         geodetic_position_v[2] = altitude;
567     }
568     inline void set_Geodetic_Position( double lat, double lon, double alt ) {
569         geodetic_position_v[0] = lat;
570         geodetic_position_v[1] = lon;
571         geodetic_position_v[2] = alt;
572     }
573
574     FG_VECTOR_3 euler_angles_v;
575     // inline double * get_Euler_angles_v() { return euler_angles_v; }
576     inline double get_Phi() const { return euler_angles_v[0]; }
577     inline double get_Theta() const { return euler_angles_v[1]; }
578     inline double get_Psi() const { return euler_angles_v[2]; }
579     inline void set_Euler_Angles( double phi, double theta, double psi ) {
580         euler_angles_v[0] = phi;
581         euler_angles_v[1] = theta;
582         euler_angles_v[2] = psi;
583     }
584
585
586     /*======================= Miscellaneous quantities ========================*/
587
588     double    t_local_to_body_m[3][3];    // Transformation matrix L to B
589     // inline double * get_T_local_to_body_m() { return t_local_to_body_m; }
590     inline double get_T_local_to_body_11() const {
591         return t_local_to_body_m[0][0];
592     }
593     inline double get_T_local_to_body_12() const {
594         return t_local_to_body_m[0][1];
595     }
596     inline double get_T_local_to_body_13() const {
597         return t_local_to_body_m[0][2];
598     }
599     inline double get_T_local_to_body_21() const {
600         return t_local_to_body_m[1][0];
601     }
602     inline double get_T_local_to_body_22() const {
603         return t_local_to_body_m[1][1];
604     }
605     inline double get_T_local_to_body_23() const {
606         return t_local_to_body_m[1][2];
607     }
608     inline double get_T_local_to_body_31() const {
609         return t_local_to_body_m[2][0];
610     }
611     inline double get_T_local_to_body_32() const {
612         return t_local_to_body_m[2][1];
613     }
614     inline double get_T_local_to_body_33() const {
615         return t_local_to_body_m[2][2];
616     }
617     inline void set_T_Local_to_Body( double m[3][3] ) {
618         int i, j;
619         for ( i = 0; i < 3; i++ ) {
620             for ( j = 0; j < 3; j++ ) {
621                 t_local_to_body_m[i][j] = m[i][j];
622             }
623         }
624     }
625
626     double    gravity;            // Local acceleration due to G 
627     // inline double get_Gravity() const { return gravity; }
628     // inline void set_Gravity(double g) { gravity = g; }
629     
630     double    centrifugal_relief; // load factor reduction due to speed
631     // inline double get_Centrifugal_relief() const { return centrifugal_relief; }
632     // inline void set_Centrifugal_relief(double cr) { centrifugal_relief = cr; }
633
634     double    alpha, beta, alpha_dot, beta_dot;   // in radians  
635     inline double get_Alpha() const { return alpha; }
636     inline void set_Alpha( double a ) { alpha = a; }
637     inline double get_Beta() const { return beta; }
638     inline void set_Beta( double b ) { beta = b; }
639     // inline double get_Alpha_dot() const { return alpha_dot; }
640     // inline void set_Alpha_dot( double ad ) { alpha_dot = ad; }
641     // inline double get_Beta_dot() const { return beta_dot; }
642     // inline void set_Beta_dot( double bd ) { beta_dot = bd; }
643
644     double    cos_alpha, sin_alpha, cos_beta, sin_beta;
645     // inline double get_Cos_alpha() const { return cos_alpha; }
646     // inline void set_Cos_alpha( double ca ) { cos_alpha = ca; }
647     // inline double get_Sin_alpha() const { return sin_alpha; }
648     // inline void set_Sin_alpha( double sa ) { sin_alpha = sa; }
649     // inline double get_Cos_beta() const { return cos_beta; }
650     // inline void set_Cos_beta( double cb ) { cos_beta = cb; }
651     // inline double get_Sin_beta() const { return sin_beta; }
652     // inline void set_Sin_beta( double sb ) { sin_beta = sb; }
653
654     double    cos_phi, sin_phi, cos_theta, sin_theta, cos_psi, sin_psi;
655     // inline double get_Cos_phi() const { return cos_phi; }
656     // inline void set_Cos_phi( double cp ) { cos_phi = cp; }
657     // inline double get_Sin_phi() const { return sin_phi; }
658     // inline void set_Sin_phi( double sp ) { sin_phi = sp; }
659     // inline double get_Cos_theta() const { return cos_theta; }
660     // inline void set_Cos_theta( double ct ) { cos_theta = ct; }
661     // inline double get_Sin_theta() const { return sin_theta; }
662     // inline void set_Sin_theta( double st ) { sin_theta = st; }
663     // inline double get_Cos_psi() const { return cos_psi; }
664     // inline void set_Cos_psi( double cp ) { cos_psi = cp; }
665     // inline double get_Sin_psi() const { return sin_psi; }
666     // inline void set_Sin_psi( double sp ) { sin_psi = sp; }
667
668     double    gamma_vert_rad, gamma_horiz_rad;    // Flight path angles  
669     inline double get_Gamma_vert_rad() const { return gamma_vert_rad; }
670     inline void set_Gamma_vert_rad( double gv ) { gamma_vert_rad = gv; }
671     // inline double get_Gamma_horiz_rad() const { return gamma_horiz_rad; }
672     // inline void set_Gamma_horiz_rad( double gh ) { gamma_horiz_rad = gh; }
673
674     double    sigma, density, v_sound, mach_number;
675     // inline double get_Sigma() const { return sigma; }
676     // inline void set_Sigma( double s ) { sigma = s; }
677     // inline double get_Density() const { return density; }
678     // inline void set_Density( double d ) { density = d; }
679     // inline double get_V_sound() const { return v_sound; }
680     // inline void set_V_sound( double v ) { v_sound = v; }
681     // inline double get_Mach_number() const { return mach_number; }
682     // inline void set_Mach_number( double m ) { mach_number = m; }
683
684     double    static_pressure, total_pressure, impact_pressure;
685     double    dynamic_pressure;
686     // inline double get_Static_pressure() const { return static_pressure; }
687     // inline void set_Static_pressure( double sp ) { static_pressure = sp; }
688     // inline double get_Total_pressure() const { return total_pressure; }
689     // inline void set_Total_pressure( double tp ) { total_pressure = tp; }
690     // inline double get_Impact_pressure() const { return impact_pressure; }
691     // inline void set_Impact_pressure( double ip ) { impact_pressure = ip; }
692     // inline double get_Dynamic_pressure() const { return dynamic_pressure; }
693     // inline void set_Dynamic_pressure( double dp ) { dynamic_pressure = dp; }
694
695     double    static_temperature, total_temperature;
696     // inline double get_Static_temperature() const { return static_temperature; }
697     // inline void set_Static_temperature( double t ) { static_temperature = t; }
698     // inline double get_Total_temperature() const { return total_temperature; }
699     // inline void set_Total_temperature( double t ) { total_temperature = t; }
700
701     double    sea_level_radius, earth_position_angle;
702     inline double get_Sea_level_radius() const { return sea_level_radius; }
703     inline void set_Sea_level_radius( double r ) { sea_level_radius = r; }
704     inline double get_Earth_position_angle() const {
705         return earth_position_angle;
706     }
707     inline void set_Earth_position_angle(double a) { 
708         earth_position_angle = a;
709     }
710
711     double    runway_altitude, runway_latitude, runway_longitude;
712     double    runway_heading;
713     inline double get_Runway_altitude() const { return runway_altitude; }
714     inline void set_Runway_altitude( double alt ) { runway_altitude = alt; }
715     // inline double get_Runway_latitude() const { return runway_latitude; }
716     // inline void set_Runway_latitude( double lat ) { runway_latitude = lat; }
717     // inline double get_Runway_longitude() const { return runway_longitude; }
718     // inline void set_Runway_longitude( double lon ) { runway_longitude = lon; }
719     // inline double get_Runway_heading() const { return runway_heading; }
720     // inline void set_Runway_heading( double h ) { runway_heading = h; }
721
722     double    radius_to_rwy;
723     // inline double get_Radius_to_rwy() const { return radius_to_rwy; }
724     // inline void set_Radius_to_rwy( double r ) { radius_to_rwy = r; }
725
726     FG_VECTOR_3    d_cg_rwy_local_v;       // CG rel. to rwy in local coords
727     // inline double * get_D_cg_rwy_local_v() { return d_cg_rwy_local_v; }
728     // inline double get_D_cg_north_of_rwy() const { return d_cg_rwy_local_v[0]; }
729     // inline double get_D_cg_east_of_rwy() const { return d_cg_rwy_local_v[1]; }
730     // inline double get_D_cg_above_rwy() const { return d_cg_rwy_local_v[2]; }
731     /* inline void set_CG_Rwy_Local( double north, double east, double above )
732     {
733         d_cg_rwy_local_v[0] = north;
734         d_cg_rwy_local_v[1] = east;
735         d_cg_rwy_local_v[2] = above;
736     } */
737
738     FG_VECTOR_3    d_cg_rwy_rwy_v; // CG relative to rwy, in rwy coordinates
739     // inline double * get_D_cg_rwy_rwy_v() { return d_cg_rwy_rwy_v; }
740     // inline double get_X_cg_rwy() const { return d_cg_rwy_rwy_v[0]; }
741     // inline double get_Y_cg_rwy() const { return d_cg_rwy_rwy_v[1]; }
742     // inline double get_H_cg_rwy() const { return d_cg_rwy_rwy_v[2]; }
743     /* inline void set_CG_Rwy_Rwy( double x, double y, double h )
744     {
745         d_cg_rwy_rwy_v[0] = x;
746         d_cg_rwy_rwy_v[1] = y;
747         d_cg_rwy_rwy_v[2] = h;
748     } */
749
750     FG_VECTOR_3    d_pilot_rwy_local_v;  // pilot rel. to rwy in local coords
751     // inline double * get_D_pilot_rwy_local_v() { return d_pilot_rwy_local_v; }
752     // inline double get_D_pilot_north_of_rwy() const {
753         //return d_pilot_rwy_local_v[0];
754   //  }
755     // inline double get_D_pilot_east_of_rwy() const {
756 //      return d_pilot_rwy_local_v[1];
757 //    }
758     // inline double get_D_pilot_above_rwy() const {
759         //return d_pilot_rwy_local_v[2];
760  //   }
761     /* inline void set_Pilot_Rwy_Local( double north, double east, double above )
762     {
763         d_pilot_rwy_local_v[0] = north;
764         d_pilot_rwy_local_v[1] = east;
765         d_pilot_rwy_local_v[2] = above;
766     } */
767
768     FG_VECTOR_3   d_pilot_rwy_rwy_v;   // pilot rel. to rwy, in rwy coords.
769     // inline double * get_D_pilot_rwy_rwy_v() { return d_pilot_rwy_rwy_v; }
770     // inline double get_X_pilot_rwy() const { return d_pilot_rwy_rwy_v[0]; }
771     // inline double get_Y_pilot_rwy() const { return d_pilot_rwy_rwy_v[1]; }
772     // inline double get_H_pilot_rwy() const { return d_pilot_rwy_rwy_v[2]; }
773     /* inline void set_Pilot_Rwy_Rwy( double x, double y, double h )
774     {
775         d_pilot_rwy_rwy_v[0] = x;
776         d_pilot_rwy_rwy_v[1] = y;
777         d_pilot_rwy_rwy_v[2] = h;
778     } */
779
780     double        climb_rate;           // in feet per second
781     inline double get_Climb_Rate() const { return climb_rate; }
782     inline void set_Climb_Rate(double rate) { climb_rate = rate; }
783
784     FGTimeStamp valid_stamp;       // time this record is valid
785     FGTimeStamp next_stamp;       // time this record is valid
786     inline FGTimeStamp get_time_stamp() const { return valid_stamp; }
787     inline void stamp_time() { valid_stamp = next_stamp; next_stamp.stamp(); }
788
789     // Extrapolate FDM based on time_offset (in usec)
790     void extrapolate( int time_offset );
791
792 };
793
794
795 extern FGState cur_fdm_state;
796
797
798 // General interface to the flight model routines
799
800 // Initialize the flight model parameters
801 int fgFDMInit(int model, FGState& f, double dt);
802
803 // Run multiloop iterations of the flight model
804 int fgFDMUpdate(int model, FGState& f, int multiloop, int jitter);
805
806 // Set the altitude (force)
807 void fgFDMForceAltitude(int model, double alt_meters);
808
809 // Set the local ground elevation
810 void fgFDMSetGroundElevation(int model, double alt_meters);
811
812
813 #endif // _FLIGHT_HXX
814
815
816 // $Log$
817 // Revision 1.12  1999/01/20 13:42:23  curt
818 // Tweaked FDM interface.
819 // Testing check sum support for NMEA serial output.
820 //
821 // Revision 1.11  1999/01/19 17:52:07  curt
822 // Working on being able to extrapolate a new position and orientation
823 // based on a position, orientation, and time offset.
824 //
825 // Revision 1.10  1999/01/09 13:37:33  curt
826 // Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
827 //
828 // Revision 1.9  1999/01/08 19:27:38  curt
829 // Fixed AOA reading on HUD.
830 // Continued work on time jitter compensation.
831 //
832 // Revision 1.8  1999/01/08 03:23:52  curt
833 // Beginning work on compensating for sim time vs. real world time "jitter".
834 //
835 // Revision 1.7  1998/12/18 23:37:09  curt
836 // Collapsed out the FGState variables not currently needed.  They are just
837 // commented out and can be readded easily at any time.  The point of this
838 // exersize is to determine which variables were or were not currently being
839 // used.
840 //
841 // Revision 1.6  1998/12/05 15:54:12  curt
842 // Renamed class fgFLIGHT to class FGState as per request by JSB.
843 //
844 // Revision 1.5  1998/12/04 01:29:40  curt
845 // Stubbed in a new flight model called "External" which is expected to be driven
846 // from some external source.
847 //
848 // Revision 1.4  1998/12/03 04:25:03  curt
849 // Working on fixing up new fgFLIGHT class.
850 //
851 // Revision 1.3  1998/12/03 01:16:41  curt
852 // Converted fgFLIGHT to a class.
853 //
854 // Revision 1.2  1998/10/16 23:27:41  curt
855 // C++-ifying.
856 //
857 // Revision 1.1  1998/10/16 20:16:44  curt
858 // Renamed flight.[ch] to flight.[ch]xx
859 //
860 // Revision 1.20  1998/09/29 14:57:39  curt
861 // c++-ified comments.
862 //
863 // Revision 1.19  1998/09/29 02:02:41  curt
864 // Added a rate of climb calculation.
865 //
866 // Revision 1.18  1998/07/30 23:44:36  curt
867 // Beginning to add support for multiple flight models.
868 //
869 // Revision 1.17  1998/07/12 03:08:28  curt
870 // Added fgFlightModelSetAltitude() to force the altitude to something
871 // other than the current altitude.  LaRCsim doesn't let you do this by just
872 // changing FG_Altitude.
873 //
874 // Revision 1.16  1998/04/22 13:26:20  curt
875 // C++ - ifing the code a bit.
876 //
877 // Revision 1.15  1998/04/21 16:59:33  curt
878 // Integrated autopilot.
879 // Prepairing for C++ integration.
880 //
881 // Revision 1.14  1998/02/07 15:29:37  curt
882 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
883 // <chotchkiss@namg.us.anritsu.com>
884 //
885 // Revision 1.13  1998/01/24 00:04:59  curt
886 // misc. tweaks.
887 //
888 // Revision 1.12  1998/01/22 02:59:32  curt
889 // Changed #ifdef FILE_H to #ifdef _FILE_H
890 //
891 // Revision 1.11  1998/01/19 19:27:03  curt
892 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
893 // This should simplify things tremendously.
894 //
895 // Revision 1.10  1997/12/10 22:37:43  curt
896 // Prepended "fg" on the name of all global structures that didn't have it yet.
897 // i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
898 //
899 // Revision 1.9  1997/09/04 02:17:33  curt
900 // Shufflin' stuff.
901 //
902 // Revision 1.8  1997/08/27 03:30:06  curt
903 // Changed naming scheme of basic shared structures.
904 //
905 // Revision 1.7  1997/07/23 21:52:19  curt
906 // Put comments around the text after an #endif for increased portability.
907 //
908 // Revision 1.6  1997/06/21 17:52:22  curt
909 // Continue directory shuffling ... everything should be compilable/runnable
910 // again.
911 //
912 // Revision 1.5  1997/06/21 17:12:49  curt
913 // Capitalized subdirectory names.
914 //
915 // Revision 1.4  1997/05/29 22:39:57  curt
916 // Working on incorporating the LaRCsim flight model.
917 //
918 // Revision 1.3  1997/05/29 02:32:25  curt
919 // Starting to build generic flight model interface.
920 //
921 // Revision 1.2  1997/05/23 15:40:37  curt
922 // Added GNU copyright headers.
923 //
924 // Revision 1.1  1997/05/16 16:04:45  curt
925 // Initial revision.
926 //