]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UFO.hxx
b680fd953ef541554697d72ab9d45384cb031720
[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     class lowpass {
32         double _coeff;
33         double _last;
34         bool _initialized;
35     public:
36         lowpass(double coeff) : _coeff(coeff), _initialized(false) {}
37         double filter(double dt, double value) {
38             if (!_initialized) {
39                 _initialized = true;
40                 return _last = value;
41             }
42             double c = dt / (_coeff + dt);
43             return _last = value * c + _last * (1.0 - c);
44         }
45     };
46
47     lowpass *Throttle;
48     lowpass *Aileron;
49     lowpass *Elevator;
50     lowpass *Rudder;
51     lowpass *Aileron_Trim;
52     lowpass *Elevator_Trim;
53     lowpass *Rudder_Trim;
54     SGPropertyNode_ptr Speed_Max;
55
56 public:
57     FGUFO( double dt );
58     ~FGUFO();
59
60     // reset flight params to a specific position 
61     void init();
62
63     // update position based on inputs, positions, velocities, etc.
64     void update( double dt );
65
66 };
67
68
69 #endif // _UFO_HXX