Smarter rebuild nurbs curves (and surfaces)

Hi all.

There are any tool or functions to have a “smarter” rebuild curve?

Sometimes I need a smooth curve (curvature continuity) … and I just set something like degree=5 , a not-too-high division count and end it like that…
But when I need a light curve/surface I have to use few control points and then I manually correct the curve to the original (pre-rebuild) curve.


curves.3dm (49.6 KB)
Red is rhino rebuild curve function; there are some “great” gap
Green is manually adjusted in 30 sec… by instinct or “heuristically”…

Has it ever been done a function/command/plug-in to do this automatically?

Please tell if I was not clear enough.

Edit: I’m interested to know also if any other software have a function of something like this… do someone know?

Hi
Did you try fit crv?

Actually no. I’ve never used that command (either in rhino or grasshopper).
Thanks for pointing it out.

But… tooltip in grasshopper says “Fit a curve along another curve”… and there is only one curve input…:face_with_raised_eyebrow:
In rhino too: you just feed it a curve and a tolerance.

I’m not getting at all how it should be used…
There are some examples?

Edit: also it seems it drastically increase control point count… not what i’m searching for…

Try RebuildCrvNonUniform and change the MaxPointCount until it looks right. in this case 13 points seem to do the job:

That too is new stuff for me. Thanks.
But results are somehow very similar to normal rebuild.
I’ve tested just now some curves: again results are “improvable” manually (by dragging control points).

I hope to not offend anyone in mcneel… but those functions do not seem “smart” in any way (and maybe were never designed to be).

I often find myself rebuilding curves made of arcs from some “designer”… and we all know that a degree 4+ curve is much smoother (and better to see) than a poly-arc curve.
Rebuiding with just many points add small “waves” and such in the shape… fewer but well-placed control points are always better… that’s my idea.

I’m asking because I have some idea in mind for an automatism… but I didn’t want to waste time on it if someone already done something similar somewhere… (even outside rhino environment)

(I don’t even know the right keyword to search…)

1 Like

I don’t think anyone will get offended by you pointing out the limitations of math. You are telling rhino to rebuild something with fewer points/higher degree and it will follow your input as close (even down to the kinks and ugly transitions) or as smooth (interpolation and deviating from the not so great input) as you want.

Fit curve description is a little confusing. What it means is its fitting a new curve along your input curve. Essentially it redistributes control points based on curvature so that the newly generated curve only deviates from the input curve by a set tolerance. It is great for making better structured curves especially if you plan to loft or tween (that’s why loft has a refit option). The downside is it may make many control points depending on your curvature.

So I would say fit curve is best used for when you have many curves that need to do something together (loft) but the profiles are important to keep.

Ok, I’ve put up some code.
Iterating then… like doing it manually.
(I haven’t found a logic to solve this matter in a single shot.)

It seems like rhino/grasshopper rebuild function “waste” points at the start/end of the curve (even if “preserve tangents” is turned off).
As just said, at first I still used the rhino rebuilt curve as first step of the re-fitting… but then I’ve found that using point from evenly dividing the original curve is advantageous.

This is slow, iterating … (and my code is completely messed up, no closed curve support, etc, etc…)

Something better than this?
Even just some theory behind…

12 Likes

This looks interesting! How does it work when the input is a 3D curve?

1 Like

I never actually though about 3d curves! … serendipidly it seems it works just the same.
smart-refit-3d
Static ones are standard rhino rebuild (with again same point count and degree).

At first i’m doing some single step in the iteration (so there’s actually chance for a “light” function), but then i let the iteration go as rightest curve needed more fitting…

(indeed i’m choosing the minimum amount of control point so the curve actually can be rebuilt without significant shape lost, like again doing it manually… almost voluntarily putting contrast to rhino rebuild function… if I put too few points both give ugly result, as well as with too many points both give good results)

1 Like

I wasn’t sure if I should (or wanted to) be jealous and keep for myself this… oh well…

Basically the idea was to pull a “portion” of the fitting-curve to the reciprocal “portion” of the original curve.
Like, the start point with the other start point, end with end, mid with mid… and so on.

