Closest point | two lists of points

Hi
i have two lists of points. and i would like to connect them with the closest point. I now have two lists with each 144 items. I managed here with anemone. I looped it and it works.
the issue is that this takes forever if i have large datasets.

The lists i actually want to work on are 3600 long. and it doesn’t work anymore.
Does somebody have another idea how I could do this? :blush::yum:

Here is what i got so far:

closest point - two lists of points.gh (15.2 KB)

thanks :smiley:
chris

Isn’t this all you need?

closest point - two lists of points2.gh (14.0 KB)

1 Like

For say 3500 pts vs 3500 pts you’ll need about 80 millisecons. Notify if you need a C# that does that.

1 Like

haha fail on my side. jup thats what I need

Hi yeah that would be great. I just tried the pull component. but it almost takes 2 sec for that many points (although 2 sec is so much better than the 2 hours i waited before with my loop shit ^^). but since it is part of a larger script 80 ms would be better :rofl:

thanks

Here’s the Dark Side (the only Side, mind) in action.

closest_pair_between_2Lists_V1.gh (120.0 KB)

If you don’t provide data it does a demo for you that is very fast (with regard the random points) because they are not “even” random points.

PS: 80 ms using an I9 (and/or a Ryzen with a name that I can’t recall).

1 Like

Must be something with me (blame Vodka maybe).

This is the thing (4000 pts VS 4000 pts = 0.4 ms, meaning ~200 times faster). Recycle that naive/ultra stupid/pointless V1 and use this (play with the loops slider as well):

closest_pair_between_2Lists_V2.gh (123.2 KB)

is there also a way of not just outputting one pair? but lets say if there are 3600pts and 3600pts -> getting 3600 pairs?

Imagine 2 nested loops:

The inner does the job in, say, 0.4 ms using all pts (list1) VS all pts (list2).
The outer does it again by removing pair’s item1 from list1 and item2 from list2.

This however would take considerably more than 0.4 ms (hard to predict how much mind … but for big n of pts expect maybe more than 1000 ms).

Found some minutes to make what you want … but Lila (the girl with the mental stability issues) said that the logic is LOL: since the outer loop works always against the 2 lists minus the previous pair … this means that the resulting pairs are not in fact the “sorted” ones. I said: indeed but who’s gonna notice that? he, he.

closest_pair_between_2Lists_V3.gh (124.9 KB)

1 Like

thanks peter