Hello!
I am currently facing an issue which I think might have to do with knots, but I am not sure.
In a nutshell I am trying to create a curve from the following code:
int degree = 3;
ON_NurbsCurve curve1(degree,true,degree+1,4);
for (std::size_t i=0; i<4; ++i)
{
curve1.SetCV(i, ON_3dPoint(i, sin(i), 0.0));
curve1.SetWeight(i, 1.0);
}
curve1.MakeClampedUniformKnotVector();
The above code creates a sin curve using 4 cv points. The output is correct, as shown below:
The curve reaches x=3, which is expected.
However, when I increase the number of cv points, I get a weird result (see code below).
int degree = 3;
ON_NurbsCurve curve2(degree,true,degree+1,5);
for (std::size_t i=0; i<5; ++i)
{
curve2.SetCV(i, ON_3dPoint(i, sin(i), 0.0));
curve2.SetWeight(i, 1.0);
}
curve2.MakeClampedUniformKnotVector();
The result is incorrect because the curve stops at x=2 instead of x=4, as shown below:
What am I missing in this example? What is the problem?