Basic tree issue

Fellow Rhinostrians,

I’ve got a data tree issue trat would seem super simple to solve, but somehow I still can’t figure it out. I’ve got two sets of points, and want to match the points in one set to the two corresponding points in the other set, without flattening the existing tree structure. Matching is to be done by distance, so i would like the two points closest 3.07 units from the original point. The branching of both data trees is the same, just the number of items in each branch is different.

I thought it should just be a matter of doing a holistic cross-reference and grafting one of the inputs, but that seems to trigger all kinds of cross-branch connecting that i don’t want. What would be the most straightforward solution here? (18.8 KB)

Like this with matching pairs closer than 3.07 units?

Or would you want just the lines which are 3.07 units long? (19.9 KB)

Hi Martin,

Matching pairs would be best, so for each point in B constructing a new branch containing two points from A, or line segments to those points. Ideally without flattening, since I’d like to use this on a large dataset.

All lines with a length below 3.07 or exactly 3.07 (3.069)?

Exactly two lines per point, the two lines closest in length to 3.07. There shouldn’t be any duplicates in the set, but the exact length might be off by a bit. So if there aren’t two points with a distance of 3.07, then 2.8 or 3.5 might do as well. (24.6 KB)

Thanks Martin, that works!

However, my real question is, do you see any option to make this work without flattening the A input first? I would like it to keep working when i use 200.000 points instead of 200, and I’m a bit worried this would get exponentially more complex for larger datasets.

This is an issue i still run into from time to time. It seems like keeping branches isolated from each other when manipulating data should be relatively easy, if not using standard grasshopper components than at least using a plugin. However, it’s not easy for me in practice, and maybe its a lot more complex than it seems…

Actually flattening is not necessary if we don’t graft the P input.

PS: there are duplicate points in point set A (22.3 KB)

You are absolutely correct, its just a matter of not grafting the P input! Thanks for your help!

1 Like

Thanks Bert. If the problem is solved, please click the Solution button