Vuo  1.2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
VuoMathExpressionParser.cc File Reference

Description

VuoMathExpressionParser implementation.

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.
 
VuoList_VuoInteger VuoMathExpressionError_getExpressionIndices (VuoMathExpressionError error)
 Returns a sorted list of the indices of the math expressions causing the error.
 
void VuoMathExpressionError_free (VuoMathExpressionError error)
 Destructor.
 
static double deg2rad (double degrees)
 Converts degrees to radians.
 
static double rad2deg (double radians)
 Converts radians to degrees.
 
static double muparser_rint (double x)
 As defined by muParserTemplateMagic.h.
 
static double fract (double x)
 As defined by https://www.opengl.org/sdk/docs/man/html/fract.xhtml.
 
static double clamp (double x, double minVal, double maxVal)
 As defined by https://www.opengl.org/sdk/docs/man/html/clamp.xhtml.
 
static double step (double edge, double x)
 As defined by https://www.opengl.org/sdk/docs/man/html/step.xhtml.
 
static double smoothstep (double edge0, double edge1, double x)
 As defined by https://www.opengl.org/sdk/docs/man/html/smoothstep.xhtml.
 
static double mix (double x, double y, double a)
 As defined by https://www.opengl.org/sdk/docs/man/html/mix.xhtml.
 
void VuoMathExpressionParser_defineStandardLibrary (void *p)
 Given a pointer to a mu::Parser instance, adds Vuo's standard operators, constants, and functions.
 
static vector< string > splitSingleExpressionOnAssignmentOperators (string expression)
 Returns the parts of expression separated by (and not including) the assignment operator ("=").
 
static void checkSyntaxOfSingleExpression (string expression, VuoMathExpressionError *error)
 Checks that expression contains a syntactically valid, single math expression with at most one assignment operator.
 
static void checkSyntaxOfMultipleExpressions (VuoList_VuoText expressions, VuoMathExpressionError *error)
 Checks that each single math expression in expressions satisfies checkSyntaxOfSingleExpression().
 
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.
 
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.
 
void VuoMathExpressionParser_free (void *me)
 Destroys me, a VuoMathExpressionParser.
 
