Пример #1
0
        private void Manual_menu_item_Click(object sender, EventArgs e)
        {
            if (inputDataForm.ShowDialog(this) == DialogResult.OK)
            {
                Data.Point[] points = inputDataForm.GetPoints();

                updateChartSeries("points", points);

                Data.CubicSpline spline       = new Data.CubicSpline(points);
                Data.Point[]     splinePoints = spline.getPoints();
                updateChartSeries("spline", splinePoints);

                Data.FirstDerivative firstDerivative = new Data.FirstDerivative(spline.getPoints());
                updateChartSeries("firstDerivative", firstDerivative.GetPoints()).Enabled = false;
                showFirstDerivative.Checked = false;

                Data.SecondDerivative secondDerivative = new Data.SecondDerivative(spline.getPoints());
                updateChartSeries("secondDerivative", secondDerivative.GetPoints()).Enabled = false;
                showSecondDerivative.Checked = false;
                chart1.ChartAreas[0].AxisX.RoundAxisValues();
            }
        }
Пример #2
0
        private void randomToolStripMenuItem_Click(object sender, EventArgs e)
        {
            chart1.Series.Clear();
            //Random rand = new Random();
            //int n = rand.Next(1, 10);
            //double[] coefficients = new double[n];
            //for (int i = 0; i < n; i++)
            //{
            //    coefficients[i] = 2*rand.NextDouble()-1;
            //}
            //Data.Polinom p = new Data.Polinom(coefficients);
            //string pName = p.ToString();
            //chart1.Series.Add(pName);
            //chart1.Series[pName].ChartType = SeriesChartType.Spline;
            //foreach (Data.Point point in p.getPoints(-2, 2))
            //{
            //    chart1.Series[pName].Points.AddXY(point.getX(), point.getY());
            //}

            Data.Point[] points = new Data.Point[]
            {
                new Data.Point(0, 1),
                new Data.Point(1, 3),
                new Data.Point(2, 1),
                new Data.Point(3, 4),
                new Data.Point(4, 2)
            };

            Data.Point[] points1 = new Data.Point[]
            {
                new Data.Point(1, 1.0002),
                new Data.Point(2, 1.0341),
                new Data.Point(3, 0.6),
                new Data.Point(4, 0.40105),
                new Data.Point(5, 0.1),
                new Data.Point(6, 0.23975)
            };


            Data.Point[] points2 = new Data.Point[]
            {
                new Data.Point(1, 1),
                new Data.Point(2, 3),
                new Data.Point(2.5, 3.5538),
                new Data.Point(3, 3)
            };

            Data.Point[] points3 = new Data.Point[]
            {
                new Data.Point(1, 1),
                new Data.Point(2, 8),
                new Data.Point(3, 27),
                new Data.Point(4, 64),
                new Data.Point(5, 125)
            };

            //Data.CubicSpline csplain = new Data.CubicSpline(p.getPoints(-2, 2, 10));
            Data.CubicSpline csplain = new Data.CubicSpline(points3);

            chart1.Series.Add("spline");

            chart1.Series["spline"].ChartType = SeriesChartType.Spline;
            foreach (Data.Point point in csplain.getPoints(100))
            {
                chart1.Series["spline"].Points.AddXY(point.getX(), point.getY());
            }
        }