From efde52468526b9ea820a6748188138f62939184c Mon Sep 17 00:00:00 2001 From: Henning Stahlke Date: Fri, 28 Apr 2017 20:23:48 +0200 Subject: [PATCH] YASIM move constants to a common header file. --- src/FDM/YASim/FGFDM.cpp | 19 ------------------- src/FDM/YASim/FGFDM.hpp | 1 + src/FDM/YASim/YASim.cxx | 17 +---------------- src/FDM/YASim/proptest.cpp | 17 ----------------- src/FDM/YASim/yasim-common.hpp | 34 ++++++++++++++++++++++++++++++++++ src/FDM/YASim/yasim-test.cpp | 6 +----- 6 files changed, 37 insertions(+), 57 deletions(-) create mode 100644 src/FDM/YASim/yasim-common.hpp diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index 8bcd6437f..e5e3f51f5 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -27,25 +27,6 @@ namespace yasim { -// Some conversion factors -static const float KTS2MPS = 0.514444444444; -static const float KMH2MPS = 1/3.6; -static const float FT2M = 0.3048; -static const float DEG2RAD = 0.0174532925199; -static const float RPM2RAD = 0.10471975512; -static const float LBS2N = 4.44822; -static const float LBS2KG = 0.45359237; -static const float KG2LBS = 2.2046225; -static const float CM2GALS = 264.172037284; -static const float HP2W = 745.700; -static const float INHG2PA = 3386.389; -static const float K2DEGF = 1.8; -static const float K2DEGFOFFSET = -459.4; -static const float CIN2CM = 1.6387064e-5; -static const float YASIM_PI = 3.14159265358979323846; - -static const float NM2FTLB = (1/(LBS2N*FT2M)); - // Stubs, so that this can be compiled without the FlightGear // binary. What's the best way to handle this? diff --git a/src/FDM/YASim/FGFDM.hpp b/src/FDM/YASim/FGFDM.hpp index c888202d2..28eabba21 100644 --- a/src/FDM/YASim/FGFDM.hpp +++ b/src/FDM/YASim/FGFDM.hpp @@ -4,6 +4,7 @@ #include #include +#include "yasim-common.hpp" #include "Airplane.hpp" #include "Vector.hpp" diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index f966b29e1..cfdf70d3f 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -15,6 +15,7 @@ #include
#include
+#include "yasim-common.hpp" #include "FGFDM.hpp" #include "Atmosphere.hpp" #include "Math.hpp" @@ -34,22 +35,6 @@ using namespace yasim; using std::string; -static const float YASIM_PI = 3.14159265358979323846; -static const float RAD2DEG = 180/YASIM_PI; -static const float PI2 = YASIM_PI*2; -static const float M2FT = 3.2808399; -static const float FT2M = 0.3048; -static const float MPS2KTS = 3600.0/1852.0; -static const float INHG2PA = 3386.389; -static const float SLUG2KG = 14.59390; - -#if 0 // unused constant values -static const float RAD2RPM = 9.54929658551; -static const float CM2GALS = 264.172037284; // gallons/cubic meter -static const float KG2LBS = 2.20462262185; -static const float W2HP = 1.3416e-3; -#endif - YASim::YASim(double dt) : _simTime(0) { diff --git a/src/FDM/YASim/proptest.cpp b/src/FDM/YASim/proptest.cpp index 29a1aeec6..c32c849e3 100644 --- a/src/FDM/YASim/proptest.cpp +++ b/src/FDM/YASim/proptest.cpp @@ -29,23 +29,6 @@ float fgGetFloat (const char * name, float defaultValue) { return 0; } double fgGetDouble (const char * name, double defaultValue) { return 0; } bool fgSetDouble (const char * name, double defaultValue) { return false; } -static const float KTS2MPS = 0.514444444444; -static const float RPM2RAD = 0.10471975512; -static const float HP2W = 745.700; -static const float FT2M = 0.3048; -static const float N2LB = 0.224809; - -// static const float DEG2RAD = 0.0174532925199; -// static const float LBS2N = 4.44822; -// static const float LBS2KG = 0.45359237; -// static const float KG2LBS = 2.2046225; -// static const float CM2GALS = 264.172037284; -// static const float INHG2PA = 3386.389; -// static const float K2DEGF = 1.8; -// static const float K2DEGFOFFSET = -459.4; -// static const float CIN2CM = 1.6387064e-5; -// static const float YASIM_PI = 3.14159265358979323846; - const int COUNT = 100; int main(int argc, char** argv) diff --git a/src/FDM/YASim/yasim-common.hpp b/src/FDM/YASim/yasim-common.hpp new file mode 100644 index 000000000..6f2678087 --- /dev/null +++ b/src/FDM/YASim/yasim-common.hpp @@ -0,0 +1,34 @@ +#ifndef _YASIM_COMMON_HPP +#define _YASIM_COMMON_HPP + +namespace yasim { + static const float YASIM_PI = 3.14159265358979323846; + static const float PI2 = YASIM_PI*2; + static const float RAD2DEG = 180/YASIM_PI; + static const float DEG2RAD = YASIM_PI/180; + static const float RPM2RAD = YASIM_PI/30; + + static const float KTS2MPS = 1852.0/3600.0; + static const float MPS2KTS = 3600.0/1852.0; + static const float KMH2MPS = 1/3.6; + + static const float FT2M = 0.3048; + static const float M2FT = 1/FT2M; + + static const float LBS2N = 4.44822; + static const float N2LB = 1/LBS2N; + static const float LBS2KG = 0.45359237; + static const float KG2LBS = 1/LBS2KG; + static const float CM2GALS = 264.172037284; + static const float HP2W = 745.700; + static const float INHG2PA = 3386.389; + static const float K2DEGF = 1.8; + static const float K2DEGFOFFSET = -459.4; + static const float CIN2CM = 1.6387064e-5; + + static const float NM2FTLB = (1/(LBS2N*FT2M)); + static const float SLUG2KG = 14.59390; + +}; + +#endif // ifndef _YASIM_COMMON_HPP diff --git a/src/FDM/YASim/yasim-test.cpp b/src/FDM/YASim/yasim-test.cpp index 25783bfa1..58efbfafe 100644 --- a/src/FDM/YASim/yasim-test.cpp +++ b/src/FDM/YASim/yasim-test.cpp @@ -7,6 +7,7 @@ #include #include +#include "yasim-common.hpp" #include "FGFDM.hpp" #include "Atmosphere.hpp" #include "RigidBody.hpp" @@ -26,11 +27,6 @@ float fgGetFloat (const char * name, float defaultValue) { return 0; } double fgGetDouble (const char * name, double defaultValue = 0.0) { return 0; } bool fgSetDouble (const char * name, double defaultValue = 0.0) { return 0; } -static const float RAD2DEG = 57.2957795131; -static const float DEG2RAD = 0.0174532925199; -/// knots 2 meters per second -static const float KTS2MPS = 0.514444444444; - enum Config {