X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2FFGJSBBase.cpp;h=a361a37d256732250ebef9803ba2fd9c8e5b23f1;hb=96a902a2eb6e4a64cd4b225eb68fd85c07901903;hp=4e02407a41025ba1262d0fae46be7fbdb3029c0a;hpb=48cad71a702c7db7981f893112cbccdc84428243;p=flightgear.git diff --git a/src/FDM/JSBSim/FGJSBBase.cpp b/src/FDM/JSBSim/FGJSBBase.cpp index 4e02407a4..a361a37d2 100644 --- a/src/FDM/JSBSim/FGJSBBase.cpp +++ b/src/FDM/JSBSim/FGJSBBase.cpp @@ -39,10 +39,12 @@ INCLUDES #include "FGJSBBase.h" #include +#include +#include namespace JSBSim { -static const char *IdSrc = "$Id$"; +static const char *IdSrc = "$Id: FGJSBBase.cpp,v 1.29 2010/03/18 13:19:21 jberndt Exp $"; static const char *IdHdr = ID_JSBBASE; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -75,8 +77,8 @@ CLASS IMPLEMENTATION char FGJSBBase::fgdef[6] = {'\0' }; #endif -const double FGJSBBase::radtodeg = 57.29578; -const double FGJSBBase::degtorad = 1.745329E-2; +const double FGJSBBase::radtodeg = 57.295779513082320876798154814105; +const double FGJSBBase::degtorad = 0.017453292519943295769236907684886; const double FGJSBBase::hptoftlbssec = 550.0; const double FGJSBBase::psftoinhg = 0.014138; const double FGJSBBase::psftopa = 47.88; @@ -240,5 +242,43 @@ void FGJSBBase::disableHighLighting(void) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +string FGJSBBase::CreateIndexedPropertyName(const string& Property, int index) +{ + std::ostringstream buf; + buf << Property << '[' << index << ']'; + return buf.str(); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +double FGJSBBase::GaussianRandomNumber(void) +{ + static double V1, V2, S; + static int phase = 0; + double X; + + if (phase == 0) { + V1 = V2 = S = X = 0.0; + + do { + double U1 = (double)rand() / RAND_MAX; + double U2 = (double)rand() / RAND_MAX; + + V1 = 2 * U1 - 1; + V2 = 2 * U2 - 1; + S = V1 * V1 + V2 * V2; + } while(S >= 1 || S == 0); + + X = V1 * sqrt(-2 * log(S) / S); + } else + X = V2 * sqrt(-2 * log(S) / S); + + phase = 1 - phase; + + return X; +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + } // namespace JSBSim