diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp index 160481467..544e1eb50 100644 --- a/src/libs/qmuparser/qmuparser.cpp +++ b/src/libs/qmuparser/qmuparser.cpp @@ -45,6 +45,18 @@ namespace qmu { //--------------------------------------------------------------------------------------------------------------------- // Trigonometric function +qreal QmuParser::DegreeToRadian(qreal deg) +{ + return deg * M_PI / 180.0; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::RadianToDegree(qreal rad) +{ + return rad * 180.0 / M_PI; +} + +//--------------------------------------------------------------------------------------------------------------------- qreal QmuParser::Sinh(qreal v) { return sinh(v); @@ -79,6 +91,79 @@ qreal QmuParser::ATanh(qreal v) { return (0.5 * log((1 + v) / (1 - v))); } + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::SinhD(qreal v) +{ + return RadianToDegree(sinh(v)); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::CoshD(qreal v) +{ + return RadianToDegree(cosh(v)); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::TanhD(qreal v) +{ + return RadianToDegree(tanh(v)); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::ASinhD(qreal v) +{ + return RadianToDegree(log(v + qSqrt(v * v + 1))); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::ACoshD(qreal v) +{ + return RadianToDegree(log(v + qSqrt(v * v - 1))); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::ATanhD(qreal v) +{ + return RadianToDegree(0.5 * log((1 + v) / (1 - v))); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::SinD(qreal v) +{ + return RadianToDegree(qSin(v)); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::ASinD(qreal v) +{ + return RadianToDegree(qAsin(v)); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::CosD(qreal v) +{ + return RadianToDegree(qCos(v)); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::ACosD(qreal v) +{ + return RadianToDegree(qAcos(v)); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::TanD(qreal v) +{ + return RadianToDegree(qTan(v)); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal QmuParser::ATanD(qreal v) +{ + return RadianToDegree(qAtan(v)); +} + //--------------------------------------------------------------------------------------------------------------------- // Logarithm functions @@ -279,23 +364,39 @@ void QmuParser::InitCharSets() */ void QmuParser::InitFun() { + // trigonometric helper functions + DefineFun("degTorad", DegreeToRadian); + DefineFun("radTodeg", RadianToDegree); + // trigonometric functions DefineFun("sin", qSin); DefineFun("cos", qCos); DefineFun("tan", qTan); + DefineFun("sinD", SinD); + DefineFun("cosD", CosD); + DefineFun("tanD", TanD); // arcus functions DefineFun("asin", qAsin); DefineFun("acos", qAcos); DefineFun("atan", qAtan); DefineFun("atan2", qAtan2); + DefineFun("asinD", ASinD); + DefineFun("acosD", ACosD); + DefineFun("atanD", ATanD); // hyperbolic functions DefineFun("sinh", Sinh); DefineFun("cosh", Cosh); DefineFun("tanh", Tanh); + DefineFun("sinhD", SinhD); + DefineFun("coshD", CoshD); + DefineFun("tanhD", TanhD); // arcus hyperbolic functions DefineFun("asinh", ASinh); DefineFun("acosh", ACosh); DefineFun("atanh", ATanh); + DefineFun("asinhD", ASinhD); + DefineFun("acoshD", ACoshD); + DefineFun("atanhD", ATanhD); // Logarithm functions DefineFun("log2", Log2); DefineFun("log10", Log10); diff --git a/src/libs/qmuparser/qmuparser.h b/src/libs/qmuparser/qmuparser.h index b0553ca10..1b98bee51 100644 --- a/src/libs/qmuparser/qmuparser.h +++ b/src/libs/qmuparser/qmuparser.h @@ -68,6 +68,22 @@ namespace qmu static qreal ASinh(qreal); static qreal ACosh(qreal); static qreal ATanh(qreal); + // functions working with degrees + static qreal DegreeToRadian(qreal); + static qreal RadianToDegree(qreal); + static qreal SinD(qreal); + static qreal CosD(qreal); + static qreal TanD(qreal); + static qreal ASinD(qreal); + static qreal ACosD(qreal); + static qreal ATanD(qreal); + static qreal SinhD(qreal); + static qreal CoshD(qreal); + static qreal TanhD(qreal); + static qreal ASinhD(qreal); + static qreal ACoshD(qreal); + static qreal ATanhD(qreal); + // Logarithm functions static qreal Log2(qreal); // Logarithm Base 2 static qreal Log10(qreal); // Logarithm Base 10 diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 2b41af8b6..37207d9b9 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -381,6 +381,8 @@ const QString p54_S = QStringLiteral("p54"); const QString p998_S = QStringLiteral("p998"); //functions +const QString degTorad_F = QStringLiteral("degTorad"); +const QString radTodeg_F = QStringLiteral("radTodeg"); const QString sin_F = QStringLiteral("sin"); const QString cos_F = QStringLiteral("cos"); const QString tan_F = QStringLiteral("tan"); @@ -393,6 +395,18 @@ const QString tanh_F = QStringLiteral("tanh"); const QString asinh_F = QStringLiteral("asinh"); const QString acosh_F = QStringLiteral("acosh"); const QString atanh_F = QStringLiteral("atanh"); +const QString sinD_F = QStringLiteral("sinD"); +const QString cosD_F = QStringLiteral("cosD"); +const QString tanD_F = QStringLiteral("tanD"); +const QString asinD_F = QStringLiteral("asinD"); +const QString acosD_F = QStringLiteral("acosD"); +const QString atanD_F = QStringLiteral("atanD"); +const QString sinhD_F = QStringLiteral("sinhD"); +const QString coshD_F = QStringLiteral("coshD"); +const QString tanhD_F = QStringLiteral("tanhD"); +const QString asinhD_F = QStringLiteral("asinhD"); +const QString acoshD_F = QStringLiteral("acoshD"); +const QString atanhD_F = QStringLiteral("atanhD"); const QString log2_F = QStringLiteral("log2"); const QString log10_F = QStringLiteral("log10"); const QString log_F = QStringLiteral("log"); @@ -408,8 +422,11 @@ const QString sum_F = QStringLiteral("sum"); const QString avg_F = QStringLiteral("avg"); const QString fmod_F = QStringLiteral("fmod"); -const QStringList builInFunctions = QStringList() << sin_F << cos_F << tan_F << asin_F << acos_F << atan_F +const QStringList builInFunctions = QStringList() << degTorad_F << radTodeg_F + << sin_F << cos_F << tan_F << asin_F << acos_F << atan_F << sinh_F << cosh_F << tanh_F << asinh_F << acosh_F << atanh_F + << sinD_F << cosD_F << tanD_F << asinD_F << acosD_F << atanD_F + << sinhD_F << coshD_F << tanhD_F << asinhD_F << acoshD_F << atanhD_F << log2_F << log10_F << log_F << ln_F << exp_F << sqrt_F << sign_F << rint_F << abs_F << min_F << max_F << sum_F << avg_F << fmod_F; diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index e74ad2e67..5afb738b3 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -607,6 +607,8 @@ QStringList ListPMSystems(); void InitPMSystems(QComboBox *systemCombo); // functions +extern const QString degTorad_F; +extern const QString radTodeg_F; extern const QString sin_F; extern const QString cos_F; extern const QString tan_F; @@ -619,6 +621,18 @@ extern const QString tanh_F; extern const QString asinh_F; extern const QString acosh_F; extern const QString atanh_F; +extern const QString sinD_F; +extern const QString cosD_F; +extern const QString tanD_F; +extern const QString asinD_F; +extern const QString acosD_F; +extern const QString atanD_F; +extern const QString sinhD_F; +extern const QString coshD_F; +extern const QString tanhD_F; +extern const QString asinhD_F; +extern const QString acoshD_F; +extern const QString atanhD_F; extern const QString log2_F; extern const QString log10_F; extern const QString log_F; diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 2fce248c3..65552be53 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -401,18 +401,32 @@ void VTranslateVars::InitVariables() //--------------------------------------------------------------------------------------------------------------------- void VTranslateVars::InitFunctions() { - functions.insert(sin_F, translate("VTranslateVars", "sin", "sine function")); - functions.insert(cos_F, translate("VTranslateVars", "cos", "cosine function")); - functions.insert(tan_F, translate("VTranslateVars", "tan", "tangens function")); - functions.insert(asin_F, translate("VTranslateVars", "asin", "arcus sine function")); - functions.insert(acos_F, translate("VTranslateVars", "acos", "arcus cosine function")); - functions.insert(atan_F, translate("VTranslateVars", "atan", "arcus tangens function")); - functions.insert(sinh_F, translate("VTranslateVars", "sinh", "hyperbolic sine function")); - functions.insert(cosh_F, translate("VTranslateVars", "cosh", "hyperbolic cosine")); - functions.insert(tanh_F, translate("VTranslateVars", "tanh", "hyperbolic tangens function")); - functions.insert(asinh_F, translate("VTranslateVars", "asinh", "hyperbolic arcus sine function")); - functions.insert(acosh_F, translate("VTranslateVars", "acosh", "hyperbolic arcus cosine function")); - functions.insert(atanh_F, translate("VTranslateVars", "atanh", "hyperbolic arcur tangens function")); + functions.insert(degTorad_F, translate("VTranslateVars", "degTorad", "converts degrees to radian")); + functions.insert(radTodeg_F, translate("VTranslateVars", "radTodeg", "converts radian to degrees")); + functions.insert(sin_F, translate("VTranslateVars", "sin", "sine function working with radians")); + functions.insert(cos_F, translate("VTranslateVars", "cos", "cosine function working with radians")); + functions.insert(tan_F, translate("VTranslateVars", "tan", "tangens function working with radians")); + functions.insert(asin_F, translate("VTranslateVars", "asin", "arcus sine function working with radians")); + functions.insert(acos_F, translate("VTranslateVars", "acos", "arcus cosine function working with radians")); + functions.insert(atan_F, translate("VTranslateVars", "atan", "arcus tangens function working with radians")); + functions.insert(sinh_F, translate("VTranslateVars", "sinh", "hyperbolic sine function working with radians")); + functions.insert(cosh_F, translate("VTranslateVars", "cosh", "hyperbolic cosine working with radians")); + functions.insert(tanh_F, translate("VTranslateVars", "tanh", "hyperbolic tangens function working with radians")); + functions.insert(asinh_F, translate("VTranslateVars", "asinh", "hyperbolic arcus sine function working with radians")); + functions.insert(acosh_F, translate("VTranslateVars", "acosh", "hyperbolic arcus cosine function working with radians")); + functions.insert(atanh_F, translate("VTranslateVars", "atanh", "hyperbolic arcur tangens function working with radians")); + functions.insert(sinD_F, translate("VTranslateVars", "sinD", "sine function working with degrees")); + functions.insert(cosD_F, translate("VTranslateVars", "cosD", "cosine function working with degrees")); + functions.insert(tanD_F, translate("VTranslateVars", "tanD", "tangens function working with degrees")); + functions.insert(asinD_F, translate("VTranslateVars", "asinD", "arcus sine function working with degrees")); + functions.insert(acosD_F, translate("VTranslateVars", "acosD", "arcus cosine function working with degrees")); + functions.insert(atanD_F, translate("VTranslateVars", "atanD", "arcus tangens function working with degrees")); + functions.insert(sinhD_F, translate("VTranslateVars", "sinhD", "hyperbolic sine function working with degrees")); + functions.insert(coshD_F, translate("VTranslateVars", "coshD", "hyperbolic cosine function working with degrees")); + functions.insert(tanhD_F, translate("VTranslateVars", "tanhD", "hyperbolic tangens function working with degrees")); + functions.insert(asinhD_F, translate("VTranslateVars", "asinhD", "hyperbolic arcus sine function working with degrees")); + functions.insert(acoshD_F, translate("VTranslateVars", "acoshD", "hyperbolic arcus cosine function working with degrees")); + functions.insert(atanhD_F, translate("VTranslateVars", "atanhD", "hyperbolic arcur tangens function working with degrees")); functions.insert(log2_F, translate("VTranslateVars", "log2", "logarithm to the base 2")); functions.insert(log10_F, translate("VTranslateVars", "log10", "logarithm to the base 10")); functions.insert(log_F, translate("VTranslateVars", "log", "logarithm to the base 10"));