Skip to content

Commit

Permalink
Rad-to-deg and deg-to-rad functions in SymHop
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed Jan 23, 2024
1 parent 05cccf5 commit 3a17401
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SymHop/include/SymHop.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SYMHOP_DLLAPI Expression
static Expression fromFunctionArguments(const QString function, const QList<Expression> arguments);
static Expression fromEquation(const Expression left, const Expression right);

double evaluate(const QMap<QString, double> &variables, const QMap<QString, SymHopFunctionoid*> *functions=0 /* = QMap<QString, SymHop::Function>() */, bool *ok=0) const;
double evaluate(const QMap<QString, double> &variables, const QMap<QString, SymHopFunctionoid*> *functions=0 /* = QMap<QString, SymHop::Function>() */, bool *ok=0) const;
// magse says: QMap is a derived type, you can't have reference this way.

void replaceByCopy(const Expression expr);
Expand Down
4 changes: 3 additions & 1 deletion SymHop/src/SymHop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,8 @@ double Expression::evaluate(const QMap<QString, double> &variables, const QMap<Q
else if(mFunction == "floor") { retval = floor(mArguments[0].evaluate(variables, functions, &ok1)); }
else if(mFunction == "ceil") { retval = ceil(mArguments[0].evaluate(variables, functions, &ok1)); }
else if(mFunction == "round") { retval = round(mArguments[0].evaluate(variables, functions, &ok1)); }
else if(mFunction == "r2d") { retval = mArguments[0].evaluate(variables, functions, &ok1)*180.0/M_PI; }
else if(mFunction == "d2r") { retval = mArguments[0].evaluate(variables, functions, &ok1)*M_PI/180.0; }
else if(mFunction == "sign")
{
if(mArguments[0].evaluate(variables, functions, &ok1) >= 0.0)
Expand Down Expand Up @@ -3756,7 +3758,7 @@ QString SymHop::getFunctionDerivative(const QString &key)
//! @brief Returns a list with supported functions for equation-based model generation
QStringList SymHop::getSupportedFunctionsList()
{
return QStringList() << "div" << "rem" << "mod" << "tan" << "cos" << "sin" << "atan" << "acos" << "asin" << "atan2" << "sinh" << "cosh" << "tanh" << "log" << "exp" << "sqrt" << "sign" << "abs" << "der" << "onPositive" << "onNegative" << "signedSquareL" << "limit" << "integer" << "floor" << "ceil" << "pow" << "min" << "max" << "nonZero" << "turbulentFlow" << "delay" << "equal" << "notEqual" << "greaterThan" << "smallerThan" << "greaterThanOrEqual" << "smallerThanOrEqual";
return QStringList() << "div" << "rem" << "mod" << "tan" << "cos" << "sin" << "atan" << "acos" << "asin" << "atan2" << "sinh" << "cosh" << "tanh" << "log" << "exp" << "sqrt" << "sign" << "abs" << "der" << "onPositive" << "onNegative" << "signedSquareL" << "limit" << "integer" << "floor" << "ceil" << "pow" << "min" << "max" << "nonZero" << "turbulentFlow" << "delay" << "equal" << "notEqual" << "greaterThan" << "smallerThan" << "greaterThanOrEqual" << "smallerThanOrEqual" << "r2d" << "d2r";
}


Expand Down

0 comments on commit 3a17401

Please sign in to comment.