Exemple #1
0
        protected override Func <double, double> GetBasisFunction(BasisInfo _info)
        {
            BezierBasisInfo info = (BezierBasisInfo)_info;

            int n = info.N;
            int i = info.I;

            Func <double, double> func = (t) => MathTool.GetBinomialCoefficient(n, i) * Math.Pow(t, i) * Math.Pow(1 - t, n - i);

            return(func);
        }
Exemple #2
0
        public void GetBinomialCoefficient()
        {
            int n, i, a, r;

            n = 3;
            i = 2;
            r = MathTool.GetBinomialCoefficient(n, i);
            a = 3;
            Assert.IsTrue(a == r);

            n = -1;
            i = 2;
            Assert.ThrowsException <ArgumentException>(() => MathTool.GetBinomialCoefficient(n, i));

            n = 2;
            i = -2;
            Assert.ThrowsException <ArgumentException>(() => MathTool.GetBinomialCoefficient(n, i));
        }