MyScript Interactive Ink SDK 4.3.0
Public Member Functions | List of all members
myscript::iink::MathExternalExpression Class Referenceabstract

#include <MathExternalExpression.h>

Public Member Functions

virtual ~MathExternalExpression ()=default
 
virtual String getString ()=0
 
virtual MathDiagnostic getDiagnostic (const String &task, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
 
virtual std::vector< MathEvaluationVariables > getEvaluables ()=0
 
virtual std::vector< std::vector< graphics::PointD > > evaluate (const MathEvaluationVariables &variables, double from, double to, int pointCount, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
 
virtual MathVariableDefinition asVariableDefinition ()=0
 
virtual std::vector< MathVariableInfo > getVariables ()=0
 
virtual double getVariableValue (const String &name)=0
 
virtual void setVariableValue (const String &name, double value)=0
 
virtual bool removeVariableValue (const String &name)=0
 

Detailed Description

The MathExternalExpression allows to manage an external math expression.

Since
4.2

Constructor & Destructor Documentation

◆ ~MathExternalExpression()

virtual myscript::iink::MathExternalExpression::~MathExternalExpression ( )
virtualdefault

Member Function Documentation

◆ getString()

virtual String myscript::iink::MathExternalExpression::getString ( )
pure virtual

Returns the expression original string.

Returns
the original string.

◆ getDiagnostic()

virtual MathDiagnostic myscript::iink::MathExternalExpression::getDiagnostic ( const String &  task,
std::shared_ptr< ParameterSet >  overrideConfiguration = nullptr 
)
pure virtual

Returns the diagnostic info for the given task.

Parameters
taskthe task to diagnose. Only "evaluation" is currently supported.
overrideConfigurationthe extra configuration used.
Returns
a diagnostic code.
Exceptions
std::invalid_argumentwhen task is invalid.
std::invalid_argumentwhen overrideConfiguration is invalid.

◆ getEvaluables()

virtual std::vector< MathEvaluationVariables > myscript::iink::MathExternalExpression::getEvaluables ( )
pure virtual

Returns the list of variable names that can be evaluated. An expression with no syntax error can be evaluated when it contains:

  • a variable definition
  • a single (multi-occurrence) undefined variable and no equal sign
  • an equal sign and two undefined variables, with at least one being a single-occurrence Returns an empty list if expression cannot be evaluated.

Example: see MathSolverController::getEvaluables.

Note: in case both variables can be evaluated interchangeably, the first returned MathEvaluationVariables will use the (leftmost) isolated variable as output if any. Example: "y = cos(x) + 1" will always return: {{ in:"x", out:"y" }, { in:"y", out:"x" }} in that order.

Returns
a list of MathEvaluationVariables that can be evaluated.

◆ evaluate()

virtual std::vector< std::vector< graphics::PointD > > myscript::iink::MathExternalExpression::evaluate ( const MathEvaluationVariables &  variables,
double  from,
double  to,
int  pointCount,
std::shared_ptr< ParameterSet >  overrideConfiguration = nullptr 
)
pure virtual

Returns the list of points resulting from evaluating the given variables.

Example: for "y = 2x", evaluate({ in:"x", out:"y" }, -1, 1, 3) returns { {-1, -2}, {0, 0}, {1, 2} }

Parameters
variablesthe variables to evaluate.
fromthe start of the range to evaluate.
tothe end of the range to evaluate.
pointCountthe number of values to evaluate between [from, to].
overrideConfigurationthe extra configuration used.
Returns
a list of evaluated points, representing continuous parts of a curve. With point.x being the input value and point.y the evaluated variable output.
Exceptions
std::invalid_argumentwhen variables are not evaluables.
std::invalid_argumentwhen from or to is not a number.
std::invalid_argumentwhen from is greater than to.
std::invalid_argumentwhen pointCount is not in [1, 10000].
std::invalid_argumentwhen overrideConfiguration is invalid.

◆ asVariableDefinition()

virtual MathVariableDefinition myscript::iink::MathExternalExpression::asVariableDefinition ( )
pure virtual

Checks if expression represents a variable definition and returns the associated information. An expression represents a variable definition if it is an equation with a single variable on the left of the equal sign and at least one constant expression on the right (first value is used). Example: "a = 1/2" or "b = 1/3 = 0.33"

Returns
the name and value of the defined variable if any, otherwise an invalid definition.

◆ getVariables()

virtual std::vector< MathVariableInfo > myscript::iink::MathExternalExpression::getVariables ( )
pure virtual

Retrieves information about all variables associated with the expression.

Returns
a vector containing the information of all variables.

◆ getVariableValue()

virtual double myscript::iink::MathExternalExpression::getVariableValue ( const String &  name)
pure virtual

Returns the value associated with the given variable name.

Parameters
namethe variable name.
Returns
a variable value.
Exceptions
std::invalid_argumentif name is not an existing variable name.

◆ setVariableValue()

virtual void myscript::iink::MathExternalExpression::setVariableValue ( const String &  name,
double  value 
)
pure virtual

Sets the value associated with the given variable name.

Parameters
namethe variable name.
valuethe variable value.
Exceptions
std::invalid_argumentwhen name is an invalid variable name.
std::invalid_argumentwhen value is an invalid variable value.

◆ removeVariableValue()

virtual bool myscript::iink::MathExternalExpression::removeVariableValue ( const String &  name)
pure virtual

Removes the definition of the given variable name.

Parameters
namethe variable name.
Returns
true if the variable existed, otherwise false.

The documentation for this class was generated from the following file: