Sinc1D constructor

Sinc1D(int npoints, double amplitude, double phase, int nperiods, double offset)

Computes the "sine cardinal" = "sinc" function f(x) = offset + amplitudesin(x+phase)/(x+phase) The resulting array of size npoints will contain "nperiods" (2pi) of the damped sinc wave with the specified amplitude and phase .

Implementation

Sinc1D(int npoints, double amplitude, double phase, int nperiods,
    double offset) {
  double xmax = 2 * math.pi * nperiods;

  _xValues = Float64List(npoints);
  _array = Float64List(npoints);
  double x, y, a;

  a = amplitude;

  for (int i = 0; i < npoints; i++) {
    x = (i * xmax) / npoints;
    if (i == 0 && phase.abs() < 0.00001) {
      y = a;
    } else {
      double ph = x + phase;
      y = a * math.sin(ph) / ph;
    }
    _xValues[i] = x;
    _array[i] = y + offset;
  }
}