Esempio n. 1
0
        public Vector2D Evaluate(double u)
        {
            Vector2D      zero          = Vector2D.Zero;
            List <double> doubleList    = new List <double>((IEnumerable <double>) this.linkedList_0);
            int           knotSpanIndex = NurbsUtilD.GetKnotSpanIndex(u, (IList <double>)doubleList, this.int_0);

            double[] result = new double[this.int_0 + 1];
            NurbsUtilD.EvaluateBasisFunctions(knotSpanIndex, u, this.int_0, (IList <double>)doubleList, result);
            List <Point2D> point2DList = new List <Point2D>((IEnumerable <Point2D>) this.linkedList_1);
            int            index1      = knotSpanIndex - this.int_0;

            for (int index2 = 0; index2 <= this.int_0; ++index2)
            {
                double  num     = result[index2];
                Point2D point2D = point2DList[index1];
                zero.X += num * point2D.X;
                zero.Y += num * point2D.Y;
                ++index1;
            }
            return(zero);
        }
Esempio n. 2
0
        public static void EvaluateRationalBasisFunctions(
            int knotIndex,
            double u,
            int degree,
            double[] knots,
            double[] weights,
            double[] result)
        {
            NurbsUtilD.EvaluateBasisFunctions(knotIndex, u, degree, (IList <double>)knots, result);
            double num1 = 0.0;
            int    num2 = knotIndex - degree;

            for (int index = 0; index < result.Length; ++index)
            {
                result[index] *= weights[(num2 + index) % weights.Length];
                num1          += result[index];
            }
            double num3 = 1.0 / num1;

            for (int index = 0; index < result.Length; ++index)
            {
                result[index] *= num3;
            }
        }