Make sure sign is preserved for turbulence direction.
This commit is contained in:
parent
a0d90b9746
commit
5d3b58438a
1 changed files with 15 additions and 2 deletions
|
@ -260,6 +260,16 @@ void FGAtmosphere::Calculate(double altitude)
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
// square a value, but preserve the original sign
|
||||||
|
static inline double
|
||||||
|
square_signed (double value)
|
||||||
|
{
|
||||||
|
if (value < 0)
|
||||||
|
return value * value * -1;
|
||||||
|
else
|
||||||
|
return value * value;
|
||||||
|
}
|
||||||
|
|
||||||
void FGAtmosphere::Turbulence(void)
|
void FGAtmosphere::Turbulence(void)
|
||||||
{
|
{
|
||||||
switch (turbType) {
|
switch (turbType) {
|
||||||
|
@ -277,8 +287,11 @@ void FGAtmosphere::Turbulence(void)
|
||||||
Magnitude += MagnitudeAccel*rate*State->Getdt();
|
Magnitude += MagnitudeAccel*rate*State->Getdt();
|
||||||
|
|
||||||
vDirectiondAccelDt.Normalize();
|
vDirectiondAccelDt.Normalize();
|
||||||
vDirectiondAccelDt(eX) *= vDirectiondAccelDt(eX);
|
|
||||||
vDirectiondAccelDt(eY) *= vDirectiondAccelDt(eY);
|
// deemphasise non-vertical forces
|
||||||
|
vDirectiondAccelDt(eX) = square_signed(vDirectiondAccelDt(eX));
|
||||||
|
vDirectiondAccelDt(eY) = square_signed(vDirectiondAccelDt(eY));
|
||||||
|
|
||||||
vDirectionAccel += vDirectiondAccelDt*rate*TurbRate*State->Getdt();
|
vDirectionAccel += vDirectiondAccelDt*rate*TurbRate*State->Getdt();
|
||||||
vDirectionAccel.Normalize();
|
vDirectionAccel.Normalize();
|
||||||
vDirection += vDirectionAccel*rate*State->Getdt();
|
vDirection += vDirectionAccel*rate*State->Getdt();
|
||||||
|
|
Loading…
Add table
Reference in a new issue