interpolate method

  1. @override
dynamic interpolate(
  1. int i1,
  2. num t0,
  3. num t,
  4. num t1,
)
override

Implementation

@override
interpolate(i1, t0, t, t1) {
  var result = resultBuffer,
      values = sampleValues,
      stride = valueSize,
      o1 = i1 * stride,
      o0 = o1 - stride,
      oP = _offsetPrev,
      oN = _offsetNext,
      wP = _weightPrev,
      wN = _weightNext,
      p = (t - t0) / (t1 - t0),
      pp = p * p,
      ppp = pp * p;

  // evaluate polynomials

  var sP = -wP * ppp + 2 * wP * pp - wP * p;
  var s0 = (1 + wP) * ppp + (-1.5 - 2 * wP) * pp + (-0.5 + wP) * p + 1;
  var s1 = (-1 - wN) * ppp + (1.5 + wN) * pp + 0.5 * p;
  var sN = wN * ppp - wN * pp;

  // combine data linearly

  for (var i = 0; i != stride; ++i) {
    result[i] = sP * values[oP + i] + s0 * values[o0 + i] + s1 * values[o1 + i] + sN * values[oN + i];
  }

  return result;
}