An abstract representation of a mathematical function. More...
#include <Expr.h>
Public Member Functions | |
float | eval (float x, float y, float step) |
Recursive method, calls eval on its nested expressions. More... | |
Expr (Expr *otherE1, Expr *otherE2, std::string otherExprType, bool dubInput) | |
Constructor takes in other expressions for the nested expression case. More... | |
Expr (Expr *otherE1, std::string otherExprType, bool dubInput) | |
Expr (std::string otherExprType) | |
string * | toString (string *theString) |
Public Attributes | |
bool | doubleInput |
shared_ptr< Expr > | e1 |
An expression might have a nested expression, for example this expression could be cos ( expr1 ) where expr1 would be another expression with other nested expression etc. More... | |
shared_ptr< Expr > | e2 |
Some expressions take two inputs like Average or Circle. More... | |
std::string | exprType |
Stores the type of expression this Expr is. More... | |
Static Public Attributes | |
static const string | ASin = "ASin" |
static const string | Average = "Average" |
static const string | Circle = "Circle" |
static const string | Cos = "Cos" |
static const string | Sin = "Sin" |
static const string | Times = "Time" |
static const string | VarX = "VarX" |
static const string | VarY = "VarY" |
An abstract representation of a mathematical function.
This class represents a math function that can then be evaluated over some interval.
Note that the static const string variables are used to set an Expression to be a certain type.
Constructor takes in other expressions for the nested expression case.
The third constructor is for "terminal" expressions, ie when the Art::build() method's depth input is 0 and terminates expression expansion. doubleInput to distinguish between single and double input math functions. The otherExprType parameter is most important as it is what sets the type of math function this newly created Expr is.
Expr::Expr | ( | Expr * | otherE1, |
std::string | otherExprType, | ||
bool | dubInput | ||
) |
Expr::Expr | ( | std::string | otherExprType | ) |
float Expr::eval | ( | float | x, |
float | y, | ||
float | step | ||
) |
Recursive method, calls eval on its nested expressions.
step is an important variable, it sets the constant that is multiplied by the input in the case of a trigonometric function, by increasing the step value over time, we get the cool changes in our 2d art animation. See the 2d art animation for an example of what eval over slowly incrementing step parameters looks like.
3.0f;
string * Expr::toString | ( | string * | theString | ) |
|
static |
|
static |
|
static |
|
static |
bool Expr::doubleInput |
shared_ptr<Expr> Expr::e1 |
An expression might have a nested expression, for example this expression could be cos ( expr1 ) where expr1 would be another expression with other nested expression etc.
shared_ptr<Expr> Expr::e2 |
Some expressions take two inputs like Average or Circle.
std::string Expr::exprType |
|
static |
|
static |
|
static |
|
static |