From 62da78fefde88c5d4e3342eb16019ff81c9c6988 Mon Sep 17 00:00:00 2001 From: Max Nova Date: Tue, 17 Sep 2024 16:14:23 -0700 Subject: [PATCH 1/2] add slack to fgtable interpolation --- src/math/FGTable.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/math/FGTable.cpp b/src/math/FGTable.cpp index 62f2ab59b5..e6f39af862 100644 --- a/src/math/FGTable.cpp +++ b/src/math/FGTable.cpp @@ -509,7 +509,9 @@ double FGTable::GetValue(double key) const double Span = Data[2*r] - x0; assert(Span > 0.0); double Factor = (key - x0) / Span; - assert(Factor >= 0.0 && Factor <= 1.0); + const double epsilon = 1e-9; + assert(Factor >= -epsilon && Factor <= 1.0 + epsilon); + double y0 = Data[2*r-1]; return Factor*(Data[2*r+1] - y0) + y0; From e508c9a97421d1552b8a1ea8fd40cc7cb0351b27 Mon Sep 17 00:00:00 2001 From: Max Nova Date: Tue, 17 Sep 2024 16:52:16 -0700 Subject: [PATCH 2/2] add epsilon def to header file --- src/math/FGTable.cpp | 3 +-- src/math/FGTable.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/math/FGTable.cpp b/src/math/FGTable.cpp index e6f39af862..c14a1f5927 100644 --- a/src/math/FGTable.cpp +++ b/src/math/FGTable.cpp @@ -509,8 +509,7 @@ double FGTable::GetValue(double key) const double Span = Data[2*r] - x0; assert(Span > 0.0); double Factor = (key - x0) / Span; - const double epsilon = 1e-9; - assert(Factor >= -epsilon && Factor <= 1.0 + epsilon); + assert(Factor >= -EPSILON && Factor <= 1.0 + EPSILON); double y0 = Data[2*r-1]; diff --git a/src/math/FGTable.h b/src/math/FGTable.h index 1439c69cb7..20905e1eea 100644 --- a/src/math/FGTable.h +++ b/src/math/FGTable.h @@ -313,6 +313,8 @@ class JSBSIM_API FGTable : public FGParameter, public FGJSBBase std::string GetName(void) const {return Name;} + static constexpr double EPSILON = 1e-9; + private: enum type {tt1D, tt2D, tt3D} Type; enum axis {eRow=0, eColumn, eTable};