]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UFO.hxx
Bugfix: no automatic runway selection with --parkpos=
[flightgear.git] / src / FDM / UFO.hxx
1 // UFO.hxx -- interface to the "UFO" flight model
2 //
3 // Written by Curtis Olson, started October 1999.
4 // Slightly modified from MagicCarpet.hxx by Jonathan Polley, April 2002
5 //
6 // Copyright (C) 1999-2002  Curtis L. Olson  - http://www.flightgear.org/~curt
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 //
22
23
24 #ifndef _UFO_HXX
25 #define _UFO_HXX
26
27 #include "flight.hxx"
28
29
30 class FGUFO: public FGInterface {
31 private:
32
33     class lowpass {
34     private:
35         static double _dt;
36         double _coeff;
37         double _last;
38         bool _initialized;
39     public:
40         lowpass(double coeff) : _coeff(coeff), _initialized(false) {}
41         static inline void set_delta(double dt) { _dt = dt; }
42         double filter(double value) {
43             if (!_initialized) {
44                 _initialized = true;
45                 return _last = value;
46             }
47             double c = _dt / (_coeff + _dt);
48             return _last = value * c + _last * (1.0 - c);
49         }
50     };
51
52     lowpass *Throttle;
53     lowpass *Aileron;
54     lowpass *Elevator;
55     lowpass *Rudder;
56     lowpass *Aileron_Trim;
57     lowpass *Elevator_Trim;
58     lowpass *Rudder_Trim;
59     SGPropertyNode_ptr Speed_Max;
60
61 public:
62     FGUFO( double dt );
63     ~FGUFO();
64
65     // reset flight params to a specific position
66     void init();
67
68     // update position based on inputs, positions, velocities, etc.
69     void update( double dt );
70
71 };
72
73
74 #endif // _UFO_HXX