Grasshopper

generative modeling for Rhino

# average curve through points

Hello!

I am sure I saw this before but can't manage to find it now:

I have a series o points, unordered. How could I get a curve which which passes through an average of all points?

Same as what happens in this graph:

http://www.amication.de/Bernhards_Comet_Project/images/240p_comet_l...

meaning, the curve does not have to connect all points...

any hints?

Thanks!
D.

Views: 468

### Replies to This Discussion

Hi Daniel,

Grasshopper has algorithms for fitting lines and circles through points, but just 'a curve' is an underdefined problem. Is this curve representable by a function (parabola, hyperbola, goniometric?). Is it a nurbs curve? If so, how many control-points and what degree? Is it allowed to move freely in space or should it only have a single y for every x?

If your data is highly structured then it's possible to write a customized fitter. But you're going to have to provide a heck of a lot more information before anyone can tackle this problem.

--

David Rutten

david@mcneel.com

Hi David!

Thanks for the answer... indeed, too little information!

Here are some images of my "problem"... I have these curves:

Which are actually closed polylines when looked up close:

And the goal is to "convert" each one of them into a single curve...

The problem is that the points in each curve are indeed not ordered. I tried to sort points, draw a polyline through them and then fit another curve using the fit curve component... it works ok with the polylines which go from left to right, but once they make a curve or are vertically oriented it is obviously a mess...

Any ideas of how to approach this?

Thanks!!!

Daniel

PS: this is just a portion of my image, there are many more lines than this!

Interesting problem. In pixel-land what you'd be looking for is a thinning algorithm. I've been trying some simple VB algorithms to try and find a center spline, but none of them work consistently. I might not be able to help out here, especially since I have to catch a train today and I've yet to start packing...

I attached my most successful attempt, but it fails miserably on other curves I try.

The 'Width' parameter is an indication of how thick the curve is expected to be btw. It needs to be set manually.

--

David Rutten

david@mcneel.com

Attachments:

Hi Daniel,

i am here on a mac so i cant even see, what David posted, but maybe this discussion could also help:

http://www.grasshopper3d.com/group/coffee-and-grasshopper/forum/top...

Best,

Phillip

• View All