X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FYASim%2FMath.cpp;h=4662d70b2329e8ce31ddb7f5052636ecbb0d423d;hb=c3cefaf883ddadb467c0e5da7f966558cbc2355b;hp=0af57a03f1ba178917fca37fdee72b4245dc2b59;hpb=5b84ae51a54afb63effb8841ed08643bb5701aa7;p=flightgear.git diff --git a/src/FDM/YASim/Math.cpp b/src/FDM/YASim/Math.cpp index 0af57a03f..4662d70b2 100644 --- a/src/FDM/YASim/Math.cpp +++ b/src/FDM/YASim/Math.cpp @@ -3,44 +3,46 @@ #include "Math.hpp" namespace yasim { -float Math::abs(float f) +float Math::clamp(float val, float min, float max) { - return ::fabs(f); + if(val < min) return min; + if(val > max) return max; + return val; } -float Math::sqrt(float f) +float Math::abs(float f) { - return ::sqrt(f); + return (float)::fabs(f); } -float Math::pow(float base, float exp) +float Math::sqrt(float f) { - return ::pow(base, exp); + return (float)::sqrt(f); } float Math::ceil(float f) { - return ::ceil(f); + return (float)::ceil(f); } float Math::cos(float f) { - return ::cos(f); + return (float)::cos(f); } float Math::sin(float f) { - return ::sin(f); + return (float)::sin(f); } float Math::tan(float f) { - return ::tan(f); + return (float)::tan(f); } float Math::atan2(float y, float x) { - return ::atan2(y, x); + return (float)::atan2(y, x); } double Math::abs(double f) @@ -53,9 +55,9 @@ double Math::sqrt(double f) return ::sqrt(f); } -double Math::pow(double base, double exp) +float Math::pow(double base, double exp) { - return ::pow(base, exp); + return (float)::pow(base, exp); } double Math::ceil(double f) @@ -152,7 +154,8 @@ void Math::mmul33(float* a, float* b, float* out) tmp[5] = a[3]*b[2] + a[4]*b[5] + a[5]*b[8]; tmp[8] = a[6]*b[2] + a[7]*b[5] + a[8]*b[8]; - for(int i=0; i<9; i++) + int i; + for(i=0; i<9; i++) out[i] = tmp[i]; }