private Vector3 getNormalNumeric(Vector3 r) { List <DefinedCommonFunction> derivativesU = new List <DefinedCommonFunction>(); List <DefinedCommonFunction> derivativesV = new List <DefinedCommonFunction>(); NumericalDerivative derivative = new NumericalDerivative(); derivativesU.Add(new DefinedCommonFunction(derivative.CreatePartialDerivativeFunctionHandle(r.X.Invoke, 0, 1), "null")); derivativesV.Add(new DefinedCommonFunction(derivative.CreatePartialDerivativeFunctionHandle(r.X.Invoke, 1, 1), "null")); derivativesU.Add(new DefinedCommonFunction(derivative.CreatePartialDerivativeFunctionHandle(r.Y.Invoke, 0, 1), "null")); derivativesV.Add(new DefinedCommonFunction(derivative.CreatePartialDerivativeFunctionHandle(r.Y.Invoke, 1, 1), "null")); derivativesU.Add(new DefinedCommonFunction(derivative.CreatePartialDerivativeFunctionHandle(r.Z.Invoke, 0, 1), "null")); derivativesV.Add(new DefinedCommonFunction(derivative.CreatePartialDerivativeFunctionHandle(r.Z.Invoke, 1, 1), "null")); Vector3 v1 = new Vector3(derivativesU); Vector3 v2 = new Vector3(derivativesV); var normalNotNormalized = (v1 ^ v2); var len = new OneVarFunction(Math.Sqrt, normalNotNormalized * normalNotNormalized, null); return(normalNotNormalized / len); }
private CommonFunction Power() { CommonFunction result = null; if (look == '(') { Match('('); result = Expression(); Match(')'); return result; } if (IsAlpha(look)) { var name = GetName(); if (look == '(') { Match('('); result = new OneVarFunction(builtInFunctions[name],(CommonFunction)Expression()); Match(')'); } else { if (variables.ContainsKey(name)) result = new Variable(variables[name]); else { variables[name] = variables.Last().Value + 1; result = new Variable(variables[name]); } ((Variable)result).name = name; } } else { double constant=GetNum(); result = new OneVarFunction(x => constant,null); } return result; }