コード例 #1
0
ファイル: GraphDrawing.cs プロジェクト: buzykina/calculus
        public void DrawDer(BinaryTree tree)
        {
            this.treeDerA = 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.CalculateDer(x1);
                    float y2 = (float)tree.CalculateDer(x2);
                    g.DrawLine(Pens.Orange, x1 * this.coef, -y1 * this.coef, x2 * this.coef, -y2 * this.coef);
                }
                catch (OverflowException)
                {
                }
            }
        }
コード例 #2
0
        private void DrawDerivativeAna()
        {
            var myModel = new PlotModel {
                Title = tree.ReadDerivative()
            };
            FunctionSeries series = new FunctionSeries();

            for (double i = -10; i < 10; i++)
            {
                double y = tree.CalculateDer(i);
                series.Points.Add(new DataPoint(i, y));
            }
            myModel.Series.Add(series);
            this.plot1.Model = myModel;
        }