Beispiel #1
0
        public void DrawFunctionPolMat(BinaryTree tree)
        {
            this.treePolMat = tree;
            Graphics g   = p1.CreateGraphics();
            float    xin = p1.Width / 2;
            float    yin = p1.Height / 2;

            g.TranslateTransform(xin, yin);
            for (float i = -xin; i <= xin; i++)
            {
                try
                {
                    float x1 = i / this.coef;
                    float x2 = (i + 1) / this.coef;
                    float y1 = (float)tree.Calculate(x1);
                    float y2 = (float)tree.Calculate(x2);
                    g.DrawLine(Pens.Chartreuse, x1 * this.coef, -y1 * this.coef, x2 * this.coef, -y2 * this.coef);
                }
                catch (OverflowException)
                {
                }
            }
        }
Beispiel #2
0
        private void DrawPrimitive()
        {
            var myModel = new PlotModel {
                Title = tree.Read()
            };
            FunctionSeries series = new FunctionSeries();

            for (double i = -10; i < 10; i++)
            {
                double y = tree.Calculate(i);
                series.Points.Add(new DataPoint(i, y));
            }
            myModel.Series.Add(series);
            this.plot1.Model = myModel;
        }
Beispiel #3
0
        public double Intergral(BinaryTree tree, double high, double low)
        {
            double integralsum = 0;
            double number      = 0;

            this.treeI = tree;
            this.High  = high;
            this.Low   = low;
            float    xin = p1.Width / 2;
            float    yin = p1.Height / 2;
            Graphics g   = p1.CreateGraphics();

            g.TranslateTransform(xin, yin);
            for (float i = (float)low * this.coef; i <= (float)high * this.coef; i++)
            {
                try
                {
                    float x1 = i / this.coef;
                    float y1 = (float)tree.Calculate(x1);
                    if (y1 * this.coef >= 0)
                    {
                        g.FillRectangle(Brushes.Green, x1 * this.coef, -y1 * this.coef, 1, y1 * this.coef);
                        integralsum += 1 * y1;
                        number++;
                    }
                    else
                    {
                        g.FillRectangle(Brushes.Green, x1 * this.coef, 0, 1, -y1 * this.coef);
                        integralsum -= 1 * (-y1);
                        number++;
                    }
                }
                catch (OverflowException)
                {
                }
            }
            return(integralsum * ((high - low) / number));
        }