148 m_Expression =
moText(
"");
162 SetExpression(p_Expression);
173 moParams& Params( m_pConfig->GetParams() );
174 for(
MOuint i=0; i < m_Variables.Count(); i++ ) {
180 for(
MOuint p=0; p<Params.Count(); p++ ) {
194 for(
MOuint m=0; m<m_pMOB->GetInlets()->Count(); m++ ) {
196 moInlet* pInlet = m_pMOB->GetInlets()->Get(m);
221 int num = m_Parameters.Count();
227 m_Parameters[0]->SetValue(s);
229 va_start(arguments, s);
230 for (
int i = 1; i < num; i++)
231 if (m_Parameters[i] != NULL)
232 m_Parameters[i]->SetValue(va_arg(arguments,
double));
240 int num = m_Variables.Count();
243 for (
int i = 0; i < num; i++) {
244 if (m_Variables[i] != NULL) {
246 m_Variables[i]->GetValue();
262 int num = m_Variables.Count();
266 m_Variables[0]->SetValue(x);
269 va_start(arguments, x);
270 for (
int i = 1; i < num; i++)
271 if (m_Variables[i] != NULL)
272 m_Variables[i]->SetValue(va_arg(arguments,
double));
280 int num = m_Variables.Count();
285 va_start(arguments, n);
286 for (
int i = 0; i < num; i++)
287 if (m_Variables[i] != NULL)
288 m_Variables[i]->SetValue(va_arg(arguments,
double));
291 return OnDerivEval(n);
296 return m_Parameters.Count();
301 if (m_Parameters[i] != NULL)
return m_Parameters[i]->GetName();
302 else return m_EmptyName;
307 if (m_Parameters[i] != NULL)
return m_Parameters[i]->GetValue();
313 return m_Variables.Count();
318 if (m_Variables[i] != NULL)
return m_Variables[i]->GetName();
319 else return m_EmptyName;
324 if (m_Variables[i] != NULL)
return m_Variables[i]->GetValue();
330 int num = m_Variables.Count();
334 m_Variables[0]->SetValue(x);
336 va_start(arguments, x);
337 for (
int i = 1; i < num; i++)
338 if (m_Variables[i] != NULL)
339 m_Variables[i]->SetValue(va_arg(arguments,
double));
351 if (p_Expression ==
moText(
"CubicInterpolant(x)"))
358 SetParameters(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
367 double x0 = m_Parameters[0]->GetValue();
368 double y0 = m_Parameters[1]->GetValue();
369 double d0 = m_Parameters[2]->GetValue();
371 double x1 = m_Parameters[3]->GetValue();
372 double y1 = m_Parameters[4]->GetValue();
373 double d1 = m_Parameters[5]->GetValue();
375 double delta = x1 - x0;
376 double deriv = (y0 - y1) /(x0 - x1);
378 C4 = (d0 + d1 - 2 * deriv) /(delta * delta);
379 C3 = (deriv - d0) / delta - C4 * delta;
387 double delta = m_Variables[0]->GetValue() - m_Parameters[0]->GetValue();
388 double sqr_delta = delta * delta;
390 return C1 + C2 * delta + C3 * sqr_delta + C4 * sqr_delta * delta;
395 if (n == 0)
return OnFuncEval();
401 if (n < 3) delta = m_Variables[0]->GetValue() - m_Parameters[0]->GetValue();
404 if (n == 1)
return C2 + 2 * C3 * delta + 3 * C4 * delta * delta;
405 else if (n == 2)
return 2 * C3 + 6 * C4 * delta;
432 if (p_Expression ==
moText(
"TautInterpolant(x)"))
440 SetParameters(0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.5);
449 double v = max(one_minus_knot_inv *(u - knot), 0.0);
450 return alpha * u * u * u + (1 - alpha) * v * v * v;
456 s = one_minus_knot_inv *(u - knot);
458 if (0 <= s) dv = one_minus_knot_inv;
else dv = 0;
459 return 3 * (alpha * u * u + (1 - alpha) * v * v * dv);
464 double v = max(one_minus_knot_inv2 *(u - knot2), 0.0);
465 return alpha2 * u * u * u + (1 - alpha2) * v * v * v;
471 s = one_minus_knot_inv2 *(u - knot2);
473 if (0 <= s) dv = one_minus_knot_inv2;
else dv = 0;
474 return 3 * (alpha2 * u * u + (1 - alpha2) * v * v * dv);
479 double x0 = m_Parameters[0]->GetValue();
480 double y0 = m_Parameters[1]->GetValue();
481 double Dy0 = m_Parameters[2]->GetValue();
483 double x1 = m_Parameters[3]->GetValue();
484 double y1 = m_Parameters[4]->GetValue();
485 double Dy1 = m_Parameters[5]->GetValue();
487 double gamma = m_Parameters[6]->GetValue();
493 delta = x1 - x0; delta_inv = 1.0 / delta;
497 s0 = Dy0 * delta - diff;
498 s1 = Dy1 * delta - diff;
501 zeta = s1 / (s1 - s0);
502 knot = 1.0 - gamma * min(1.0 - zeta, 1.0 / 3.0);
503 knot = max(1e-10, knot); knot = min(1.0 - 1e-10, knot);
504 one_minus_knot_inv = 1.0 /(1.0 - knot);
505 alpha = (1.0 - gamma / 3.0) / knot;
510 knot2 = 1.0 - gamma * min(1.0 - zeta2, 1.0 / 3.0);
511 knot2 = max(1e-10, knot2); knot2 = min(1.0 - 1e-10, knot2);
512 one_minus_knot_inv2 = 1.0 /(1.0 - knot2);
513 alpha2 = (1.0 - gamma / 3.0) / knot2;
526 else D = (s1 + a * s0) / (a * b + 1);
534 double u = delta_inv *(m_Variables[0]->GetValue() - m_Parameters[0]->GetValue());
535 return A +
B * u + C * PhiFunc1(u) + D * PhiFunc2(1 - u);
540 if (n == 0)
return OnFuncEval();
543 double u = delta_inv *(m_Variables[0]->GetValue() - m_Parameters[0]->GetValue());
544 return (
B + C * DPhiFunc1(u) - D * DPhiFunc2(1 - u)) * delta_inv;
581 mu::Parser* pParser =
new mu::Parser();
584 if (m_pMOB) m_pConfig = m_pMOB->
GetConfig();
594 m_Expression = p_Expression;
595 char* expr = (
char*)(m_Expression);
598 pParser->SetExpr(expr);
601 catch ( mu::ParserError Exc) {
602 moText msgexpr = (
char*)Exc.GetExpr().c_str();
603 moText msgerror = (
char*)Exc.GetMsg().c_str();
604 moText mobname =
"undefined MOB";
618 moParams& Params( m_pConfig->GetParams() );
619 for(
MOuint i=0; i < m_Variables.Count(); i++ ) {
624 for(
MOuint p=0; p<Params.Count(); p++ ) {
639 for(
MOuint m=0; m<m_pMOB->GetInlets()->Count(); m++ ) {
641 moInlet* pInlet = m_pMOB->GetInlets()->Get(m);
655 return CheckVariables();
661 mu::Parser* pParser = (mu::Parser*) m_pParser;
670 mu::Parser* pParser = (mu::Parser*) m_pParser;
708 mu::Parser* pParser = (mu::Parser*) m_pParser;
733 mu::Parser* pParser = (mu::Parser*) m_pParser;
737 mu::varmap_type variables = pParser->GetVar();
739 iNumVar = (int)variables.size();
741 mu::varmap_type::const_iterator item = variables.begin();
743 for (; item!=variables.end(); ++item)
745 if (item->first[0] ==
'_')
755 if (nvar != (
MOint)m_Variables.Count())
761 if (npar != (
MOint)m_Parameters.Count())
763 MODebug2->
Push(
"Error in number of parser parameters.");
774 mu::Parser* pParser = (mu::Parser*) m_pParser;
778 m_LastEval = pParser->Eval();
780 catch ( mu::ParserError Exc) {
781 moText msgexpr = (
char*)Exc.GetExpr().c_str();
782 moText msgerror = (
char*)Exc.GetMsg().c_str();
783 moText mobname =
"undefined MOB";
784 if (m_pMOB) mobname = m_pMOB->GetLabelName();
MOuint GetVariableCount()
static double FastInvTan1(double fValue)
MOuint GetParameterCount()
The Blue component of a color.
moDefineDynamicArray(moIntArray) moDefineDynamicArray(moBoolArray) moDefineDynamicArray(moFloatArray) moDefineDynamicArray(moMathVariableArray) moDefineDynamicArray(moMathFunctionArray) moMathFunction *BuiltInMathFunctionFactory(const moText &p_expr)
virtual MOboolean Finish()
const moText & GetName() const
void Error(moText p_text)
Anuncia y registra un error.
static double FastCos1(double fAngle)
double GetParameterValue(int i)
static double FastTan1(double fAngle)
static double FastTan0(double fAngle)
Conector Inlet, conector que recibe datos.
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
static double FastInvSin1(double fValue)
static double FastNegExp2(double fValue)
virtual double DEval(int n,...)
static double FastInvCos1(double fValue)
const MOlong ZERO_TOLERANCE
moText & GetParameterName(int i)
double * GetValuePointer()
virtual MOboolean Init()
Inicializa el objeto.
double PhiFunc2(double u)
virtual const moText & GetConnectorLabelName() const
static double FastNegExp0(double fValue)
const moText & GetLabelName() const
static double SymmetricRandom(unsigned int uiSeed=0)
moMathFunction * BuiltInMathFunctionFactory(const moText &p_expr)
clase de para manejar textos
void SetParam(moParam *p_Param)
double * CreateNewVariable(const char *p_pNewName)
double GetVariableValue(int i)
static double DegToRad(double iDeg)
void Log(moText p_text)
Escribe un mensaje en el archivo de registro (log)
static double FastNegExp3(double fValue)
double OnDerivEval(int n)
virtual void SetParameters(double s,...)
Clase Base para Objetos Moldeo ( moEffect, moIODevice, moResource, moConsole )
static double FastCos0(double fAngle)
The Alpha (or transparency) of a color.
static double FastSin0(double fAngle)
static double FastInvTan0(double fValue)
void SetInlet(moInlet *p_Inlet)
virtual ~moMathFunction()
double PhiFunc1(double u)
static double RadToDeg(double iRad)
MOboolean CheckVariables()
double * AddParserVariableFunction(const char *p_pVarName, void *p_pUserData)
static moDebug * MODebug2
Clase de impresión de errores para depuración.
static double FastInvSqrt(double fValue)
void Push(moText p_text)
Apila el mensaje dentro de la pila de mensajes.
double OnDerivEval(int n)
moParamDefinition & GetParamDefinition()
static double FastInvSin0(double fValue)
double DPhiFunc1(double u)
static double FastInvCos0(double fValue)
LIBMOLDEO_API moText0 IntToStr(int a)
static double FastNegExp1(double fValue)
double DPhiFunc2(double u)
static double IntervalRandom(double fMin, double fMax, unsigned int uiSeed=0)
moText & GetVariableName(int i)
double operator()(double x,...)
static double UnitRandom(unsigned int uiSeed=0)
static double FastSin1(double fAngle)