From b87a03b5bebbf9a177dd3c219d6f83332d4018f0 Mon Sep 17 00:00:00 2001 From: Sean McLeod Date: Mon, 30 Oct 2023 12:33:31 +0200 Subject: [PATCH] Argument of perigee only valid if both inclination and eccentricity are non-zero --- src/models/FGPropagate.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/models/FGPropagate.cpp b/src/models/FGPropagate.cpp index 452b618017..bd41fa311e 100644 --- a/src/models/FGPropagate.cpp +++ b/src/models/FGPropagate.cpp @@ -512,6 +512,7 @@ void FGPropagate::ComputeOrbitalParameters(void) else { RightAscension = 0.0; N = {1., 0., 0.}; + PerigeeArgument = 0.0; } R.Normalize(); double vr = DotProduct(R, VState.vInertialVelocity); @@ -519,8 +520,10 @@ void FGPropagate::ComputeOrbitalParameters(void) Eccentricity = eVector.Magnitude(); if (Eccentricity > 1E-8) { eVector /= Eccentricity; - PerigeeArgument = acos(DotProduct(N, eVector))*radtodeg; - if (eVector(eZ) < 0) PerigeeArgument = 360. - PerigeeArgument; + if (abs(Inclination) > 1E-8) { + PerigeeArgument = acos(DotProduct(N, eVector)) * radtodeg; + if (eVector(eZ) < 0) PerigeeArgument = 360. - PerigeeArgument; + } } else {