interpolateDoubleArray function

Interpolator<List<double>> interpolateDoubleArray(
  1. List<double> a,
  2. List<double> b
)

Creates a double array interpolator between a and b.

Implementation

Interpolator<List<double>> interpolateDoubleArray(
    List<double> a, List<double> b) {
  assert(a.length == b.length, 'Arrays must have the same length');

  final n = a.length;

  return (double t) {
    final result = List<double>.filled(n, 0);
    for (int i = 0; i < n; i++) {
      result[i] = a[i] + (b[i] - a[i]) * t;
    }
    return result;
  };
}