72 m_name = (
char*)p_name;
124 m_value = pData->
Double();
125 }
else if (m_pInlet) {
128 m_value = pData->
Double();
180 for(
MOuint p=0; p<Params.Count(); p++ ) {
229 va_start(arguments, s);
230 for (
int i = 1; i < num; i++)
243 for (
int i = 0; i < num; i++) {
269 va_start(arguments, x);
270 for (
int i = 1; i < num; i++)
272 m_Variables[i]->SetValue(va_arg(arguments,
double));
285 va_start(arguments, n);
286 for (
int i = 0; i < num; i++)
288 m_Variables[i]->SetValue(va_arg(arguments,
double));
336 va_start(arguments, x);
337 for (
int i = 1; i < num; i++)
339 m_Variables[i]->SetValue(va_arg(arguments,
double));
351 if (p_Expression ==
moText(
"CubicInterpolant(x)"))
365 void moCubicInterpolant::OnParamUpdate()
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;
384 double moCubicInterpolant::OnFuncEval()
388 double sqr_delta = delta * delta;
390 return C1 + C2 * delta + C3 * sqr_delta + C4 * sqr_delta * delta;
393 double moCubicInterpolant::OnDerivEval(
int n)
395 if (n == 0)
return OnFuncEval();
404 if (n == 1)
return C2 + 2 * C3 * delta + 3 * C4 * delta * delta;
405 else if (n == 2)
return 2 * C3 + 6 * C4 * delta;
411 void moCubicInterpolant::BuildParamList()
421 void moCubicInterpolant::BuildVarList()
432 if (p_Expression ==
moText(
"TautInterpolant(x)"))
447 double moTautInterpolant::PhiFunc1(
double u)
449 double v = max(one_minus_knot_inv *(u - knot), 0.0);
450 return alpha * u * u * u + (1 - alpha) * v * v * v;
453 double moTautInterpolant::DPhiFunc1(
double u)
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);
462 double moTautInterpolant::PhiFunc2(
double u)
464 double v = max(one_minus_knot_inv2 *(u - knot2), 0.0);
465 return alpha2 * u * u * u + (1 - alpha2) * v * v * v;
468 double moTautInterpolant::DPhiFunc2(
double u)
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);
477 void moTautInterpolant::OnParamUpdate()
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);
532 double moTautInterpolant::OnFuncEval()
535 return A + B * u + C * PhiFunc1(u) + D * PhiFunc2(1 - u);
538 double moTautInterpolant::OnDerivEval(
int n)
540 if (n == 0)
return OnFuncEval();
544 return (B + C * DPhiFunc1(u) - D * DPhiFunc2(1 - u)) * delta_inv;
551 void moTautInterpolant::BuildParamList()
562 void moTautInterpolant::BuildVarList()
581 mu::Parser* pParser =
new mu::Parser();
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";
624 for(
MOuint p=0; p<Params.Count(); p++ ) {
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] ==
'_')
763 MODebug2->
Push(
"Error in number of parser parameters.");
774 mu::Parser* pParser = (mu::Parser*)
m_pParser;
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";
moMathVariableArray m_Variables
MOuint GetVariableCount()
static double FastInvTan1(doublefValue)
MOuint GetParameterCount()
const moText & GetLabelName() const
static const double HALF_PI
moDefineDynamicArray(moIntArray) moDefineDynamicArray(moBoolArray) moDefineDynamicArray(moFloatArray) moDefineDynamicArray(moMathVariableArray) moDefineDynamicArray(moMathFunctionArray) moMathFunction *BuiltInMathFunctionFactory(const moText &p_expr)
virtual MOboolean Finish()
void Error(moText p_text)
Anuncia y registra un error.
static double FastCos1(doublefAngle)
double GetParameterValue(int i)
static double FastTan1(doublefAngle)
static double FastTan0(doublefAngle)
virtual void SetExpression(const moText &p_Expression)
moParams & GetParams()
Devuelve el puntero al arreglo de parámetros.
Conector Inlet, conector que recibe datos.
static double FastInvSin1(doublefValue)
static double FastNegExp2(doublefValue)
virtual double DEval(int n,...)
static const double RAD_TO_DEG
static const double INV_TWO_PI
static double FastInvCos1(doublefValue)
virtual void OnParamUpdate()=0
static const double TWO_PI
moText & GetParameterName(int i)
double * GetValuePointer()
virtual MOboolean Init()
Inicializa el objeto.
static double FastNegExp0(doublefValue)
static const double ZERO_TOLERANCE
static double SymmetricRandom(unsigned int uiSeed=0)
moMathFunction * BuiltInMathFunctionFactory(const moText &p_expr)
const moText & GetName() const
static const double EPSILON
clase de para manejar textos
void SetParam(moParam *p_Param)
double * CreateNewVariable(const char *p_pNewName)
double GetVariableValue(int i)
static double DegToRad(doubleiDeg)
void Log(moText p_text)
Escribe un mensaje en el archivo de registro (log)
static const double MAX_REAL
static double FastNegExp3(doublefValue)
virtual void BuildVarList()=0
virtual void SetParameters(double s,...)
Clase Base para Objetos Moldeo ( moEffect, moIODevice, moResource, moConsole )
static double FastCos0(doublefAngle)
static const double INV_LN_10
static double FastSin0(doublefAngle)
moMathVariableArray m_Parameters
static const double LN_10
static double FastInvTan0(doublefValue)
void SetInlet(moInlet *p_Inlet)
virtual ~moMathFunction()
static double RadToDeg(doubleiRad)
MOboolean CheckVariables()
double * AddParserVariableFunction(const char *p_pVarName, void *p_pUserData)
static moDebug * MODebug2
Clase de impresión de errores para depuración
virtual const moText & GetConnectorLabelName() const
virtual double OnFuncEval()=0
static double FastInvSqrt(doublefValue)
void Push(moText p_text)
Apila el mensaje dentro de la pila de mensajes.
moParamDefinition & GetParamDefinition()
static double FastInvSin0(doublefValue)
static double FastInvCos0(doublefValue)
static const double INV_LN_2
LIBMOLDEO_API moText0 IntToStr(int a)
static double FastNegExp1(doublefValue)
static double IntervalRandom(doublefMin, doublefMax, unsigned int uiSeed=0)
moText & GetVariableName(int i)
static const double DEG_TO_RAD
virtual double OnDerivEval(int n)=0
double operator()(double x,...)
virtual void BuildParamList()=0
static double UnitRandom(unsigned int uiSeed=0)
static double FastSin1(doublefAngle)
static const double INV_PI