~ubuntu-branches/debian/sid/flightgear/sid

« back to all changes in this revision

Viewing changes to src/Systems/static.cxx

  • Committer: Package Import Robot
  • Author(s): Markus Wanner, Markus Wanner, Rebecca Palmer
  • Date: 2014-01-21 22:31:02 UTC
  • mfrom: (1.3.1) (15.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20140121223102-cjw7g9le25acd119
Tags: 3.0.0~git20140204+c99ea4-1
[ Markus Wanner ]
* Upload to unstable.
* Adjust B-D to allow building on kfreebsd-*. Closes: #724686.
* Add a lintian-overrides on autotools; we use cmake.
* Upstream corrected the fgfs manpage. Closes: #556362.
* Drop unnecessary man page for gl-info. Closes: #698308.
* Drop README.Linux: it's outdated to the point of uselessness.
  Closes: #574173.
* Add an upper limit of libsimgear-dev versions that flightgear can be
  built with. Closes: #738436.
* Drop the libsvn-dev dependency, neither flightgear nor simgear depend
  on libsvn, anymore. Closes: #682947.
* List icons in debian/install rather than copying around from rules.
* Update menu entry for flightgear, add one for fgcom; add .xpm icons.
  Closes: #713924.
* flightgear.desktop: add German translation
* Bump Standards-Version to 3.9.5; no changes needed.

[ Rebecca Palmer ]
* New upstream release.
* Install the icons (based on code by Saikrishna Arcot).  (Not a
  complete fix for LP908153 as it only sets the menu/Dash icon, not the
  running window's icon, but better than nothing).
* Disable screensaver while running. Closes: LP#793599. Add required
  libdbus-1-dev dependency.
* Remove outdated README.Debian.
* Terrasync now works after just ticking the box. Closes: #252899.
* Always set Terrasync directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// static.cxx - the static air system.
2
2
// Written by David Megginson, started 2002.
3
3
//
 
4
// Last modified by Eric van den Berg, 09 Nov 2013
4
5
// This file is in the Public Domain and comes with no warranty.
5
6
 
6
7
#ifdef HAVE_CONFIG_H
13
14
 
14
15
#include <Main/fg_props.hxx>
15
16
#include <Main/util.hxx>
 
17
#include <simgear/constants.h>
 
18
#include <simgear/sg_inlines.h>
16
19
 
17
20
 
18
21
StaticSystem::StaticSystem ( SGPropertyNode *node )
19
22
    :
20
23
    _name(node->getStringValue("name", "static")),
21
24
    _num(node->getIntValue("number", 0)),
22
 
    _tau(node->getDoubleValue("tau", 1))
23
 
 
 
25
    _tau(node->getDoubleValue("tau", 1)),
 
26
    _error_factor(node->getDoubleValue("error-factor", 0)),
 
27
    _type(node->getIntValue("type", 0))
24
28
{
25
29
}
26
30
 
37
41
    _serviceable_node = node->getChild("serviceable", 0, true);
38
42
    _pressure_in_node = fgGetNode("/environment/pressure-inhg", true);
39
43
    _pressure_out_node = node->getChild("pressure-inhg", 0, true);
 
44
    _beta_node = fgGetNode("/orientation/side-slip-deg", true);
 
45
    _alpha_node = fgGetNode("/orientation/alpha-deg", true);
 
46
    _mach_node = fgGetNode("/velocities/mach", true);
 
47
    SG_CLAMP_RANGE(_error_factor,0.0,1.0);     // making sure the error_factor is between 0 and 1
40
48
 
41
49
    reinit();
42
50
}
62
70
StaticSystem::update (double dt)
63
71
{
64
72
    if (_serviceable_node->getBoolValue()) {
 
73
        double p_new = _pressure_in_node->getDoubleValue();                         //current static pressure around aircraft
 
74
        double p = _pressure_out_node->getDoubleValue();                            //last pressure in aircraft static system
 
75
 
 
76
        double beta;
 
77
        double alpha;
 
78
        double mach;
65
79
        double trat = _tau ? dt/_tau : 100;
66
 
        double target = _pressure_in_node->getDoubleValue();
67
 
        double current = _pressure_out_node->getDoubleValue();
68
 
        _pressure_out_node->setDoubleValue(fgGetLowPass(current, target, trat));
 
80
 
 
81
        double proj_factor = 0;
 
82
        double pt;
 
83
        double qc_part;
 
84
 
 
85
        if (_type == 1) {                                       // type 1 = static pressure dependent on side-slip only: static port on the fuselage
 
86
            beta = _beta_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
 
87
            proj_factor = sin(beta);
 
88
        }
 
89
 
 
90
        if (_type == 2) {                                       // type 2 = static pressure dependent on aoa and side-slip: static port on the pitot tube
 
91
            alpha = _alpha_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
 
92
            beta = _beta_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
 
93
            proj_factor = sqrt( 1.0 - cos(beta)*cos(beta) * cos(alpha)*cos(alpha) );
 
94
        }
 
95
 
 
96
        if ( (_type ==1) || (_type == 2) ) {
 
97
            mach = _mach_node->getDoubleValue();
 
98
            pt = p_new * pow(1 + 0.2 * mach*mach*proj_factor*proj_factor, 3.5 );    //total pressure perpendicular to static port (=perpendicular to body x-axis)
 
99
            qc_part = (pt - p_new) * _error_factor ;                            //part of impact pressure to be added to static pressure (due to sideslip)
 
100
            p_new = p_new + qc_part;
 
101
        }
 
102
 
 
103
        _pressure_out_node->setDoubleValue(fgGetLowPass(p, p_new, trat));           //setting new pressure in static system
 
104
 
69
105
    }
70
106
}
71
107