diff --git a/src_main/math/pievaluator.cpp b/src_main/math/pievaluator.cpp index 6e36739c..9db4768d 100755 --- a/src_main/math/pievaluator.cpp +++ b/src_main/math/pievaluator.cpp @@ -105,6 +105,7 @@ * * clamp(x, a, b) - trim x on range [a, b] * * step(x, s) - 0 if x < s, else 1 * * mix(x, a, b) - interpolate between a and b linear for x (a * (1 - x) + b * x) + * * round(x) - round * * There are some built-in constans: * * i (imaginary 1) @@ -161,6 +162,7 @@ PIEvaluatorContent::PIEvaluatorContent() { addFunction("step", 2); // (x,s) = x >= s ? 1. : 0. (1 if 'x' >= 's', else 0) addFunction("mix", 3); // (x,a,b) = a*(1.-x) + b*x (interpolate between 'a' and 'b' linear for 'x') addFunction("defined", 1); + addFunction("round", 1); clearCustomVariables(); //addVariable("n", 0.); //addVariable("x1", 123); @@ -250,6 +252,7 @@ PIEvaluatorTypes::BaseFunctions PIEvaluatorContent::getBaseFunction(const PIStri if (name == "step") return PIEvaluatorTypes::bfStep; if (name == "mix") return PIEvaluatorTypes::bfMix; if (name == "defined") return PIEvaluatorTypes::bfDefined; + if (name == "round") return PIEvaluatorTypes::bfRound; return PIEvaluatorTypes::bfUnknown; } @@ -1168,6 +1171,9 @@ inline void PIEvaluator::execFunction(const PIEvaluatorTypes::Instruction & ci) case PIEvaluatorTypes::bfRandomn: tmpvars[oi].value = randomn(value(ci.operators[0]).real(), value(ci.operators[1]).real()); break; + case PIEvaluatorTypes::bfRound: + tmpvars[oi].value = piRoundd(value(ci.operators[0]).real()); + break; default: break; } } diff --git a/src_main/math/pievaluator.h b/src_main/math/pievaluator.h index 2a70fbba..299e43c0 100755 --- a/src_main/math/pievaluator.h +++ b/src_main/math/pievaluator.h @@ -46,6 +46,7 @@ namespace PIEvaluatorTypes { bfRad, bfDeg, bfJ0, bfJ1, bfJN, bfY0, bfY1, bfYN, bfMin, bfMax, bfClamp, bfStep, bfMix, bfDefined, + bfRound, bfCustom = 0xFFFF };