CMathExpression Class Reference
[Mathematical computations]

This class represents a mathematical expression. More...

#include <CMathExpression.h>

List of all members.

Public Member Functions

 CMathExpression (const char *Equation=0)
 This is the CMathExpression constructor.
 CMathExpression (const CMathExpression &copy)
 This is the CMathExpression copy constructor.
const CMathExpressionoperator= (const CMathExpression &copy)
 This is the assignment operator.
float GetValue (const CVector3f &Point) const
CMathExpressionGetDerivative (CValue::TYPE_VARIABLE Type) const
void Print (std::ostream &o) const
std::string GetString () const
 ~CMathExpression ()

Static Public Member Functions

static bool Validate (const std::string &Formula, int *value=NULL, int min=-1, int max=-1)
 This recursive function validates an equation.

Private Member Functions

void Compile (std::vector< char > &v) const
 This function fills the vector with code to compute the given formula.
void Compile ()
 This function updates the pointer to the function that computes the given formula.

Static Private Member Functions

static CValueBuildFormula (const char *Formula, int min, int max)
 This recursive function is used to build the tree associated with a mathematical expression.

Private Attributes

CValuem_pFormula
float(* m_pFunction )(const CVector3f &)


Detailed Description

This class represents a mathematical expression.

It is actually the only class that will be directly called and used to calculate something.

Definition at line 25 of file CMathExpression.h.


Constructor & Destructor Documentation

CMathExpression::CMathExpression ( const CMathExpression copy  )  [inline]

This is the CMathExpression copy constructor.

Definition at line 36 of file CMathExpression.h.

References CValue::GetCopy(), and m_pFormula.

CMathExpression::~CMathExpression (  )  [inline]

Destructor of CMathExpression, which release the memory in the CValue object it contains.

Definition at line 109 of file CMathExpression.h.

References m_pFormula, and m_pFunction.


Member Function Documentation

const CMathExpression& CMathExpression::operator= ( const CMathExpression copy  )  [inline]

This is the assignment operator.

Definition at line 42 of file CMathExpression.h.

References CValue::GetCopy(), and m_pFormula.

float CMathExpression::GetValue ( const CVector3f Point  )  const [inline]

This function returns the value of the expression it contains evaluated at a specific point.

Definition at line 58 of file CMathExpression.h.

References CValue::Compute(), m_pFormula, and m_pFunction.

Referenced by CRenderObj::GetPixelColor().

CMathExpression* CMathExpression::GetDerivative ( CValue::TYPE_VARIABLE  Type  )  const [inline]

This function returns a pointer to a newly allocated expression containing the derivative of the expression.

Definition at line 75 of file CMathExpression.h.

References Compile(), CValue::Derive(), and m_pFormula.

Referenced by CRenderObj::Update().

void CMathExpression::Print ( std::ostream &  o  )  const [inline]

This function fills the stream with the expression of the CValue it contains.

Definition at line 88 of file CMathExpression.h.

References m_pFormula, and CValue::Print().

std::string CMathExpression::GetString (  )  const [inline]

This function returns a string representing the formula it holds

Definition at line 97 of file CMathExpression.h.

References m_pFormula, and CValue::Print().

void CMathExpression::Compile (  )  [inline, private]

This function updates the pointer to the function that computes the given formula.

Definition at line 145 of file CMathExpression.h.

References m_pFunction.

Referenced by CMathExpression().


Member Data Documentation

CValue* CMathExpression::m_pFormula [private]

Pointer to the first node of the expression

Definition at line 124 of file CMathExpression.h.

Referenced by CMathExpression(), Compile(), GetDerivative(), GetString(), GetValue(), operator=(), Print(), and ~CMathExpression().

float(* CMathExpression::m_pFunction)(const CVector3f &) [private]

Pointer to the executable function

Referenced by CMathExpression(), Compile(), GetValue(), and ~CMathExpression().


The documentation for this class was generated from the following files:
Generated on Fri Dec 5 03:20:33 2008 for Mathematical Ray-tracer by  doxygen 1.5.4