private double NewtonRaphsonIterate(double aX, double aGuessT, double mX1, double mX2)
 {
     for (int index = 0; index < 4; ++index)
     {
         double slopeX = CubicBezier.GetSlopeX(aGuessT, mX1, mX2);
         if (Math.Abs(slopeX) < 1E-07)
         {
             return(aGuessT);
         }
         double num = CubicBezier.CalcBezierX(aGuessT, mX1, mX2) - aX;
         aGuessT -= num / slopeX;
     }
     return(aGuessT);
 }
        private double GetTForX(double aX)
        {
            double aA     = 0.0;
            int    index1 = 1;

            for (int index2 = 10; index1 != index2 && this._sampleValues[index1] <= aX; ++index1)
            {
                aA += 0.1;
            }
            int    index3 = index1 - 1;
            double num1   = (aX - this._sampleValues[index3]) / (this._sampleValues[index3 + 1] - this._sampleValues[index3]);
            double num2   = aA + num1 * 0.1;
            double slopeX = CubicBezier.GetSlopeX(num2, this._x1, this._x2);

            return(slopeX < 0.001 ? (!CubicBezier.AlmostEq(slopeX, 0.0) ? CubicBezier.BinarySubdivide(aX, aA, aA + 0.1, this._x1, this._x2) : num2) : this.NewtonRaphsonIterate(aX, num2, this._x1, this._x2));
        }