VuoMathExpressionParser VuoMathExpressionParser_makeFromSingleExpression (VuoText expression, VuoMathExpressionError *error)
 Parses expression (e.g.
 
VuoMathExpressionParser VuoMathExpressionParser_makeFromMultipleExpressions (VuoList_VuoText expressions, VuoMathExpressionError *error)
 Parses expressions (e.g.
 
VuoList_VuoText VuoMathExpressionParser_getInputVariables (VuoMathExpressionParser m)
 Returns the unique input variable names from the parsed expression(s), in alphabetical order.
 
VuoList_VuoText VuoMathExpressionParser_getOutputVariables (VuoMathExpressionParser m)
 Returns the output variable names from the parsed expression(s), in the order they appeared.
 
VuoDictionary_VuoText_VuoReal VuoMathExpressionParser_calculate (VuoMathExpressionParser m, VuoDictionary_VuoText_VuoReal inputValues)
 Evaluates the parsed expression(s).
 
VuoList_VuoReal VuoMathExpressionParser_calculateList (VuoMathExpressionParser m, VuoList_VuoReal xValues, VuoDictionary_VuoText_VuoReal constants)
 Evaluates the expression for each of xValues.
 
static double sinInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double cosInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double tanInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double asinInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double acosInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double atanInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double atan2InDegrees (double y, double x)
 Trigonometric functions that take degrees instead of radians.
 
static double sinhInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double coshInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double tanhInDegrees (double degrees)
 Trigonometric functions that take degrees instead of radians.
 
static double asinhInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double acoshInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double atanhInDegrees (double x)
 Trigonometric functions that take degrees instead of radians.
 
static double perlin2d (double x, double y)
 Gradient noise wrappers.
 
static double perlin3d (double x, double y, double z)
 Gradient noise wrappers.
 
static double perlin4d (double x, double y, double z, double w)
 Gradient noise wrappers.
 
static double simplex2d (double x, double y)
 Gradient noise wrappers.
 
static double simplex3d (double x, double y, double z)
 Gradient noise wrappers.
 
static double simplex4d (double x, double y, double z, double w)
 Gradient noise wrappers.
 

Variables

static const size_t MAX_VARIABLE_COUNT = 64
 Maximum number of variables that can be parsed by a VuoMathExpressionParser.
 

Function Documentation

static double acoshInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double acosInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double asinhInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double asinInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double atan2InDegrees ( double  y,
double  x 
)
static

Trigonometric functions that take degrees instead of radians.

static double atanhInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static double atanInDegrees ( double  x)
static

Trigonometric functions that take degrees instead of radians.

static void checkSyntaxOfMultipleExpressions ( VuoList_VuoText  expressions,
VuoMathExpressionError error 
)
static

Checks that each single math expression in expressions satisfies checkSyntaxOfSingleExpression().

static void checkSyntaxOfSingleExpression ( string  expression,
VuoMathExpressionError error 
)
static

Checks that expression contains a syntactically valid, single math expression with at most one assignment operator.

static double clamp ( double  x,
double  minVal,
double  maxVal 
)
static
static double coshInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static double cosInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static double deg2rad ( double  degrees)
static

Converts degrees to radians.

static double fract ( double  x)
static
static double mix ( double  x,
double  y,
double  a 
)
static
static double muparser_rint ( double  x)
static

As defined by muParserTemplateMagic.h.

static void parseVariablesFromMultipleExpressions ( VuoList_VuoText  expressions,
vector< string > &  inputVariableNames,
vector< string > &  outputVariableNames,
VuoMathExpressionError error 
)
static

Parses the unique variable names from expressions and puts them in inputVariableNames and outputVariableNames.

Assumes that expressions satisfies checkSyntaxOfMultipleExpressions().

static void parseVariablesFromSingleExpression ( string  expression,
vector< string > &  inputVariableNames,
string &  outputVariableName,
VuoMathExpressionError error 
)
static

Parses the unique variable names from expression and puts them in inputVariableNames and outputVariableName.

Assumes that expression satisfies checkSyntaxOfSingleExpression().

static double perlin2d ( double  x,
double  y 
)
static

Gradient noise wrappers.

static double perlin3d ( double  x,
double  y,
double  z 
)
static

Gradient noise wrappers.

static double perlin4d ( double  x,
double  y,
double  z,
double  w 
)
static

Gradient noise wrappers.

static double rad2deg ( double  radians)
static

Converts radians to degrees.

static double simplex2d ( double  x,
double  y 
)
static

Gradient noise wrappers.

static double simplex3d ( double  x,
double  y,
double  z 
)
static

Gradient noise wrappers.

static double simplex4d ( double  x,
double  y,
double  z,
double  w 
)
static

Gradient noise wrappers.

static double sinhInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static double sinInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static double smoothstep ( double  edge0,
double  edge1,
double  x 
)
static
static vector<string> splitSingleExpressionOnAssignmentOperators ( string  expression)
static

Returns the parts of expression separated by (and not including) the assignment operator ("=").

Assumes that expression satisfies checkSyntaxOfSingleExpression().

static double step ( double  edge,
double  x 
)
static
static double tanhInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

static double tanInDegrees ( double  degrees)
static

Trigonometric functions that take degrees instead of radians.

void VuoMathExpressionError_free ( VuoMathExpressionError  error)

Destructor.

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().

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.

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.

VuoList_VuoReal VuoMathExpressionParser_calculateList ( VuoMathExpressionParser  m,
VuoList_VuoReal  xValues,
VuoDictionary_VuoText_VuoReal  constants 
)

Evaluates the expression for each of xValues.

void VuoMathExpressionParser_defineStandardLibrary ( void *  p)

Given a pointer to a mu::Parser instance, adds Vuo's standard operators, constants, and functions.

void VuoMathExpressionParser_free ( void *  me)

Destroys me, a VuoMathExpressionParser.

VuoList_VuoText VuoMathExpressionParser_getInputVariables ( VuoMathExpressionParser  m)

Returns the unique input variable names from the parsed expression(s), in alphabetical order.

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.

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.

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.

Variable Documentation

const size_t MAX_VARIABLE_COUNT = 64
static

Maximum number of variables that can be parsed by a VuoMathExpressionParser.