Grasshopper

algorithmic modeling for Rhino

Hi all,

I am wondering if anyone has any advice on the problem of finding pairs of closest points in a collection of points.

By this I mean, different from what Proximity2D does, for example, if there is a cloud of 100 points, there will be 50 pairs of points, with 50 lines that are not connected to one another; or in other words, each point is only "used" once.

Thanks a lot!

Views: 2312

Replies to This Discussion

Take one point.

Using  Rhino.Collections.Point3dList find the prox point (closest) and store both in a DataTree<Point3d> branch.

remove both points from the list and continue.

For instance

Attachments:

Hi Peter,

Thanks a lot!

I'll have to take some time to take a look into the code thoroughly, but it's looking great.

And the trad update that does ... er ... hmm ... "better" things (plus a Ducati promo: makes all the difference).

Attachments:

And given the opportunity ... the attached finds the closest pair between 2 point Lists. Useful in quite a few cases (for instance random trusses and the likes).

If user provides data then these are used ... if not an internal demo is on duty.

Attachments:

Thanks a lot, Peter, this is great!

Would you have any suggestion to do the closest pairs between the two lists? instead of only one single closest pair (for example, finding next closest pair until the smaller of the lists exhaust)?

Thanks again!

That's simply a case of a "bigger" loop that repeats (each previous one removes the point found per List) until the smaller List has no cookies to offer (for instance: if (!ListSmaller.Any()) break; or using a crude try{} catch{} combo or ... counting the beans etc etc).

Try it and if you hit the wall drop a word.

And this finds the closest pair using 3 Methods (ranging from ultra stupid to the classic divide and conquer).

BTW: This is the ultra stupid:

Attachments:

Peter's code is the best, but if you are looking for other ways not to use C#, then ,, this one is using "Anemone" plug-in.

Attachments:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service