Reverse of Curve Interpolation

Hi, I’m not sure this is a function that will have had much demand (or maybe be that practical), but I’m interested if Rhino (in particular Rhinocommon) can do the opposite of the interpolation for curves? The input would be a nurbs curve, the output would be a “minimal” set of points that when interpolated (with start and end tangent of the curve) would recreate the nurbs curve to a nominated tolerance?
I could simply divide the curve into a nominated number of equidistant points, but I’m wondering if there is a better approach.

Thanks for any suggestions if this is possible. The requirement is to allow recreation of the curve in external software.

You can access the Greville points of a NurbsCurve.

Usually when implementing an interpolation algorithm from scratch, one mandatory function parameter is always the (curve-) parameter spacing. In Rhino you are limited in defining that. Usually you can choose inbetween 3-4 modes I believe. If you choose uniform, then on a Single-Span-Nurbs of order 4, your points will be at t0=0.0 t1=0.333 t2=0.666 t3=1.0. But of course you would need to know how the curve was created initially, so that it will recover the same curve. I think you can recover the required information when analyzing the spacing of the knot-vector. But I’m not 100% sure here.

In any case, there is also something called curve-approximation, where a curve narrows a set of data-points as close as possible. This is not part of Rhinocommon. And a good approximation algorithm contains a smoothing algorithm. Can be implemented using LLS algorithms and/or recursive annealing.

Just out of curiosity, what are you trying to implement at the end?

Thanks for the reply, it’s very helpful. My previous search didn’t turn up that as a possibility (shows I should have put more effort into my search).

The objective is to export curves out of Rhino into an external application where I can’t (yet) nominate control points, knot vectors etc (it must be in the software, just not accessible from the API).

An extreme test in Grasshopper of the Greville points shows deviations, but I can add some validation as the typical use of the process is much simpler curves where this approach should be fine.

220720 greville (11.0 KB)

A similar scenario might be involved in the Rhino Inside Revit project, In effect the external software might create something akin to a hermitespline where you nominate end tangents and interpolation points. I’ve taken a quick glance at the RIR code, but believe they are not using hermite splines (modern versions of Revit has ability to nominate nurbs curves).

Hey @jonm,

Have a look at:

– Dale

Thanks Dale, hope you’re great.
The methods you refer to are the opposite of what I’d like. Ie I want to take a nurbs curve, and determine a “minimal/practical” number of points to define the equivalent hermite spline.
I’m mainly checking if something already exists, it’s a nice to have, but not something I expect or demand.

Again I’m not 100 % sure, but I always assumed that a Hermite and a Bézier Spline are the same, they are just expressed in a different form. So for a cubic spline, the Hermite form uses Start and Endpoint, and both tangents at start and end, whereas a cubic Bézier spline requires the 4 controlpoints. But essentially this is the same spline. (Because you get the tangents by subtracting p1 from p0 and pn-1 from pn)

Is it “just” a cubic Hermite spline you want?

So with that in mind, the problem you have is a little more complex!
You want to make out of an arbitrary NurbsCurve a set of non-rational cubic Beziersplines. Now a NurbsCurve is a composite Bezier spline, that’s the reason why you have something like knots. They essentially determine how a Nurbs is composed together.

So this task can be quite simple if some conditions are true. The NurbsCurve must be non-rational (all cp-weights == 1) and of degree 3 (=cubic). If it has one span, then it’s already a cubic Bezier = cubic Hermite. If it has more spans, then you need to decompose the cubic splines which is easy as well.

The problem begins if the degree is different and/or you have a rational spline. Then you need to approximate. At least this is what all the class A surface modelling softwares make very well. Especially ICEM Surf and Alias are very good at this. Rhino lacks powerful algorithms, but there are some approximation (“fitting”) algorithms. I think Rhinocommon’s approximation algorithm/command (which is not as powerful) is called “FitCurve”. One problem is, that you might need to approximate by using more than one Bezier/Hermite spline, which is one of the greater challenges. This is because it is not obvious where one sub-curve need to start or end to get a perfect fit.

E.g. If you want to convert a NurbsCircle you would need 4 Bezier-curves of degree 6 to match a real circle. This essential shows the advantage of Nurbs over Hermite/Bezier splines, although rational splines also have disadvantages. But this is another topic.

Another approach is degree elevation!
If your curve non-rational and of degree 2 you can increase the degree to 3, making it cubic without any deviation, but, depending on your curve properties, lowering the degree might lead to deviation as well.

But again, this is not a trivial problem!

As a follow up, I’ve had a conversation with the other software vendor. They have methods to create nurbs curves and surfaces using control points, knots, degree etc, so this question is now obsolete (I hope, will be back if I implement and there it’s not as I understand it).

Thanks for the responses and interesting insights.