catmullRom static method

LatLng catmullRom(
  1. LatLng p0,
  2. LatLng p1,
  3. LatLng p2,
  4. LatLng p3,
  5. double t,
)

E3: Catmull-Rom Spline

Implementation

static LatLng catmullRom(LatLng p0, LatLng p1, LatLng p2, LatLng p3, double t) {
  double tt = t * t, ttt = tt * t;
  double q1 = -ttt + 2*tt - t;
  double q2 = 3*ttt - 5*tt + 2;
  double q3 = -3*ttt + 4*tt + t;
  double q4 = ttt - tt;
  return LatLng(
    0.5 * (p0.latitude*q1 + p1.latitude*q2 + p2.latitude*q3 + p3.latitude*q4),
    0.5 * (p0.longitude*q1 + p1.longitude*q2 + p2.longitude*q3 + p3.longitude*q4),
  );
}