示例#1
0
        public DoubleSeries GetDampedSinewave(int pad, double amplitude, double phase, double dampingFactor, int count, int freq = 10)
        {
            var doubleSeries = new DoubleSeries(count);

            for (var i = 0; i < pad; i++)
            {
                var time = 10 * i / (double)count;
                doubleSeries.Add(new XyPoint {
                    X = time
                });
            }

            for (int i = pad, j = 0; i < count; i++, j++)
            {
                var xyPoint = new XyPoint();

                var time = 10 * i / (double)count;
                var wn   = 2 * Math.PI / (count / (double)freq);

                xyPoint.X = time;
                xyPoint.Y = amplitude * Math.Sin(j * wn + phase);
                doubleSeries.Add(xyPoint);

                amplitude *= 1.0 - dampingFactor;
            }

            return(doubleSeries);
        }
示例#2
0
        private DoubleSeries GetDoubleSeries(int count, Action <DoubleSeries> initAction)
        {
            var doubleSeries = new DoubleSeries(count);

            initAction(doubleSeries);

            return(doubleSeries);
        }
示例#3
0
 public void SetStraightLine(DoubleSeries series, double gradient, double yIntercept, int count)
 {
     for (var i = 0; i < count; i++)
     {
         var x = i + 1;
         var y = gradient * x + yIntercept;
         series.Add(new XyPoint {
             X = x, Y = y
         });
     }
 }
示例#4
0
        public void SetRandomDoubleSeries(DoubleSeries doubleValues, int count)
        {
            var amplitude = _random.NextDouble() + 0.5;
            var freq      = Math.PI * (_random.NextDouble() + 0.5) * 10;
            var offset    = _random.NextDouble() - 0.5;

            for (var i = 0; i < count; i++)
            {
                doubleValues.Add(new XyPoint {
                    X = i, Y = offset + amplitude * Math.Sin(freq * i)
                });
            }
        }
示例#5
0
        public DoubleSeries GetLissajousCurve(double alpha, double beta, double delta, int count)
        {
            var doubleSeries = new DoubleSeries(count);

            for (var i = 0; i < count; i++)
            {
                var x = Math.Sin(alpha * i * 0.1 + delta);
                var y = Math.Sin(beta * i * 0.1);
                doubleSeries.Add(new XyPoint {
                    X = x, Y = y
                });
            }

            return(doubleSeries);
        }
示例#6
0
        public DoubleSeries GetFourierSeries(double amplitude, double phaseShift, double xStart, double xEnd, int count = 5000)
        {
            var fourierSeries = GetFourierSeries(amplitude, phaseShift);

            var startIndex = Array.FindLastIndex(fourierSeries.XData, x => x < xStart);
            var endIndex   = Array.FindIndex(fourierSeries.XData, x => x > xEnd);

            var size = endIndex - startIndex;

            var result = new DoubleSeries(size);

            for (var i = startIndex; i < endIndex; i++)
            {
                result.Add(fourierSeries[i]);
            }

            return(result);
        }
示例#7
0
        public void SetFourierSeries(DoubleSeries series, double amplitude, double phaseShift, int count)
        {
            for (var i = 0; i < count; i++)
            {
                var xyPoint = new XyPoint();

                var time = 10.0 * i / count;
                var wn   = 2 * Math.PI / count * 10;

                xyPoint.X = time;
                xyPoint.Y = Math.PI * amplitude *
                            (Math.Sin(i * wn + phaseShift) +
                             0.33 * Math.Sin(i * 3 * wn + phaseShift) +
                             0.20 * Math.Sin(i * 5 * wn + phaseShift) +
                             0.14 * Math.Sin(i * 7 * wn + phaseShift) +
                             0.11 * Math.Sin(i * 9 * wn + phaseShift) +
                             0.09 * Math.Sin(i * 11 * wn + phaseShift));

                series.Add(xyPoint);
            }
        }