Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            section = new List<Section>();

            Function = ((ComboBoxItem)comboBox1.SelectedItem).GetFunction();

            double xmin = Convert.ToDouble(textBox5.Text);
            double xmax = Convert.ToDouble(textBox6.Text);
            Mu = Convert.ToDouble(textBox7.Text);

              GraphPane pane = zedGraphControl1.GraphPane;
              GraphPane pane2 = zedGraphControl2.GraphPane;
              pane2.CurveList.Clear();
              zedGraphControl2.ZoomOutAll(pane2);
              zedGraphControl1.ZoomOutAll(pane);
              pane.CurveList.Clear();
              richTextBox1.Text = "";

                PointPairList list = new PointPairList();
                PointPairList list_aprox = new PointPairList();

                list = FunctionUtil.GetPointPairsInRange(xmin, xmax, Function);

                PointPairList list_1 = new PointPairList();
                PointPairList aprox = new PointPairList();

                    Compute(xmin, xmax);
                    for (int i = 0; i < section.Count; i++)
                    {
                        for (double x = section[i].LeftPoint; x <= section[i].RightPoint; x += 0.001)
                        {

                            double fx = AproximFunc(x, section[i].Coef);

                            aprox.Add(x, fx);

                        }

                        richTextBox1.Text += "Ланка # " + (i + 1) + "\n\nxL= " + section[i].LeftPoint
                            +"\nxR= " + section[i].RightPoint + "\nMu= "
                            + section[i].Mu + "\n\n" + "Коефіцієнти\n\n";
                        for (int ii = 0; ii < section[i].Coef.Length; ii++)
                        {
                            richTextBox1.Text += "a["+ii+"]= "+section[i].Coef[ii]+"\n";

                        }
                        richTextBox1.Text += "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"+"\n\n";

                    }

                LineItem myCurve = pane.AddCurve(Function.Text, list, Color.Blue, SymbolType.None);
                LineItem myCurve2 = pane.AddCurve("aprox", aprox, Color.Red, SymbolType.None);

                pane.XAxis.MajorGrid.IsVisible = true;
                pane.YAxis.MajorGrid.IsVisible = true;

                zedGraphControl1.AxisChange();

                zedGraphControl1.Invalidate();
                list_1.Clear();

                foreach (Section sec in section)
                {
                    double[] coef = exp(Function, sec.LeftPoint, sec.RightPoint);

                    for (double x = sec.LeftPoint; x <= sec.RightPoint; x += 0.001)
                    {

                        double fx = Math.Abs(Function.Val(x) - AproximFunc(x, coef));

                        list_1.Add(x, fx);

                    }
                }

                LineItem newCurves = pane2.AddCurve("Ro", list_1, Color.Blue, SymbolType.None);
                list_1 = new PointPairList();
                list_1.Add(xmin,Mu);
                list_1.Add(xmax,Mu);
                newCurves = pane2.AddCurve("Mu", list_1, Color.Red, SymbolType.None);

                pane2.XAxis.MajorGrid.IsVisible = true;
                pane2.YAxis.MajorGrid.IsVisible = true;
                pane2.YAxis.Scale.Max = 2 * Mu;
                pane2.YAxis.Scale.Min = 0;
                pane2.XAxis.Scale.Max = xmax;
                pane2.XAxis.Scale.Min = xmin;

                zedGraphControl2.AxisChange();

                zedGraphControl2.Invalidate();
        }
Пример #2
0
 private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
 {
     Function=(AppMath.BaseFunc) comboBox1.SelectedValue;
 }