Rhino.Geometry.NurbsCurve() constructor bug

Hello all,

I may be using it wrong but I am finding that:

Rhino.Geometry.NurbsCurve(dimension, rational, degree, point count) creates a Nurbs Curve object with one less Knot than Rhino.Geometry.NurbsCurve(degree, point count);

Is this a bug or is there something I am missing about this constructor?

Hi,

The constructor initializes the curve, but does not add mutable properties like the knot vector and the actual control points. With a given degree, you can create a default knot vector sequence. But usually for a NurbsCurve the knot vector is the important property. It determines the parameterization, the subdivision of the Bézier segments and the continuity in between these segments. If it’s periodic or not, etc. Without specifying, you can’t really control the curve itself.
Unless you want to do this manually, you should use one out of the static factory methods:

NurbsCurve.Create()
NurbsCurve.CreateFromLine()
…

You can also create another curve type and apply the .ToNurbsCurve() method.

Hi Tom,

Thank you so much for your answer. I understand all this as I am negotiating rhino against a custom Nurbs implementation. I am saying that the Knot Vector that is outputted from that constructor is the wrong size and that it may be a bug. Unless that constructor produces a knot vector one size too small by design and I am missing something.

Matthew.

Ok, I guess the post was a bit off to your question. I’m just trying to say that it shouldn’t matter what the knot-vector is after calling the constructor, because if you create a curve from scratch, then you need to define the knot-vector anyway. In other words, even if there is a mismatch on different ctor overrides, the knot-vector is at that point just a placeholder.

Btw: I noticed the following:
public NurbsCurve(
int dimension,
bool rational,
int order,
int pointCount
)

The ctor with more arguments does memory allocate. In order to do that, it needs to know the amount of future cps equal to the length of the knot vector.

The order is not the degree of a curve. The order is usually the degree+1.

1 Like

That describes my problem! Yeah, you are right I forgot that as the other describe degree instead of order. Bizarre that one calls order and the other calls degree…nevertheless, thanks, I’ll be more careful on the future.