コード例 #1
0
        private static double BinarySubdivide(
            double aX,
            double aA,
            double aB,
            double mX1,
            double mX2)
        {
            int    num1 = 0;
            double aT;
            double num2;

            do
            {
                aT   = aA + (aB - aA) / 2.0;
                num2 = CubicBezier.CalcBezierX(aT, mX1, mX2) - aX;
                if (num2 > 0.0)
                {
                    aB = aT;
                }
                else
                {
                    aA = aT;
                }
            }while (Math.Abs(num2) > 1E-07 && ++num1 < 10);
            return(aT);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 private CubicBezier(double x1, double y1, double x2, double y2, double yBegin = 0.0, double yEnd = 1.0)
 {
     this._y0 = yBegin;
     this._y3 = yEnd;
     this._x1 = x1;
     this._y1 = y1;
     this._x2 = x2;
     this._y2 = y2;
     if (0.0 > this._x1 || this._x1 > 1.0 || (0.0 > this._x2 || this._x2 > 1.0))
     {
         throw new ArgumentOutOfRangeException();
     }
     for (int index = 0; index < 11; ++index)
     {
         this._sampleValues[index] = CubicBezier.CalcBezierX((double)index * 0.1, this._x1, this._x2);
     }
 }