49 #include "JSBSim_API.h"
50 #include "input_output/string_utilities.h"
53 # define M_PI 3.14159265358979323846
64 BaseException(
const std::string& msg) : std::runtime_error(msg) {}
80 auto seed_value = std::chrono::system_clock::now().time_since_epoch().count();
81 generator.seed(
static_cast<unsigned int>(seed_value));
85 : generator(seed), uniform_random(-1.0, 1.0), normal_random(0.0, 1.0) {}
87 void seed(
unsigned int value) {
88 generator.seed(value);
89 uniform_random.reset();
90 normal_random.reset();
99 std::default_random_engine generator;
100 std::uniform_real_distribution<double> uniform_random;
101 std::normal_distribution<double> normal_random;
134 Filter(
double coeff,
double dt) {
135 prev_in = prev_out = 0.0;
136 double denom = 2.0 + coeff*dt;
138 cb = (2.0 - coeff*dt)/denom;
140 double execute(
double in) {
141 double out = (in + prev_in)*ca + prev_out*cb;
150 static char highint[5];
153 static char halfint[5];
155 static char normint[6];
157 static char reset[5];
159 static char underon[5];
161 static char underoff[6];
163 static char fgblue[6];
165 static char fgcyan[6];
167 static char fgred[6];
169 static char fggreen[6];
171 static char fgdef[6];
176 static const std::string&
GetVersion(
void) {
return JSBSim_version;}
179 void disableHighLighting(
void);
181 static short debug_lvl;
187 return 1.8*kelvin - 459.4;
194 return celsius * 1.8 + 491.67;
201 return (rankine - 491.67)/1.8;
222 return (fahrenheit - 32.0)/1.8;
229 return celsius * 1.8 + 32.0;
236 return celsius + 273.15;
243 return kelvin - 273.15;
250 return measure*0.3048;
258 double eps = 2.0*DBL_EPSILON;
259 return std::fabs(a - b) <= eps * std::max<double>(std::fabs(a), std::fabs(b));
267 float eps = 2.0*FLT_EPSILON;
268 return std::fabs(a - b) <= eps * std::max<double>(std::fabs(a), std::fabs(b));
276 return EqualToRoundoff(a, (
float)b);
284 return EqualToRoundoff((
float)a, b);
289 static constexpr
double Constrain(
double min,
double value,
double max) {
290 return value<min?(min):(value>max?(max):(value));
293 static constexpr
double sign(
double num) {
return num>=0.0?1.0:-1.0;}
296 static constexpr
double radtodeg = 180. / M_PI;
297 static constexpr
double degtorad = M_PI / 180.;
298 static constexpr
double hptoftlbssec = 550.0;
299 static constexpr
double psftoinhg = 0.014138;
300 static constexpr
double psftopa = 47.88;
301 static constexpr
double fttom = 0.3048;
302 static constexpr
double ktstofps = 1852./(3600*fttom);
303 static constexpr
double fpstokts = 1.0 / ktstofps;
304 static constexpr
double inchtoft = 1.0/12.0;
305 static constexpr
double m3toft3 = 1.0/(fttom*fttom*fttom);
306 static constexpr
double in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3;
307 static constexpr
double inhgtopa = 3386.38;
314 static constexpr
double slugtolb = 32.174049;
315 static constexpr
double lbtoslug = 1.0/slugtolb;
316 static constexpr
double kgtolb = 2.20462;
317 static constexpr
double kgtoslug = 0.06852168;
318 static const std::string needed_cfg_version;
319 static const std::string JSBSim_version;
321 static std::string CreateIndexedPropertyName(
const std::string& Property,
int index);
325 enum {eL = 1, eM, eN };
327 enum {eP = 1, eQ, eR };
329 enum {eU = 1, eV, eW };
331 enum {eX = 1, eY, eZ };
333 enum {ePhi = 1, eTht, ePsi };
335 enum {eDrag = 1, eSide, eLift };
337 enum {eRoll = 1, ePitch, eYaw };
339 enum {eNorth = 1, eEast, eDown };
341 enum {eLat = 1, eLong, eRad };
343 enum {inNone = 0, inDegrees, inRadians, inMeters, inFeet };
First order, (low pass / lag) filter.
static bool EqualToRoundoff(double a, double b)
Finite precision comparison.
static constexpr double KelvinToCelsius(double kelvin)
Converts from degrees Kelvin to degrees Celsius.
virtual ~FGJSBBase()
Destructor for FGJSBBase.
static bool EqualToRoundoff(float a, double b)
Finite precision comparison.
static bool EqualToRoundoff(double a, float b)
Finite precision comparison.
FGJSBBase()
Constructor for FGJSBBase.
static constexpr double Constrain(double min, double value, double max)
Constrain a value between a minimum and a maximum value.
static constexpr double KelvinToFahrenheit(double kelvin)
Converts from degrees Kelvin to degrees Fahrenheit.
static constexpr double RankineToKelvin(double rankine)
Converts from degrees Rankine to degrees Kelvin.
static constexpr double CelsiusToRankine(double celsius)
Converts from degrees Celsius to degrees Rankine.
static constexpr double FeetToMeters(double measure)
Converts from feet to meters.
static const std::string & GetVersion(void)
Returns the version number of JSBSim.
static constexpr double RankineToCelsius(double rankine)
Converts from degrees Rankine to degrees Celsius.
static constexpr double CelsiusToKelvin(double celsius)
Converts from degrees Celsius to degrees Kelvin.
static bool EqualToRoundoff(float a, float b)
Finite precision comparison.
static constexpr double KelvinToRankine(double kelvin)
Converts from degrees Kelvin to degrees Rankine.
static constexpr double FahrenheitToCelsius(double fahrenheit)
Converts from degrees Fahrenheit to degrees Celsius.
static constexpr double CelsiusToFahrenheit(double celsius)
Converts from degrees Celsius to degrees Fahrenheit.
double GetNormalRandomNumber(void)
Get a random number which probability of occurrence is following Gauss normal distribution with a mea...
double GetUniformRandomNumber(void)
Get a random number which probability of occurrence is uniformly distributed over the segment [-1;1(.
RandomNumberGenerator(void)
Default constructor using a seed based on the system clock.
RandomNumberGenerator(unsigned int seed)
Constructor allowing to specify a seed.
void seed(unsigned int value)
Specify a new seed and reinitialize the random generation process.