Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
GpwsBehavior.h
Go to the documentation of this file.
1
#pragma once
2
#include <algorithm>
3
#include <cmath>
4
#include <vector>
5
6
// Documented turbofan installation behavior, Honeywell 060-4314-000 Rev C.
7
// Instrument thresholds, not a Vieneo aircraft-performance/escape model.
8
namespace
GpwsBehavior
9
{
10
constexpr
float
FootKm
= .0003048f,
NmKm
= 1.852f,
KnotKms
= .000514444f;
11
inline
float
Clamp01
(
float
x) {
return
(std::clamp)(x,0.f,1.f); }
12
// Guide pp.27–28. Range is measured from the runway end; beside the
13
// runway, the improved TCF retains a 245 ft floor outside its bias box.
14
inline
float
TerrainFloor
(
float
endRangeKm,
bool
besideRunway,
bool
highIntegrity)
15
{
16
const
float
beyondBias = endRangeKm/
NmKm
-(highIntegrity ? .25f : 1.f);
17
if
(beyondBias <= 0)
return
0;
18
float
ft = beyondBias < 4 ? 30+370*
Clamp01
(beyondBias/4) :
19
beyondBias < 12 ? 400 : 400+300*
Clamp01
((beyondBias-12)/3);
20
if
(besideRunway) ft = (std::max)(ft,245.f);
21
return
ft*
FootKm
;
22
}
23
inline
float
RunwayFieldFloor
(
float
endRangeKm,
bool
highIntegrity)
24
{
25
const
float
nm = endRangeKm/
NmKm
, krf = highIntegrity ? .5f : 1.f;
26
if
(nm <= krf || nm > 5)
return
-100.f;
27
return
300*
FootKm
*
Clamp01
((nm-krf)/1.5f);
28
}
29
inline
float
Mode2Ceiling
(
float
speedKms,
bool
tad,
bool
slow)
30
{
31
if
(tad)
return
950*
FootKm
;
32
// Figure p.13 is a closure-dependent envelope; this is its speed cap.
33
return
(1500+500*
Clamp01
((speedKms/
KnotKms
-(slow ? 190 : 220))/90))*
FootKm
;
34
}
35
inline
float
GlideslopeThreshold
(
float
radioKm,
bool
hard)
36
{
37
// Linear approximation of the p.22 near-ground envelope (the guide
38
// does not publish coefficients). Both limits expand toward full scale.
39
const
float
ft = radioKm/
FootKm
;
40
return
(hard ? 2.f : 1.3f) + (hard ? 2.f : 2.7f)*
Clamp01
((150-ft)/150);
41
}
42
inline
float
AltitudeLossLimit
(
float
radioKm)
43
{
44
// The guide supplies a numerical turboprop plot, but only an
45
// illustration for jets. Retain Rise's jet sensitivity, do not claim
46
// the turboprop coefficients describe a jet installation.
47
return
.008f-.003f*radioKm;
48
}
49
inline
float
GearFloor
(
float
speedKms,
bool
terrainAvailable)
50
{
51
if
(terrainAvailable)
return
.1524f;
52
return
(std::clamp)(.1524f+(speedKms-.0977444f)*(.1524f/.0308667f),.1524f,.3048f);
53
}
54
inline
float
FlapFloor
(
float
speedKms,
bool
terrainAvailable)
55
{
56
if
(terrainAvailable)
return
.074676f;
57
return
(std::clamp)(.074676f+(speedKms-.0817967f)*(.230124f/.0468144f),.074676f,.3048f);
58
}
59
inline
float
BankLimit
(
float
radioKm,
bool
autopilot)
60
{
61
if
(autopilot)
return
(std::clamp)(10.f+(radioKm-.009144f)*23.f/.0280416f,10.f,33.f);
62
if
(radioKm < .04572f)
return
(std::clamp)(10.f+(radioKm-.009144f)*30.f/.036576f,10.f,40.f);
63
return
(std::clamp)(40.f+(radioKm-.04572f)*15.f/.70104f,40.f,55.f);
64
}
65
// Rise-only bank-advisory admission; not an orbital-state classifier and
66
// not a change to the Honeywell manual/Autoflyte roll-angle schedules.
67
struct
BankFlightEnvelope
68
{
69
bool
spaceflight
=
false
;
70
void
Reset
() {
spaceflight
=
false
; }
71
bool
Allows
(
float
radioKm,
float
densityRatio,
float
mach)
72
{
73
if
(!std::isfinite(radioKm) || radioKm < 0)
return
false
;
74
// A stall, backwards flight or a VTOL hover can have zero IAS.
75
// Preserve near-ground protection even during a fast re-entry.
76
if
(radioKm <= .762f) {
Reset
();
return
true
; }
77
if
(!std::isfinite(densityRatio) || densityRatio < 0)
return
false
;
78
const
bool
machValid = std::isfinite(mach) && mach >= 0;
79
if
(densityRatio <= .01f || (machValid && mach >= 5.f))
spaceflight
=
true
;
80
else
if
(densityRatio >= .02f && machValid && mach <= 4.f)
spaceflight
=
false
;
81
return
!
spaceflight
;
82
}
83
};
84
struct
ClearanceHistory
85
{
86
struct
Sample
{
float
seconds
,
radioKm
; };
87
std::vector<Sample>
samples
;
88
float
seconds
= 0,
floorKm
= 0;
89
void
Reset
() {
samples
.clear();
seconds
=
floorKm
= 0; }
90
float
Update
(
float
dt,
float
radioKm,
float
limitKm)
91
{
92
samples
.push_back({dt,radioKm});
seconds
+= dt;
93
while
(
seconds
> 15 && !
samples
.empty())
94
{
95
const
float
removed = (std::min)(
samples
.front().seconds,
seconds
-15);
96
samples
.front().seconds -= removed;
seconds
-= removed;
97
if
(
samples
.front().seconds <= .00001f)
samples
.erase(
samples
.begin());
98
}
99
float
total = 0;
100
for
(
const
auto
& s :
samples
) total += s.seconds*s.radioKm;
101
// Include the zero-height period before takeoff in the first 15 s.
102
floorKm
= (std::max)(
floorKm
,.75f*total/15.f);
103
return
(std::min)(
floorKm
,limitKm);
104
}
105
};
106
}
GpwsBehavior
Definition
GpwsBehavior.h:9
GpwsBehavior::FlapFloor
float FlapFloor(float speedKms, bool terrainAvailable)
Definition
GpwsBehavior.h:54
GpwsBehavior::BankLimit
float BankLimit(float radioKm, bool autopilot)
Definition
GpwsBehavior.h:59
GpwsBehavior::AltitudeLossLimit
float AltitudeLossLimit(float radioKm)
Definition
GpwsBehavior.h:42
GpwsBehavior::GearFloor
float GearFloor(float speedKms, bool terrainAvailable)
Definition
GpwsBehavior.h:49
GpwsBehavior::Clamp01
float Clamp01(float x)
Definition
GpwsBehavior.h:11
GpwsBehavior::NmKm
constexpr float NmKm
Definition
GpwsBehavior.h:10
GpwsBehavior::TerrainFloor
float TerrainFloor(float endRangeKm, bool besideRunway, bool highIntegrity)
Definition
GpwsBehavior.h:14
GpwsBehavior::FootKm
constexpr float FootKm
Definition
GpwsBehavior.h:10
GpwsBehavior::KnotKms
constexpr float KnotKms
Definition
GpwsBehavior.h:10
GpwsBehavior::Mode2Ceiling
float Mode2Ceiling(float speedKms, bool tad, bool slow)
Definition
GpwsBehavior.h:29
GpwsBehavior::RunwayFieldFloor
float RunwayFieldFloor(float endRangeKm, bool highIntegrity)
Definition
GpwsBehavior.h:23
GpwsBehavior::GlideslopeThreshold
float GlideslopeThreshold(float radioKm, bool hard)
Definition
GpwsBehavior.h:35
GpwsBehavior::BankFlightEnvelope
Definition
GpwsBehavior.h:68
GpwsBehavior::BankFlightEnvelope::Reset
void Reset()
Definition
GpwsBehavior.h:70
GpwsBehavior::BankFlightEnvelope::spaceflight
bool spaceflight
Definition
GpwsBehavior.h:69
GpwsBehavior::BankFlightEnvelope::Allows
bool Allows(float radioKm, float densityRatio, float mach)
Definition
GpwsBehavior.h:71
GpwsBehavior::ClearanceHistory::Sample
Definition
GpwsBehavior.h:86
GpwsBehavior::ClearanceHistory::Sample::radioKm
float radioKm
Definition
GpwsBehavior.h:86
GpwsBehavior::ClearanceHistory::Sample::seconds
float seconds
Definition
GpwsBehavior.h:86
GpwsBehavior::ClearanceHistory
Definition
GpwsBehavior.h:85
GpwsBehavior::ClearanceHistory::seconds
float seconds
Definition
GpwsBehavior.h:88
GpwsBehavior::ClearanceHistory::Update
float Update(float dt, float radioKm, float limitKm)
Definition
GpwsBehavior.h:90
GpwsBehavior::ClearanceHistory::Reset
void Reset()
Definition
GpwsBehavior.h:89
GpwsBehavior::ClearanceHistory::floorKm
float floorKm
Definition
GpwsBehavior.h:88
GpwsBehavior::ClearanceHistory::samples
std::vector< Sample > samples
Definition
GpwsBehavior.h:87
GpwsBehavior.h
Generated on
for Rise by
1.18.0