Rebuild or add Knots?

I just noticed that adding knots gives me a much lower deviation than rebuilding. I’m surprised that rebuild accuracy is so low. I’m just looking at arcs. it might be different with more complex curves. Insights?
Rebuild-Vs-Knots.gh (11.3 KB)

the definition you uploaded does not contain a rebuild or adding knots.
so we can not know how the curves are made, changed

I don’t know what you want to achieve. But rebuild is intended to clean-up curves. Deviation to the original curve is even desired to reach this goal. Arcs are special, because they are weighted. To replace an arc with a un-weighted Nurbs/Bezier curve, you need to do a bit more. In Rhino I’m not aware of a proper conversion, because a simple, unweighted Nurbs/Bezier curve cannot properly represent an arc or circle. For a circle, a good approximation with Beziers requires 4 “Order-7” Bezier curves

Yeah, sorry it’s supposed to be a rhino post not a grasshopper one. The script is there just to measure the deviation. The construction is straightforward. Say you have an arc with 3 control points but you need more (in my case I need to manipulate it to create a bulge in elevation and an arc in plan and maintain end tangents)
How to do that while minimising deviation? Somehow I thought rebuilding would be a good method. Clearly inserting knots returns a curve closer to the original. Not sure if you have better suggestions.

I’m intrigued by why you would ever desire deviation

Because you can not force a curve/surface to be “cleaner” in any circumstances.

It depends a bit on what your overall goal is. You did not elaborate yet.
If you want to add or remove cps, you should use degree elevation. You can also refit/-approximate a curve. But Rhino does not offer the best functionality for this, IMHO.

In my understanding ‘rebuild’ improves the quality of the curve, by moving cps in a more relaxed position. This improves the overall flow-of-curvature etc.. But you cannot move cps without deviating. Its just not possible…

I elaborated a little in response to Jakob:

I guess you’re right, and I’m realising this was a pretty lazy post.
The Rebuild icon in Grasshopper kind of proves your position


In addition, there are a bunch of rebuild options here that I’ve ignored:
image
“rebuild to master curve” and “rebuild non-uniform”
I probably should test these out and come back.

you can try change degree… .

This adds control-points without deviation. But still. An arc is a weighted/rational nurbs. You might use a blend curve instead of an arc. I think there is no easy conversion to a non-rational Nurbs. But try changing the degree first.

I would expect rising degree to cause deviation too unless you work singlespan.

InsertKnot does not change the degree or shape of the curve. It will increase the number of spans by the number of knots inserted. InsertKnot works on rational curves including arcs as well as nonrational curves.

When ChangeDegree is used to increase degree of a single span curve the result has zero deviation from the input. and will be a single span curve.

When ChangeDegree with Deformable=No is used to increase degree of a multispan curve the result has zero deviation from the input, the number of spans is unchanged, and will has multiknots.

When ChangeDegree with Deformable=Yes is used to increase degree of a multispan curve the result will usually deviate from the input, the number of spans is unchanged, the result ** doesnot have multiknots** (unless the input had multiknots).

An arc cannot be represented exactly by a non-rational NURBS curve. An arc can be approximated by a non-ration NURBS curve within an desired accuracy by combinations of degree and number of spans.

For example a 90 degree arc with radius 1 can be approximated by:
Degree 3 single span 4 control points - max deviation 0.0027
Degree 3 two span 5 control points - max deviation 0.0004
Degree 3 three span 6 control points - max deviation 0.00007
Degree 5 single span 6 control points - max deviation 0.00002
Degree 7 single span 8 control points - max deviation 0.00000007
These approximations were obtained using Rebuild

I have a very different understanding of the Rebuild command in Rhino. My understanding is based on studying numerical methods, experimentation with Rhino, and occasional comments and answers to questions by McNeel staff on this forum. I do not have any direct knowledge of the Rhino code.

There is nothing in how Rebuild works which inherently leads to “moving cps in a more relaxed position. This improves the overall flow-of-curvature etc.” Depending on the shape of the input curve and the degree and number of control points selected for the rebuild, the resulting curves may have control points with large oscillations compared to the input curve. This is more likely the higher the degree of the result. (See the bottom of this post for a simple example of using Rebuild to a single span degree 7 curve from a single span degree 3 curve.)

Rebuild uses a simpler interpolation algorithm which only uses a small number of points on the input curve as input to the algorithm, and then fits a curve to those points.

The basic method used by the Rebuild command:
Points with equal arc length spacing on the input curve are created. The number of points equals the number of control points specified for the result. The curve with the specified degree and number of control points is determined which has edit points coinciding with the points along the input curve.

If the “Preserve end tangent directions” and/or “make SubD friendly” options are selected then determination of the curve is modfied to satisfy those options, but it is still interpolation through a set of points.

Example of using Rebuild from single span degree 3 to single span degree 7:
Rebuild3to7 DC01.3dm (52.2 KB)

thank You for the explenation. MULTIKNOTS - didn´t knew

This is a typical blend curve and the deviation is very acceptable. Other than that, I was exactly writing this in the previous post. But maybe he doesn’t need to have an exact arc at all.

Yes you are right here, but this essentially often leads to a better curve (if the desired cp-count is lower), even with strong oscillation. So yes, the second part of my statement was inaccurate. But its not the complete different. The interpolation will move the cps in a better, more equidistant position.
I would also assume that there is a smoothing part in this algorithm. But that doesn’t mean that smoothing or interpolation always work as expected. This is also true for any fitting operation. And essentially this together sometimes leads to these strange result as shown.

I have not seen any evidence in my experiments with the Rebuild command algorithm that suggest it includes any smoothing. The results are consistent with interpolation without modification.

The higher the degree of the polynomial used in interpolation through points the greater the tendency for oscillations to occur. That is how the math works. I first heard about this during a course in numerical methods almost fifty years ago. It was given as a primary reason to use multi-span splines of lower degree for interpolation in preference to higher degree single span curves.

The ChangeDegree command in Rhino appears to use a fundamentally different method, not interpolation, which does not result in such oscillations. I assume it uses a degree change algorithm which calcuates the new control points directly from the input control points such as described in “The NURBS Book”.

You find degree elevation also explained here:

I have also seen various interpolation algorithms and I also implemented an interpolation algorithm for n-degree Bezier curves. Its not so difficult actually. You basically reverse the standard point-on-curve (de Casteljau/De Boor) algorithm and solve the equation system. The only thing you can vary is the parameter spacing. Maybe “rebuild” ends there, but I’ve heard that any good interpolation and approximation algorithm should always smooth-out afterwards and use some sort of energy minimising algorithm. But sure, this does not mean its actually implemented here.

interestingly RH9 has a new rebuild command called Elmo with more detailed rebuild options