catmullRom function

num catmullRom(
  1. dynamic t,
  2. dynamic p0,
  3. dynamic p1,
  4. dynamic p2,
  5. dynamic p3,
)

Bezier Curves formulas obtained from http://en.wikipedia.org/wiki/Bézier_curve

Implementation

num catmullRom(t, p0, p1, p2, p3) {
  var v0 = (p2 - p0) * 0.5;
  var v1 = (p3 - p1) * 0.5;
  var t2 = t * t;
  var t3 = t * t2;
  return (2 * p1 - 2 * p2 + v0 + v1) * t3 +
      (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +
      v0 * t +
      p1;
}