コード例 #1
0
        public void funcSin(double[] x, double[] y, Plotter2D ReadSinPlotter, LineGraph readSinGraph)
        {
            EnumerableDataSource <double> xDataSource = x.AsXDataSource();
            EnumerableDataSource <double> yDataSource = y.AsYDataSource();

            CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);

            readSinGraph = ReadSinPlotter.AddLineGraph(compositeDataSource, Colors.AliceBlue, 3, "Sin");
            ReadSinPlotter.FitToView();
        }
コード例 #2
0
        public void readFuncAmp(double[][] amp, Plotter2D specPlotter, LineGraph[] readAmpGraph)
        {
            EnumerableDataSource <double> xDataSource;
            EnumerableDataSource <double> yDataSource;

            int a = 0;

            ky = 0.1f;
            x1 = 0;
            hx = 0.01f;

            for (int k = 0; k < amp.Length; k++)
            {
                for (int i = 0; i < amp[0].Length / 2; i++)
                {
                    double[] x = new double[2];
                    double[] y = new double[2];

                    y1 = (float)(amp[k][i]);

                    if (y1 > 0.1)
                    {
                        x[0] = i;

                        x[1] = x[0];
                        y[0] = 0;
                        y[1] = y1;

                        xDataSource = x.AsXDataSource();
                        yDataSource = y.AsYDataSource();

                        CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);

                        readAmpGraph[a] = specPlotter.AddLineGraph(compositeDataSource, col[k], 3, names[k]);
                        a++;
                    }

                    if (i == 127)
                    {
                        x1 = 0;
                    }
                }
            }

            specPlotter.FitToView();
        }
コード例 #3
0
        //методы построения графиков и спектра при различных входных данных

        public int[] funcSin(Harmonics[] harms, Plotter2D sinPlotter, LineGraph[] sinGraph)
        {
            EnumerableDataSource <double> xDataSource;
            EnumerableDataSource <double> yDataSource;


            int[] coords = new int[1000];

            double min = harms[0].harm.Min(h => h.f);

            float period = (float)(1 / min);

            hx = 0.01f;

            float x1Binary = 0, y1Binary = 0;
            int   count = 0;

            while (count < coords.Length)
            {
                x1Binary += hx;
                y1Binary  = (float)harms[0].getSample(x1Binary) * 2; // *2 - амплитуда домножается для того, чтобы убрать минусы
                // *4 - прост))
                coords[count] = Convert.ToInt32(Math.Abs(y1Binary));
                count++;
            }

            hx = 0.0001f;

            for (int k = 0; k < 3; k++)
            {
                xln = (lx - l2);
                x1  = 0;
                y1  = (float)harms[k].getSample(x1);
                n   = lx;
                n1  = ly;

                int a = 0;

                double[] x = new double[(int)Math.Ceiling(period / hx)];
                double[] y = new double[(int)Math.Ceiling(period / hx)];

                while (x1 < period)
                {
                    x1 += hx;
                    y1  = (float)harms[k].getSample(x1);

                    x[a] = x1 * 2;
                    y[a] = y1;
                    a++;
                }

                // Create data sources:
                xDataSource = x.AsXDataSource();
                yDataSource = y.AsYDataSource();

                CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);

                sinGraph[k] = sinPlotter.AddLineGraph(compositeDataSource, col[k], 3, names[k]);
                sinPlotter.FitToView();
            }

            return(coords);
        }