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