예제 #1
0
        public void CreateUniformPeriodicKnotVector_Throws_An_Exception_If_Are_Not_Valid_Inputs(int degree, int numberOfControlPts)
        {
            // Are identifies as not valid inputs when:
            // Degree and control points count is less than 2.
            // Degree is bigger than the control points count.
            // Act
            Func <KnotVector> funcResult = () => KnotVector.UniformPeriodic(degree, numberOfControlPts);

            // Assert
            funcResult.Should().Throw <Exception>();
        }
예제 #2
0
        public virtual NurbsBase Close()
        {
            // Wrapping control points
            List <Point4> pts = new List <Point4>(ControlPoints);

            for (int i = 0; i < Degree; i++)
            {
                pts.Add(pts[i]);
            }

            KnotVector knots = KnotVector.UniformPeriodic(Degree, pts.Count);

            return(new NurbsCurve(Degree, knots, pts));
        }
예제 #3
0
        public void It_Creates_A_Periodic_Uniform_KnotVector()
        {
            // Arrange
            int        degree             = 2;
            int        ctrlPts            = 5;
            KnotVector expectedKnotVector = new KnotVector {
                -0.666667, -0.333333, 0, 0.333333, 0.666667, 1, 1.333333, 1.666667
            };

            // Act
            KnotVector knots = KnotVector.UniformPeriodic(degree, ctrlPts);

            // Assert
            for (int i = 0; i < knots.Count; i++)
            {
                (expectedKnotVector[i] - knots[i]).Should().BeLessThan(GSharkMath.MaxTolerance);
            }
        }