I randomly discovered Greville points… (didn’t know the name).

For every iteration it:
-make a list of vectors from fitting curve to original, as said above (by equally lenght-subdividing both curves)
-for every Greville point making a sub-list of the vector list, picking only the near ones (near by curve parameter)
-for every Greville point, moving the corrispective control-point by the average of the vector sub-list

The Greville points “know” where to go by looking at the local vectors… so if a part of a curve is “shifted” behind of where it should be the vectors clearly tells it out.

Probably gifs tell more than all the words…
(vectors scaled down for the sake of human view; vectors 1x give decent results in few iterations)

refit_curve_2


Note how red (that is the summit of the bulge) vectors sub-list average is directly pointed so it pull red Greville to the relative original summit.

Iteresting that, I haven’t fixed start/end points as in the script (theese gifs are made with anemone), but still them get to their place.

refit_curve_3

(Do someone ever have made stuff like this into a living? :roll_eyes: )

Anyway… do Greville points equivalent for surface exists?
If no, how can I calculate it?
(Or better, what are Greville points?)

8 Likes

There is a method in RhinoCommon:
NurbsSurfacePointList.GetGrevillePoint

If I’m not mistaken, you can extract Surface Greville Points like this:


Riccardo.gh (17.4 KB)

1 Like

Uh! That’s great!
Thank you!

Then… I think translating the algorithm from curve to surface shouldn’t be that hard or different…

WIP

1 Like

Greville points are edit points. You can use them in rhino with the EditPtOn command. In Pufferfish I have an edit points component that uses them.

Looks very nice :slight_smile:

Just as background, the big difference between most curve fitting/rebuild algorithms and what you’ve implemented is that you’re changing the curve parameterization.

The advantage of keeping the parameterization the same is that the refit is a linear system, which makes it have a single solution, and fast to compute - you can use a direct solver instead of an iterative solver. The disadvantage is that the fits might not be optimal (if you don’t care about curve parameterization).

Now that CPUs are so much faster than they used to be, it makes sense that nonlinear solvers are more feasible.

One thing you might want to try is translating the original curve out of the plane, and then loft between the original and the refit. That will show you how much the parameterization is changing between the two.

Riccardo,
As interesting as this discussion is, it might be in your best interest to fall silent on the Forum and pursue the matter privately. A smart(er) Rebuild command could be (in my view as an endlessly frustrated rebuilder) a real Godsend.
Michael

Thank you.

That make sense.
I think the “problem” here is my personal viewpoint of Nurbs curves.
As I knew them time ago, I really appreciate them for the smoothness of the shape (for a natural shape I always want a degree=5 one, not less).
So, everytime I rebuild a curve with many points (to avoid shape-loss) I end up with a curve with, indeed, linear parametrization (useful for loft and many other situations), but with also many “wrinkles” in the curvature…
It’s a compromise for me.
Using a nurbs curve in that way seems a waste for me, an improper use of a tool… or even worse like: “we have nurbs, but let’s use high-detailed polylines anyway”.
I found myself always capable of re-drawing a complex shape with so many points, tanks to nurbs.
Using back again many points seems like going back in time.
(I am being redundant?)

So in the lack of the other counterpart, I made the opposite of that compromise: another compromise where linear parametrization is lost, but shape is kept and curvature is smooth… with few points!
Maybe working with weights would… no, maybe knowing what weights are would help in this matter… I have no clue.

(again, maybe what I’m writing here is total nonsense… I have just high-school math knowledge)

I’m almost doing this for fun, for hobby.
It started with me searching for something… and then I found myself creating what I was searching for in an afternoon.

I’m seeing a lot of free tools (plug-ins and such) in this environment… I’ve learnt so much stuff just messing around in the forum, the more I share the more I get. (is it so? :sweat_smile:)

I’d very like to use this stuff (grasshopper in general) for a living, but I have no idea where to start with.

I’m not sure on what to do.

I want this as standard tool!
it looks great!