예제 #1
0
 public GrapherFunction(MathExpression ex)
 {
     IsAlphaFaded = true;
     ColorA = m_ColorA;
     ColorB = m_ColorB;
     Reset(ex);
 }
예제 #2
0
 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;
 }
예제 #3
0
 public void AddFunction(MathExpression ex )
 {
     Functions.Add(new GrapherFunction(ex));
     UpdateSettingsForm();
 }
예제 #4
0
 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);
 }
예제 #5
0
 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;
     }
 }
예제 #6
0
        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;
        }