public GrapherFunction(MathExpression ex) { IsAlphaFaded = true; ColorA = m_ColorA; ColorB = m_ColorB; Reset(ex); }
public void Reset(MathExpression ex) { expression = ex; Is3D = ex.ContainsVariable("z"); IsDensityPlot = expression.ExpressionStack.Peek() is Density; IsImplicit = ex.IsImplicit; if (IsImplicit) implicitdata = new List<Vector2>(); timer = new Stopwatch(); timer.Start(); Visible = true; InvalidateVBO(); IsLocked = false; }
public void AddFunction(MathExpression ex ) { Functions.Add(new GrapherFunction(ex)); UpdateSettingsForm(); }
public void Expect(MathExpression custom, float expected) { float result = Truncate(custom.Calculate(), 3); Assert.AreEqual(expected, result); Console.WriteLine("Given: " + custom.OriginalExpression); Console.WriteLine("Expected: " + expected); Console.WriteLine("Result: " + result); }
public bool TryCreateExpression(string expression,out MathExpression ex) { try { StaticStack<MathOperation> Expression = Convert(expression); //the new MathExpression gets the original Dictionary<string, float> var = m_Variables; //and we keep a copy so they dont intefere with eachother m_Variables = new Dictionary<string, float>(var); ex = new MathExpression(Expression, var, expression); return true; } catch (Exception) { ex = null; return false; } }
public MathExpression Optimize(MathState state) { ExpressionTree tree = m_ExpressionTree; m_ExpressionTree.Optimize(state); StaticStack<MathOperation> stack = m_ExpressionTree.BuildExpressionStack(new StaticStack<MathOperation>()); Dictionary<string, float> var = new Dictionary<string, float>(m_Variables); for (int i = 0; i < stack.Count; i++) { if (stack[i] is Variable) { Variable v = (Variable)stack[i]; stack[i] = new Variable(v.ToString(), var); } } MathExpression optimized = new MathExpression(stack, var, OriginalExpression); UpdateExpressionTree(); return optimized; }