]> git.mxchange.org Git - flightgear.git/blob - src/FDM/flight.hxx
Really implement fgWarpMouse for osgviewer
[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  - http://www.flightgear.org/~curt
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 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_Radius_to_vehicle ()'
78
79  */
80
81
82 #include <math.h>
83
84 #include <list>
85 #include <vector>
86 #include <string>
87
88 #include <simgear/compiler.h>
89 #include <simgear/constants.h>
90 #include <simgear/structure/subsystem_mgr.hxx>
91 #include <FDM/groundcache.hxx>
92
93 SG_USING_STD(list);
94 SG_USING_STD(vector);
95 SG_USING_STD(string);
96
97 // This is based heavily on LaRCsim/ls_generic.h
98 class FGInterface : public SGSubsystem {
99
100 private:
101   
102     // Has the init() method been called.  This is used to delay
103     // initialization until scenery can be loaded and we know the true
104     // ground elevation.
105     bool inited;
106
107     // Have we bound to the property system
108     bool bound; 
109
110     // periodic update management variable.  This is a scheme to run
111     // the fdm with a fixed delta-t.  We control how many iteration of
112     // the fdm to run with the fixed dt based on the elapsed time from
113     // the last update.  This allows us to maintain sync with the real
114     // time clock, even though each frame could take a random amount
115     // of time.  Since "dt" is unlikely to divide evenly into the
116     // elapse time, we keep track of the remainder and add it into the
117     // next elapsed time.  This yields a small amount of temporal
118     // jitter ( < dt ) but in practice seems to work well.
119
120     double remainder;           // remainder time from last run
121
122     // CG position w.r.t. ref. point
123     SGVec3d d_cg_rp_body_v;
124
125     // Accelerations
126     SGVec3d v_dot_local_v;
127     SGVec3d v_dot_body_v;
128     SGVec3d a_cg_body_v;
129     SGVec3d a_pilot_body_v;
130     SGVec3d n_cg_body_v;
131     SGVec3d omega_dot_body_v;
132
133     // Velocities
134     SGVec3d v_local_v;
135     SGVec3d v_local_rel_ground_v; // V rel w.r.t. earth surface
136     SGVec3d v_local_airmass_v;    // velocity of airmass (steady winds)
137     SGVec3d v_wind_body_v;        // Wind-relative velocities in body axis
138
139     SGVec3d omega_body_v;         // Angular B rates
140     SGVec3d euler_rates_v;
141     SGVec3d geocentric_rates_v;   // Geocentric linear velocities
142
143     // Positions
144     SGGeod geodetic_position_v;
145     SGVec3d cartesian_position_v;
146     SGGeoc geocentric_position_v;
147     SGVec3d euler_angles_v;
148
149     // Inertias
150     double mass, i_xx, i_yy, i_zz, i_xz;
151
152     // Normal Load Factor
153     double nlf;
154
155     // Velocities
156     double v_rel_wind, v_true_kts;
157     double v_ground_speed, v_equiv_kts;
158     double v_calibrated_kts;
159
160     // Miscellaneious Quantities
161     double alpha, beta;  // in radians
162     double gamma_vert_rad;  // Flight path angles
163     double density, mach_number;
164     double static_pressure, total_pressure;
165     double dynamic_pressure;
166     double static_temperature, total_temperature;
167     double sea_level_radius, earth_position_angle;
168     double runway_altitude;
169     double climb_rate;                // in feet per second
170     double altitude_agl;
171
172     double daux[16];            // auxilliary doubles
173     float  faux[16];            // auxilliary floats
174     int    iaux[16];            // auxilliary ints
175
176     // the ground cache object itself.
177     FGGroundCache ground_cache;
178
179 protected:
180
181     int _calc_multiloop (double dt);
182
183 public:
184
185                                 // deliberately not virtual so that
186                                 // FGInterface constructor will call
187                                 // the right version
188     void _setup();
189
190     void _busdump(void);
191     void _updatePositionM(const SGVec3d& cartPos);
192     void _updatePositionFt(const SGVec3d& cartPos) {
193         _updatePositionM(SG_FEET_TO_METER*cartPos);
194     }
195     void _updatePosition(const SGGeod& geod);
196     void _updatePosition(const SGGeoc& geoc);
197   
198     void _updateGeodeticPosition( double lat, double lon, double alt );
199     void _updateGeocentricPosition( double lat_geoc, double lon, double alt );
200     void _update_ground_elev_at_pos( void );
201
202     inline void _set_Inertias( double m, double xx, double yy, 
203                               double zz, double xz)
204     {
205         mass = m;
206         i_xx = xx;
207         i_yy = yy;
208         i_zz = zz;
209         i_xz = xz;
210     }
211     inline void _set_CG_Position( double dx, double dy, double dz ) {
212         d_cg_rp_body_v[0] = dx;
213         d_cg_rp_body_v[1] = dy;
214         d_cg_rp_body_v[2] = dz;
215     }
216     inline void _set_Accels_Local( double north, double east, double down ) {
217         v_dot_local_v[0] = north;
218         v_dot_local_v[1] = east;
219         v_dot_local_v[2] = down;
220     }
221     inline void _set_Accels_Body( double u, double v, double w ) {
222         v_dot_body_v[0] = u;
223         v_dot_body_v[1] = v;
224         v_dot_body_v[2] = w;
225     }
226     inline void _set_Accels_CG_Body( double x, double y, double z ) {
227         a_cg_body_v[0] = x;
228         a_cg_body_v[1] = y;
229         a_cg_body_v[2] = z;
230     }
231     inline void _set_Accels_Pilot_Body( double x, double y, double z ) {
232         a_pilot_body_v[0] = x;
233         a_pilot_body_v[1] = y;
234         a_pilot_body_v[2] = z;
235     }
236     inline void _set_Accels_CG_Body_N( double x, double y, double z ) {
237         n_cg_body_v[0] = x;
238         n_cg_body_v[1] = y;
239         n_cg_body_v[2] = z;
240     }
241     void _set_Nlf(double n) { nlf=n;  }
242     inline void _set_Velocities_Local( double north, double east, double down ){
243         v_local_v[0] = north;
244         v_local_v[1] = east;
245         v_local_v[2] = down;
246     }
247     inline void _set_Velocities_Ground(double north, double east, double down) {
248         v_local_rel_ground_v[0] = north;
249         v_local_rel_ground_v[1] = east;
250         v_local_rel_ground_v[2] = down;
251     }
252     inline void _set_Velocities_Local_Airmass( double north, double east, 
253                                               double down)
254     {
255         v_local_airmass_v[0] = north;
256         v_local_airmass_v[1] = east;
257         v_local_airmass_v[2] = down;
258     }
259     inline void _set_Velocities_Wind_Body( double u, double v, double w) {
260         v_wind_body_v[0] = u;
261         v_wind_body_v[1] = v;
262         v_wind_body_v[2] = w;
263     }
264     inline void _set_V_rel_wind(double vt) { v_rel_wind = vt; }
265     inline void _set_V_ground_speed( double v) { v_ground_speed = v; }
266     inline void _set_V_equiv_kts( double kts ) { v_equiv_kts = kts; }
267     inline void _set_V_calibrated_kts( double kts ) { v_calibrated_kts = kts; }
268     inline void _set_Omega_Body( double p, double q, double r ) {
269         omega_body_v[0] = p;
270         omega_body_v[1] = q;
271         omega_body_v[2] = r;
272     }
273     inline void _set_Euler_Rates( double phi, double theta, double psi ) {
274         euler_rates_v[0] = phi;
275         euler_rates_v[1] = theta;
276         euler_rates_v[2] = psi;
277     }
278     inline void _set_Geocentric_Rates( double lat, double lon, double rad ) {
279         geocentric_rates_v[0] = lat;
280         geocentric_rates_v[1] = lon;
281         geocentric_rates_v[2] = rad;
282     }
283     inline void _set_Geocentric_Position( double lat, double lon, double rad ) {
284         geocentric_position_v.setLatitudeRad(lat);
285         geocentric_position_v.setLongitudeRad(lon);
286         geocentric_position_v.setRadiusFt(rad);
287     }
288     inline void _set_Latitude(double lat) {
289         geodetic_position_v.setLatitudeRad(lat);
290     }
291     inline void _set_Longitude(double lon) {
292         geodetic_position_v.setLongitudeRad(lon);
293     }
294     inline void _set_Altitude(double altitude) {
295         geodetic_position_v.setElevationFt(altitude);
296     }
297     inline void _set_Altitude_AGL(double agl) {
298         altitude_agl = agl;
299     }
300     inline void _set_Geodetic_Position( double lat, double lon, double alt ) {
301         geodetic_position_v.setLatitudeRad(lat);
302         geodetic_position_v.setLongitudeRad(lon);
303         geodetic_position_v.setElevationFt(alt);
304     }
305     inline void _set_Euler_Angles( double phi, double theta, double psi ) {
306         euler_angles_v[0] = phi;
307         euler_angles_v[1] = theta;
308         euler_angles_v[2] = psi;
309     }
310     // FIXME, for compatibility with JSBSim
311     inline void _set_T_Local_to_Body( int i, int j, double value) { }
312     inline void _set_Alpha( double a ) { alpha = a; }
313     inline void _set_Beta( double b ) { beta = b; }
314     inline void _set_Gamma_vert_rad( double gv ) { gamma_vert_rad = gv; }
315     inline void _set_Density( double d ) { density = d; }
316     inline void _set_Mach_number( double m ) { mach_number = m; }
317     inline void _set_Static_pressure( double sp ) { static_pressure = sp; }
318     inline void _set_Static_temperature( double t ) { static_temperature = t; } 
319     inline void _set_Total_temperature( double tat ) { total_temperature = tat; } //JW
320     inline void _set_Sea_level_radius( double r ) { sea_level_radius = r; }
321     inline void _set_Earth_position_angle(double a) { earth_position_angle = a; }
322     inline void _set_Runway_altitude( double alt ) { runway_altitude = alt; }
323     inline void _set_Climb_Rate(double rate) { climb_rate = rate; }
324
325     inline void _set_daux( int n, double value ) { daux[n] = value; }
326     inline void _set_faux( int n, float value ) { faux[n] = value; }
327     inline void _set_iaux( int n, int value ) { iaux[n] = value; }
328
329 public:
330   
331     FGInterface();
332     FGInterface( double dt );
333     virtual ~FGInterface();
334
335     virtual void init ();
336     virtual void bind ();
337     virtual void unbind ();
338     virtual void update(double dt);
339     virtual bool ToggleDataLogging(bool state) { return false; }
340     virtual bool ToggleDataLogging(void) { return false; }
341
342     // Define the various supported flight models (many not yet implemented)
343     enum {
344         // Magic Carpet mode
345         FG_MAGICCARPET = 0,
346
347         // The NASA LaRCsim (Navion) flight model
348         FG_LARCSIM = 1,
349
350         // Jon S. Berndt's new FDM written from the ground up in C++
351         FG_JSBSIM = 2,
352
353         // Christian's hot air balloon simulation
354         FG_BALLOONSIM = 3,
355
356         // Aeronautical DEvelopment AGEncy, Bangalore India
357         FG_ADA = 4,
358
359         // The following aren't implemented but are here to spark
360         // thoughts and discussions, and maybe even action.
361         FG_ACM = 5,
362         FG_SUPER_SONIC = 6,
363         FG_HELICOPTER = 7,
364         FG_AUTOGYRO = 8,
365         FG_PARACHUTE = 9,
366
367         // Driven externally via a serial port, net, file, etc.
368         FG_EXTERNAL = 10
369     };
370
371     // initialization
372     inline bool get_inited() const { return inited; }
373     inline void set_inited( bool value ) { inited = value; }
374
375     inline bool get_bound() const { return bound; }
376
377     //perform initializion that is common to all FDM's
378     void common_init();
379
380     // Positions
381     virtual void set_Latitude(double lat);       // geocentric
382     virtual void set_Longitude(double lon);    
383     virtual void set_Altitude(double alt);  // triggers re-calc of AGL altitude
384     virtual void set_AltitudeAGL(double altagl); // and vice-versa
385     virtual void set_Latitude_deg (double lat) {
386       set_Latitude(lat * SGD_DEGREES_TO_RADIANS);
387     }
388     virtual void set_Longitude_deg (double lon) {
389       set_Longitude(lon * SGD_DEGREES_TO_RADIANS);
390     }
391     
392     // Speeds -- setting any of these will trigger a re-calc of the rest
393     virtual void set_V_calibrated_kts(double vc);
394     virtual void set_Mach_number(double mach);
395     virtual void set_Velocities_Local( double north, double east, double down );
396     inline void set_V_north (double north) { 
397       set_Velocities_Local(north, v_local_v[1], v_local_v[2]);
398     }
399     inline void set_V_east (double east) { 
400       set_Velocities_Local(v_local_v[0], east, v_local_v[2]);
401     }
402     inline void set_V_down (double down) { 
403       set_Velocities_Local(v_local_v[0], v_local_v[1], down);
404     }
405     virtual void set_Velocities_Wind_Body( double u, double v, double w);
406     virtual void set_uBody (double uBody) { 
407       set_Velocities_Wind_Body(uBody, v_wind_body_v[1], v_wind_body_v[2]);
408     }
409     virtual void set_vBody (double vBody) { 
410       set_Velocities_Wind_Body(v_wind_body_v[0], vBody, v_wind_body_v[2]);
411     }
412     virtual void set_wBody (double wBody) {
413       set_Velocities_Wind_Body(v_wind_body_v[0], v_wind_body_v[1], wBody);
414     }
415     
416     // Euler angles 
417     virtual void set_Euler_Angles( double phi, double theta, double psi );
418     virtual void set_Phi (double phi) {
419       set_Euler_Angles(phi, get_Theta(), get_Psi());
420     }
421     virtual void set_Theta (double theta) {
422       set_Euler_Angles(get_Phi(), theta, get_Psi());
423     }
424     virtual void set_Psi (double psi) { 
425       set_Euler_Angles(get_Phi(), get_Theta(), psi);
426     }
427     virtual void set_Phi_deg (double phi) {
428       set_Phi(phi * SGD_DEGREES_TO_RADIANS);
429     }
430     virtual void set_Theta_deg (double theta) {
431       set_Theta(theta * SGD_DEGREES_TO_RADIANS); 
432     }
433     virtual void set_Psi_deg (double psi) {
434       set_Psi(psi * SGD_DEGREES_TO_RADIANS);
435     }
436     
437     // Flight Path
438     virtual void set_Climb_Rate( double roc);
439     virtual void set_Gamma_vert_rad( double gamma);
440     
441     // Earth
442     
443     virtual void set_Static_pressure(double p);
444     virtual void set_Static_temperature(double T);
445     virtual void set_Density(double rho);
446     
447     virtual void set_Velocities_Local_Airmass (double wnorth, 
448                                                double weast, 
449                                                double wdown );
450
451     // ========== Mass properties and geometry values ==========
452
453     // Inertias
454     inline double get_Mass() const { return mass; }
455     inline double get_I_xx() const { return i_xx; }
456     inline double get_I_yy() const { return i_yy; }
457     inline double get_I_zz() const { return i_zz; }
458     inline double get_I_xz() const { return i_xz; }
459
460     // CG position w.r.t. ref. point
461     inline double get_Dx_cg() const { return d_cg_rp_body_v[0]; }
462     inline double get_Dy_cg() const { return d_cg_rp_body_v[1]; }
463     inline double get_Dz_cg() const { return d_cg_rp_body_v[2]; }
464
465     // ========== Accelerations ==========
466
467     inline double get_V_dot_north() const { return v_dot_local_v[0]; }
468     inline double get_V_dot_east() const { return v_dot_local_v[1]; }
469     inline double get_V_dot_down() const { return v_dot_local_v[2]; }
470
471     inline double get_U_dot_body() const { return v_dot_body_v[0]; }
472     inline double get_V_dot_body() const { return v_dot_body_v[1]; }
473     inline double get_W_dot_body() const { return v_dot_body_v[2]; }
474
475     inline double get_A_X_cg() const { return a_cg_body_v[0]; }
476     inline double get_A_Y_cg() const { return a_cg_body_v[1]; }
477     inline double get_A_Z_cg() const { return a_cg_body_v[2]; }
478
479     inline double get_A_X_pilot() const { return a_pilot_body_v[0]; }
480     inline double get_A_Y_pilot() const { return a_pilot_body_v[1]; }
481     inline double get_A_Z_pilot() const { return a_pilot_body_v[2]; }
482
483     inline double get_N_X_cg() const { return n_cg_body_v[0]; }
484     inline double get_N_Y_cg() const { return n_cg_body_v[1]; }
485     inline double get_N_Z_cg() const { return n_cg_body_v[2]; }
486
487     inline double get_Nlf(void) const { return nlf; }
488
489     // ========== Velocities ==========
490
491     inline double get_V_north() const { return v_local_v[0]; }
492     inline double get_V_east() const { return v_local_v[1]; }
493     inline double get_V_down() const { return v_local_v[2]; }
494     inline double get_uBody () const { return v_wind_body_v[0]; }
495     inline double get_vBody () const { return v_wind_body_v[1]; }
496     inline double get_wBody () const { return v_wind_body_v[2]; }
497
498     // Please dont comment these out. fdm=ada uses these (see
499     // cockpit.cxx) --->
500     inline double get_V_north_rel_ground() const {
501         return v_local_rel_ground_v[0];
502     }
503     inline double get_V_east_rel_ground() const {
504         return v_local_rel_ground_v[1];
505     }
506     inline double get_V_down_rel_ground() const {
507         return v_local_rel_ground_v[2];
508     }
509     // <--- fdm=ada uses these (see cockpit.cxx)
510
511     inline double get_V_north_airmass() const { return v_local_airmass_v[0]; }
512     inline double get_V_east_airmass() const { return v_local_airmass_v[1]; }
513     inline double get_V_down_airmass() const { return v_local_airmass_v[2]; }
514
515     inline double get_U_body() const { return v_wind_body_v[0]; }
516     inline double get_V_body() const { return v_wind_body_v[1]; }
517     inline double get_W_body() const { return v_wind_body_v[2]; }
518
519     inline double get_V_rel_wind() const { return v_rel_wind; }
520
521     inline double get_V_true_kts() const { return v_true_kts; }
522
523     inline double get_V_ground_speed() const { return v_ground_speed; }
524     inline double get_V_ground_speed_kt() const { return v_ground_speed * SG_FEET_TO_METER * 3600 * SG_METER_TO_NM; }
525
526     inline double get_V_equiv_kts() const { return v_equiv_kts; }
527
528     inline double get_V_calibrated_kts() const { return v_calibrated_kts; }
529
530     inline double get_P_body() const { return omega_body_v[0]; }
531     inline double get_Q_body() const { return omega_body_v[1]; }
532     inline double get_R_body() const { return omega_body_v[2]; }
533
534     inline double get_Phi_dot() const { return euler_rates_v[0]; }
535     inline double get_Theta_dot() const { return euler_rates_v[1]; }
536     inline double get_Psi_dot() const { return euler_rates_v[2]; }
537     inline double get_Phi_dot_degps() const { return euler_rates_v[0] * SGD_RADIANS_TO_DEGREES; }
538     inline double get_Theta_dot_degps() const { return euler_rates_v[1] * SGD_RADIANS_TO_DEGREES; }
539     inline double get_Psi_dot_degps() const { return euler_rates_v[2] * SGD_RADIANS_TO_DEGREES; }
540
541     inline double get_Latitude_dot() const { return geocentric_rates_v[0]; }
542     inline double get_Longitude_dot() const { return geocentric_rates_v[1]; }
543     inline double get_Radius_dot() const { return geocentric_rates_v[2]; }
544
545     // ========== Positions ==========
546
547     inline double get_Lat_geocentric() const {
548         return geocentric_position_v.getLatitudeRad();
549     }
550     inline double get_Lon_geocentric() const {
551         return geocentric_position_v.getLongitudeRad();
552     }
553     inline double get_Radius_to_vehicle() const {
554         return geocentric_position_v.getRadiusFt();
555     }
556
557     const SGGeod& getPosition() const { return geodetic_position_v; }
558     const SGGeoc& getGeocPosition() const { return geocentric_position_v; }
559     const SGVec3d& getCartPosition() const { return cartesian_position_v; }
560
561     inline double get_Latitude() const {
562         return geodetic_position_v.getLatitudeRad();
563     }
564     inline double get_Longitude() const {
565         return geodetic_position_v.getLongitudeRad();
566     }
567     inline double get_Altitude() const {
568         return geodetic_position_v.getElevationFt();
569     }
570     inline double get_Altitude_AGL(void) const { return altitude_agl; }
571
572     inline double get_Latitude_deg () const {
573       return geodetic_position_v.getLatitudeDeg();
574     }
575     inline double get_Longitude_deg () const {
576       return geodetic_position_v.getLongitudeDeg();
577     }
578
579     inline double get_Phi() const { return euler_angles_v[0]; }
580     inline double get_Theta() const { return euler_angles_v[1]; }
581     inline double get_Psi() const { return euler_angles_v[2]; }
582     inline double get_Phi_deg () const { return get_Phi() * SGD_RADIANS_TO_DEGREES; }
583     inline double get_Theta_deg () const { return get_Theta() * SGD_RADIANS_TO_DEGREES; }
584     inline double get_Psi_deg () const { return get_Psi() * SGD_RADIANS_TO_DEGREES; }
585
586
587     // ========== Miscellaneous quantities ==========
588
589     inline double get_Alpha() const { return alpha; }
590     inline double get_Alpha_deg() const { return alpha * SGD_RADIANS_TO_DEGREES; }
591     inline double get_Beta() const { return beta; }
592     inline double get_Beta_deg() const { return beta * SGD_RADIANS_TO_DEGREES; }
593     inline double get_Gamma_vert_rad() const { return gamma_vert_rad; }
594
595     inline double get_Density() const { return density; }
596     inline double get_Mach_number() const { return mach_number; }
597
598     inline double get_Static_pressure() const { return static_pressure; }
599     inline double get_Total_pressure() const { return total_pressure; }
600     inline double get_Dynamic_pressure() const { return dynamic_pressure; }
601
602     inline double get_Static_temperature() const { return static_temperature; }
603     inline double get_Total_temperature() const { return total_temperature; }
604
605     inline double get_Sea_level_radius() const { return sea_level_radius; }
606     inline double get_Earth_position_angle() const {
607         return earth_position_angle;
608     }
609
610     inline double get_Runway_altitude() const { return runway_altitude; }
611     inline double get_Runway_altitude_m() const { return SG_FEET_TO_METER * runway_altitude; }
612
613     inline double get_Climb_Rate() const { return climb_rate; }
614
615     // Auxilliary variables
616     inline double get_daux( int n ) const { return daux[n]; }
617     inline float  get_faux( int n ) const { return faux[n]; }
618     inline int    get_iaux( int n ) const { return iaux[n]; }
619
620     // Note that currently this is the "same" value runway altitude...
621     inline double get_ground_elev_ft() const { return runway_altitude; }
622
623
624     //////////////////////////////////////////////////////////////////////////
625     // Ground handling routines
626     //////////////////////////////////////////////////////////////////////////
627
628     enum GroundType {
629       Unknown = 0, //??
630       Solid, // Whatever we will roll on with infinite load factor.
631       Water, // For the beaver ...
632       Catapult, // Carrier cats.
633       Wire // Carrier wires.
634     };
635
636     // Prepare the ground cache for the wgs84 position pt_*.
637     // That is take all vertices in the ball with radius rad around the
638     // position given by the pt_* and store them in a local scene graph.
639     bool prepare_ground_cache_m(double ref_time, const double pt[3],
640                                 double rad);
641     bool prepare_ground_cache_ft(double ref_time, const double pt[3],
642                                  double rad);
643
644
645     // Returns true if the cache is valid.
646     // Also the reference time, point and radius values where the cache
647     // is valid for are returned.
648     bool is_valid_m(double *ref_time, double pt[3], double *rad);
649     bool is_valid_ft(double *ref_time, double pt[3], double *rad);
650
651     // Return the nearest catapult to the given point
652     // pt in wgs84 coordinates.
653     double get_cat_m(double t, const double pt[3],
654                      double end[2][3], double vel[2][3]);
655     double get_cat_ft(double t, const double pt[3],
656                       double end[2][3], double vel[2][3]);
657   
658
659     // Return the altitude above ground below the wgs84 point pt
660     // Search for the nearest triangle to pt.
661     // Return ground properties like the ground type, the maximum load
662     // this kind kind of ground can carry, the friction factor between
663     // 0 and 1 which can be used to model lower friction with wet runways
664     // and finally the altitude above ground.
665     bool get_agl_m(double t, const double pt[3],
666                    double contact[3], double normal[3], double vel[3],
667                    int *type, double *loadCapacity,
668                    double *frictionFactor, double *agl);
669     bool get_agl_m(double t, const double pt[3],
670                        double contact[3], double normal[3], double vel[3],
671                        int *type, const SGMaterial **material,double *agl);
672     bool get_agl_ft(double t, const double pt[3],
673                     double contact[3], double normal[3], double vel[3],
674                     int *type, double *loadCapacity,
675                     double *frictionFactor, double *agl);
676
677     // Return the altitude above ground below the wgs84 point pt
678     // Search for the nearest triangle to pt.
679     // Return ground properties like the ground type, a pointer to the
680     // material and finally the altitude above ground.
681     bool get_agl_m(double t, const double pt[3], double max_altoff,
682                    double contact[3], double normal[3], double vel[3],
683                    int *type, const SGMaterial** material, double *agl);
684     bool get_agl_ft(double t, const double pt[3], double max_altoff,
685                     double contact[3], double normal[3], double vel[3],
686                     int *type, const SGMaterial** material, double *agl);
687     double get_groundlevel_m(double lat, double lon, double alt);
688     double get_groundlevel_m(const SGGeod& geod);
689
690
691     // Return 1 if the hook intersects with a wire.
692     // That test is done by checking if the quad spanned by the points pt*
693     // intersects with the line representing the wire.
694     // If the wire is caught, the cache will trace this wires endpoints until
695     // the FDM calls release_wire().
696     bool caught_wire_m(double t, const double pt[4][3]);
697     bool caught_wire_ft(double t, const double pt[4][3]);
698   
699     // Return the location and speed of the wire endpoints.
700     bool get_wire_ends_m(double t, double end[2][3], double vel[2][3]);
701     bool get_wire_ends_ft(double t, double end[2][3], double vel[2][3]);
702
703     // Tell the cache code that it does no longer need to care for
704     // the wire end position.
705     void release_wire(void);
706 };
707
708 extern FGInterface * cur_fdm_state;
709
710 // Toggle data logging on/off
711 void fgToggleFDMdataLogging(void);
712
713
714 #endif // _FLIGHT_HXX