Пример #1
0
        public void Ast_compute_withIdentifier(string toCompute, double x, double y, double result)
        {
            //arrange
            AstWrapper sut = new AstWrapper();
            //act
            var n = sut.Parse(toCompute);

            //assert
            sut.Compute(n, x, y).Should().Be(result);
        }
Пример #2
0
        public void Ast_compute(string toCompute, double result)
        {
            //arrange
            AstWrapper sut = new AstWrapper();
            //act
            var n = sut.Parse(toCompute);

            //assert
            sut.Compute(n, 0, 0).Should().Be(result);
        }
Пример #3
0
        public static double[,] CreatePictureFromGraph(int width, int height, Ast.Node root)
        {
            AstWrapper astWrapper = new AstWrapper();


            double[,] matrix = new double[width, height];

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    double x = (i - width / 2) * 0.1;
                    double y = -(j - height / 2) * 0.1;
                    matrix[i, j] = astWrapper.Compute(root, x, y);//COMPUTE AST Here
                }
            }
            return(matrix);
        }
Пример #4
0
        public static double[,] CreatePictureFromEquation(int width, int height, string equation)
        {
            //throw new NotImplementedException("ready for the ast !");
            AstWrapper astWrapper = new AstWrapper();

            Node computeGraphRoot = astWrapper.Parse(equation);

            double[,] matrix = new double[width, height];

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    double x = (i - width / 2) * 0.1;
                    double y = -(j - height / 2) * 0.1;
                    matrix[i, j] = astWrapper.Compute(computeGraphRoot, x, y); //COMPUTE AST Here
                }
            }
            return(matrix);
        }