How to approximate NURBS with bezier spline

what algorithm should be used to approximate a Nurbs curve to which I have control points, knots and weights to turn it into one or several bezier spans?

I know ConvertToBeziers command is doing this but I’d like to know how to do this programmatically?

I’m trying to use this equation for approximating the nurbs curve:

But something is missing…

I thought maybe I need to first get the equation of the approximated nurbs curve and then somehow fit bezier spans there, but I can’t figure out how.

Any advice?

here’s my gh file. (7.8 KB)

Get an entry level C# on that matter (123.0 KB)

It seems you’re trying to create a third-degree curve using 5 points. Curves that have more control points than 1+the degree are internally piecewise, the points of transition between these internal curve spans are called knots.
source: rhino_basics.pdf (2.5 MB)

You can extract these spans by shattering the curve at its knots like this:

Obviously each spans has it’s own control-points:

Therefore, to convert this multi-span curve to a piecewise cubic Bezier curve, we need to find the relationship between spans control points and the main curve control points:

Keep in mind that every span is a simple cubic Bezier curve so you can lerp them simply by this formula:

pt = -p_0t^3+3p_0t^2-3p_0t+p_0 + 3p_1t^3-6p_1t^2+3p_1t - 3p_2t^3+3p_2t^2 + p_3t^3

Putting all together we will have something like this: (14.2 KB)


How about this? (6.1 KB)

– Dale

Thanks @Mahdiyar ,

This is exactly what I wanted to do.

So a Nurbs curve with 4 control points is exactly a cubic Bezier curve and a Bezier span of nurbs with more than 4 control points is taking the 3 control points of the nurbs and the 4th one is taken as the mid point of the line between control point 3 and 4.

What then happens if the Nubrs has exactly 5 control points? There should be two Bezier spans. Does the second span’s 2nd and 3rd control points coincide?

How do you determine which span should have coinciding control points?
Does it matter?

Never mind, apparently the second span is also with 4 points.

A single span NURBS curve has 1 more control points than the degree. There is a Bezier curve of the same degree which is exactly equivalent.

A multi-span NURBS curve has a number of control points equal to the degree plus the number of spans. For each span in the NURBS curve there is a Bezier curve of the same degree which is exactly equivalent to that span. The total number of Bezier curves equivalent to a multi-span NURBS curves is the number of spans.

ConvertToBezier splits a NURBS curve into single span curves, one per span of the original NURBS curve.

1 Like

Thanks @davidcockey,

One thing still puzzles me, how are the knots values assigned?
I understand it’s something to do with the “overlapping” control points. That is if control point in one span (bezier curve) is also used in another span. But what is the meaning of the multiplicity and how does it affect the curve?

What if:
degree = 3
number of control points = 6
number of spans = 3
knot vector (by definition not by Rhino) = (0, 0, 0, 0, 1, 2, 3, 3, 3, 3)

why is it 0, 0, 0, 0, 1, 2, 3, 3, 3, 3 and not say - (0, 0, 0, 1, 1, 2, 2, 3, 3, 3) or (0, 0, 0, 0, 1, 1, 2, 2, 2, 2)?