VuoMathExpressionParser implementation.
Definition in file VuoMathExpressionParser.cc.
Go to the source code of this file.
Classes | |
class | VuoMathExpressionErrorInternal |
C++ implementation of opaque C type VuoMathExpressionError. More... | |
class | VuoMathExpressionParserInternal |
C++ implementation of opaque C type VuoMathExpressionParser. More... | |
Functions | |
const char * | VuoMathExpressionError_getMessage (VuoMathExpressionError error) |
Returns a description of the error. More... | |
VuoList_VuoInteger | VuoMathExpressionError_getExpressionIndices (VuoMathExpressionError error) |
Returns a sorted list of the indices of the math expressions causing the error. More... | |
void | VuoMathExpressionError_free (VuoMathExpressionError error) |
Destructor. More... | |
static double | deg2rad (double degrees) |
Converts degrees to radians. More... | |
static double | rad2deg (double radians) |
Converts radians to degrees. More... | |
static double | muparser_rint (double x) |
As defined by muParserTemplateMagic.h. More... | |
static double | fract (double x) |
As defined by https://www.opengl.org/sdk/docs/man/html/fract.xhtml. More... | |
static double | clamp (double x, double minVal, double maxVal) |
As defined by https://www.opengl.org/sdk/docs/man/html/clamp.xhtml. More... | |
static double | step (double edge, double x) |
As defined by https://www.opengl.org/sdk/docs/man/html/step.xhtml. More... | |
static double | smoothstep (double edge0, double edge1, double x) |
As defined by https://www.opengl.org/sdk/docs/man/html/smoothstep.xhtml. More... | |
static double | mix (double x, double y, double a) |
As defined by https://www.opengl.org/sdk/docs/man/html/mix.xhtml. More... | |
void | VuoMathExpressionParser_defineStandardLibrary (void *p) |
Given a pointer to a mu::Parser instance, adds Vuo's standard operators, constants, and functions. More... | |
static vector< string > | splitSingleExpressionOnAssignmentOperators (string expression) |
Returns the parts of expression separated by (and not including) the assignment operator ("="). More... | |
static void | checkSyntaxOfSingleExpression (string expression, VuoMathExpressionError *error) |
Checks that expression contains a syntactically valid, single math expression with at most one assignment operator. More... | |
static void | checkSyntaxOfMultipleExpressions (VuoList_VuoText expressions, VuoMathExpressionError *error) |
Checks that each single math expression in expressions satisfies checkSyntaxOfSingleExpression(). More... | |
static void | parseVariablesFromSingleExpression (string expression, vector< string > &inputVariableNames, string &outputVariableName, VuoMathExpressionError *error) |
Parses the unique variable names from expression and puts them in inputVariableNames and outputVariableName. More... | |
static void | parseVariablesFromMultipleExpressions (VuoList_VuoText expressions, vector< string > &inputVariableNames, vector< string > &outputVariableNames, VuoMathExpressionError *error) |
Parses the unique variable names from expressions and puts them in inputVariableNames and outputVariableNames. More... | |
void | VuoMathExpressionParser_free (void *me) |
Destroys me, a VuoMathExpressionParser. More... | |
VuoMathExpressionParser | VuoMathExpressionParser_makeFromSingleExpression (VuoText expression, VuoMathExpressionError *error) |
Parses expression (e.g. More... | |
VuoMathExpressionParser | VuoMathExpressionParser_makeFromMultipleExpressions (VuoList_VuoText expressions, VuoMathExpressionError *error) |
Parses expressions (e.g. More... | |
VuoList_VuoText | VuoMathExpressionParser_getInputVariables (VuoMathExpressionParser m) |
Returns the unique input variable names from the parsed expression(s), in alphabetical order. More... | |
VuoList_VuoText | VuoMathExpressionParser_getOutputVariables (VuoMathExpressionParser m) |
Returns the output variable names from the parsed expression(s), in the order they appeared. More... | |
VuoDictionary_VuoText_VuoReal | VuoMathExpressionParser_calculate (VuoMathExpressionParser m, VuoDictionary_VuoText_VuoReal inputValues) |
Evaluates the parsed expression(s). More... | |
VuoList_VuoReal | VuoMathExpressionParser_calculateList (VuoMathExpressionParser m, VuoList_VuoReal xValues, VuoDictionary_VuoText_VuoReal constants) |
Evaluates the expression for each of xValues . More... | |
static double | sinInDegrees (double degrees) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | cosInDegrees (double degrees) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | tanInDegrees (double degrees) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | asinInDegrees (double x) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | acosInDegrees (double x) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | atanInDegrees (double x) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | atan2InDegrees (double y, double x) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | sinhInDegrees (double degrees) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | coshInDegrees (double degrees) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | tanhInDegrees (double degrees) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | asinhInDegrees (double x) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | acoshInDegrees (double x) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | atanhInDegrees (double x) |
Trigonometric functions that take degrees instead of radians. More... | |
static double | perlin2d (double x, double y) |
Gradient noise wrappers. More... | |
static double | perlin3d (double x, double y, double z) |
Gradient noise wrappers. More... | |
static double | perlin4d (double x, double y, double z, double w) |
Gradient noise wrappers. More... | |
static double | simplex2d (double x, double y) |
Gradient noise wrappers. More... | |
static double | simplex3d (double x, double y, double z) |
Gradient noise wrappers. More... | |
static double | simplex4d (double x, double y, double z, double w) |
Gradient noise wrappers. More... | |
Variables | |
static const size_t | MAX_VARIABLE_COUNT = 64 |
Maximum number of variables that can be parsed by a VuoMathExpressionParser. More... | |
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 196 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 189 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 195 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 188 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 191 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 197 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 190 of file VuoMathExpressionParser.cc.
|
static |
Checks that each single math expression in expressions satisfies checkSyntaxOfSingleExpression().
Definition at line 428 of file VuoMathExpressionParser.cc.
|
static |
Checks that expression contains a syntactically valid, single math expression with at most one assignment operator.
Definition at line 398 of file VuoMathExpressionParser.cc.
|
static |
As defined by https://www.opengl.org/sdk/docs/man/html/clamp.xhtml.
Definition at line 151 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 193 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 186 of file VuoMathExpressionParser.cc.
|
static |
Converts degrees to radians.
Definition at line 119 of file VuoMathExpressionParser.cc.
|
static |
As defined by https://www.opengl.org/sdk/docs/man/html/fract.xhtml.
Definition at line 143 of file VuoMathExpressionParser.cc.
|
static |
As defined by https://www.opengl.org/sdk/docs/man/html/mix.xhtml.
Definition at line 176 of file VuoMathExpressionParser.cc.
|
static |
As defined by muParserTemplateMagic.h.
Definition at line 135 of file VuoMathExpressionParser.cc.
|
static |
Parses the unique variable names from expressions and puts them in inputVariableNames and outputVariableNames.
Assumes that expressions satisfies checkSyntaxOfMultipleExpressions().
Definition at line 477 of file VuoMathExpressionParser.cc.
|
static |
Parses the unique variable names from expression and puts them in inputVariableNames and outputVariableName.
Assumes that expression satisfies checkSyntaxOfSingleExpression().
Definition at line 449 of file VuoMathExpressionParser.cc.
|
static |
Gradient noise wrappers.
Definition at line 204 of file VuoMathExpressionParser.cc.
|
static |
Gradient noise wrappers.
Definition at line 205 of file VuoMathExpressionParser.cc.
|
static |
Gradient noise wrappers.
Definition at line 206 of file VuoMathExpressionParser.cc.
|
static |
Converts radians to degrees.
Definition at line 127 of file VuoMathExpressionParser.cc.
|
static |
Gradient noise wrappers.
Definition at line 207 of file VuoMathExpressionParser.cc.
|
static |
Gradient noise wrappers.
Definition at line 208 of file VuoMathExpressionParser.cc.
|
static |
Gradient noise wrappers.
Definition at line 209 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 192 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 185 of file VuoMathExpressionParser.cc.
|
static |
As defined by https://www.opengl.org/sdk/docs/man/html/smoothstep.xhtml.
Definition at line 167 of file VuoMathExpressionParser.cc.
|
static |
Returns the parts of expression separated by (and not including) the assignment operator ("=").
Assumes that expression satisfies checkSyntaxOfSingleExpression().
Definition at line 367 of file VuoMathExpressionParser.cc.
|
static |
As defined by https://www.opengl.org/sdk/docs/man/html/step.xhtml.
Definition at line 159 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 194 of file VuoMathExpressionParser.cc.
|
static |
Trigonometric functions that take degrees instead of radians.
Definition at line 187 of file VuoMathExpressionParser.cc.
void VuoMathExpressionError_free | ( | VuoMathExpressionError | error | ) |
Destructor.
Definition at line 107 of file VuoMathExpressionParser.cc.
VuoList_VuoInteger VuoMathExpressionError_getExpressionIndices | ( | VuoMathExpressionError | error | ) |
Returns a sorted list of the indices of the math expressions causing the error.
The indices refer to the VuoList_VuoText passed to VuoMathExpressionParser_makeFromMultipleExpressions().
Definition at line 93 of file VuoMathExpressionParser.cc.
const char* VuoMathExpressionError_getMessage | ( | VuoMathExpressionError | error | ) |
Returns a description of the error.
The returned pointer is owned by error and should not be freed by the caller.
Definition at line 82 of file VuoMathExpressionParser.cc.
VuoDictionary_VuoText_VuoReal VuoMathExpressionParser_calculate | ( | VuoMathExpressionParser | m, |
VuoDictionary_VuoText_VuoReal | inputValues | ||
) |
Evaluates the parsed expression(s).
The value of each input variable is set from inputValues (a mapping of variable names to values). Any variables not in inputValues are set to 0.
Returns a mapping of output variable names to values.
Definition at line 644 of file VuoMathExpressionParser.cc.
VuoList_VuoReal VuoMathExpressionParser_calculateList | ( | VuoMathExpressionParser | m, |
VuoList_VuoReal | xValues, | ||
VuoDictionary_VuoText_VuoReal | constants | ||
) |
Evaluates the expression for each of xValues
.
Definition at line 686 of file VuoMathExpressionParser.cc.
void VuoMathExpressionParser_defineStandardLibrary | ( | void * | p | ) |
Given a pointer to a mu::Parser
instance, adds Vuo's standard operators, constants, and functions.
Definition at line 215 of file VuoMathExpressionParser.cc.
void VuoMathExpressionParser_free | ( | void * | me | ) |
Destroys me, a VuoMathExpressionParser.
Definition at line 543 of file VuoMathExpressionParser.cc.
VuoList_VuoText VuoMathExpressionParser_getInputVariables | ( | VuoMathExpressionParser | m | ) |
Returns the unique input variable names from the parsed expression(s), in alphabetical order.
Definition at line 609 of file VuoMathExpressionParser.cc.
VuoList_VuoText VuoMathExpressionParser_getOutputVariables | ( | VuoMathExpressionParser | m | ) |
Returns the output variable names from the parsed expression(s), in the order they appeared.
For a non-assignment expression (e.g. "x + 1", as opposed to "y = x + 1"), a unique name is automatically assigned.
Definition at line 625 of file VuoMathExpressionParser.cc.
VuoMathExpressionParser VuoMathExpressionParser_makeFromMultipleExpressions | ( | VuoList_VuoText | expressions, |
VuoMathExpressionError * | error | ||
) |
Parses expressions (e.g.
["sum=n1+n2", "product=n1*n2", "n1-n2+5"]).
If parsing fails, returns null and sets error.
Definition at line 577 of file VuoMathExpressionParser.cc.
VuoMathExpressionParser VuoMathExpressionParser_makeFromSingleExpression | ( | VuoText | expression, |
VuoMathExpressionError * | error | ||
) |
Parses expression (e.g.
"a + b" or "y = x + 1").
If parsing fails, returns null and sets error.
Definition at line 553 of file VuoMathExpressionParser.cc.
|
static |
Maximum number of variables that can be parsed by a VuoMathExpressionParser.
Definition at line 114 of file VuoMathExpressionParser.cc.