CMathExpression.cpp File Reference
This file contains the implementations of the different functions that will be used in mathematical calculation. More...
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include "popassert.h"
#include "CVector3f.h"
#include "compute.h"
#include "CMathExpression.h"
Go to the source code of this file.
|
Functions |
| bool | In (const char *Formula, int min, int max) |
| | This function checks is an operator (+, -, *, /, ^) is in parenthesis.
|
Detailed Description
This file contains the implementations of the different functions that will be used in mathematical calculation.
It contains the functions that validate an expression, build the tree in a CMathExpression and derives an expression.
The algorithm used it the following. The function recursively calls itself the following way to build the three.
- Beginning from the right, it looks for an + or - operator. If it finds one, it checks that it is not inside parenthesis and returns the sum or difference of the left part of the expression parsed by the function and the right part of the expression parsed by the function. Si the unary operator - is found, 0 minus the rest of the expression is returned.
- It does the same thing for the * and / operators, that are also ignored if found in parenthesis.
- Next, The function looks for some functions like sqrt, sin, cos, tan, exp, ln or ^. If this function is not in parenthesis, the function proceeds with the rest of the expression.
- After that the function looks for an opening parenthesis. If it finds one, it starts from the end looking for a closing parenthesis, then it proceeds inside the parenthesis.
- Then it looks for x, y or z, and finally for a number.
Definition in file CMathExpression.cpp.
Generated on Fri Dec 5 03:20:33 2008 for Mathematical Ray-tracer by
1.5.4