getPointY method

double getPointY(
  1. double t
)

Computes the curve's Y coordinate at a point between 0 and 1. @param {number} t The point on the curve to find. @return {number} The computed coordinate.

Implementation

double getPointY(double t)
{
  // Special case start and end.
  if (t == 0) {
    return this.y0;
  }
  else if (t == 1) {
    return this.y3;
  }

  // Step one - from 4 points to 3
  double iy0 = Algebra.lerp(this.y0, this.y1, t);
  double iy1 = Algebra.lerp(this.y1, this.y2, t);
  double iy2 = Algebra.lerp(this.y2, this.y3, t);

  // Step two - from 3 points to 2
  iy0 = Algebra.lerp(iy0, iy1, t);
  iy1 = Algebra.lerp(iy1, iy2, t);

  // Final step - last point
  return Algebra.lerp(iy0, iy1, t);
}