initNonuniformCatmullRom method

void initNonuniformCatmullRom(
  1. num x0,
  2. num x1,
  3. num x2,
  4. num x3,
  5. num dt0,
  6. num dt1,
  7. num dt2,
)

Implementation

void initNonuniformCatmullRom(num x0, num x1, num x2, num x3, num dt0, num dt1, num dt2) {
  // compute tangents when parameterized in [t1,t2]
  num t1 = (x1 - x0) / dt0 - (x2 - x0) / (dt0 + dt1) + (x2 - x1) / dt1;
  num t2 = (x2 - x1) / dt1 - (x3 - x1) / (dt1 + dt2) + (x3 - x2) / dt2;

  // rescale tangents for parametrization in [0,1]
  t1 *= dt1;
  t2 *= dt1;

  init(x1, x2, t1, t2);
}