newtonRaphsonIterate function

double newtonRaphsonIterate(
  1. double aX,
  2. double aGuessT,
  3. double mX1,
  4. double mX2,
)

Implementation

double newtonRaphsonIterate(double aX, double aGuessT, double mX1, double mX2) {
  for (int i = 0; i < newtonIterations; ++i) {
    double currentSlope = getSlope(aGuessT, mX1, mX2);
    if (currentSlope == 0.0) {
      return aGuessT;
    }
    double currentX = calcBezier(aGuessT, mX1, mX2) - aX;
    // ignore: parameter_assignments
    aGuessT -= currentX / currentSlope;
  }
  return aGuessT;
}