intervalChanged method

  1. @override
dynamic intervalChanged(
  1. dynamic i1,
  2. dynamic t0,
  3. dynamic t1
)

Implementation

@override
intervalChanged(i1, t0, t1) {
  var pp = parameterPositions;
  var iPrev = i1 - 2, iNext = i1 + 1, tPrev = pp[iPrev], tNext = pp[iNext];

  if (tPrev == null) {
    switch (getSettings().endingStart) {
      case ZeroSlopeEnding:

        // f'(t0) = 0
        iPrev = i1;
        tPrev = 2 * t0 - t1;

        break;

      case WrapAroundEnding:

        // use the other end of the curve
        iPrev = pp.length - 2;
        tPrev = t0 + pp[iPrev] - pp[iPrev + 1];

        break;

      default: // ZeroCurvatureEnding

        // f''(t0) = 0 a.k.a. Natural Spline
        iPrev = i1;
        tPrev = t1;
    }
  }

  if (tNext == null) {
    switch (getSettings().endingEnd) {
      case ZeroSlopeEnding:

        // f'(tN) = 0
        iNext = i1;
        tNext = 2 * t1 - t0;

        break;

      case WrapAroundEnding:

        // use the other end of the curve
        iNext = 1;
        tNext = t1 + pp[1] - pp[0];

        break;

      default: // ZeroCurvatureEnding

        // f''(tN) = 0, a.k.a. Natural Spline
        iNext = i1 - 1;
        tNext = t0;
    }
  }

  var halfDt = (t1 - t0) * 0.5, stride = valueSize;

  _weightPrev = halfDt / (t0 - tPrev);
  _weightNext = halfDt / (tNext - t1);
  _offsetPrev = iPrev * stride;
  _offsetNext = iNext * stride;
}