Surface regression

Hi community!

Given a set of points, is it possible to get a surface that best fits the points? Similar to finding the best line or polynomial function that minimizes square error (in this case distances from the points to the square). Ideally, the simpler the better (to follow the analogy, it would be great to choose the degree of polynomial, rather than some degree=1000 that overfits to a ton of points)

I saw some CATIA videos where people select the mesh, then get a surface from the selected faces (though I think it’s the points the faces are made of that mattered)

Thanks a lot!

1 Like

This seems like something people have researched (probably years ago) but, I think I’m missing the correct keywords in my searches

In 2D, my problem would look like this:
regression
This image is from: Redirect Notice

Although I have to say I stopped working on it at some point. Also there was plugin called VSR which you can’t use anymore. It had a function to fit a surface to a mesh. From a practical standpoint you can only use such algorithm if it yields a proper curve/surface, and this has more to do with smoothing instead of fitting. Grasshopper is not the right tool for proper surface modelling. Almost any fundamental modelling tool is missing, meaning that fitting a surface is pointless if you cannot do more with it.

You find an okish algorithm in “The Nurbs Book” from Tiller and Piegl

1 Like

Thanks very much for your detailed reply Tom! I want to say that your project in the thread is a very important one! What I’m describing would be absolutely broken in the right situations

GH came to mind because of the coding part (also Rhino’s UI is way too hard for me). I was thinking more of points-in, surface-out algorithm so, I suppose there’s no surface modeling in the sense of adjusting the curves by hand. Certainly, having on access to important matrix tools like numpy, to say the least, has always been limiting.

I’m not sure if smoothing is the best way since it alters the input data–I will elaborate in the following reply.

I will do some homework on the book (thanks for pointing me to that!) to see what I can find in the meantime

Consider a discretization of an NURBS surface–all vertices from a dense tri-remesh of an original. And let’s say maybe 5% of the points are moved out of place at random.

With these points as input, I want to get the original NURBS back as much as possible. That’s why some form of fitting came to mind

Constructing NURBS manually requires (sometimes many) curves so, that’s often plenty trial-and-error to minimize the visual discrepancy. That’s not super awesome–like doing ‘hard surface’ modeling in Blender (I’m sure there’s a simpler analogy here :joy:)

This actually seems like a solved problem in some tools. But it would still be super good to have in GH!

not exactly a polynomial regression in 3d space, but if you have a mesh, you could pass it to a quadremesh and pass that to a subd

you might also like to play around with shrinkwrap in R8

if you’re starting from a list of points, you could pass those to a delunay triangulation → quadremesh ->subd

otherwise, if you’d like to get a single polynomial surface, you can use any modern tool that calculates that regression (mathematica comes to mind right now) and you can probably reconstruct a nurbs approximation

1 Like

Thanks very much for your help Adel!

Quad remesh and shrinkwrap are both great tools, but they don’t guarantee a continuous surface

The Mathematica path sounds promising–I’ve ran into some cool equation-driven surfaces but nothing on the NURBS side yet.