Grasshopper

algorithmic modeling for Rhino

hi,

i thought i understand trees completely, but, awkwardly, it seems i don't.

i already solved my problem but i would like to understand.

problem:
i want to find the closest, non similar point to teach point in each branch of a tree. i only want to search within the same branch.

intuitive solution:

1. create branches of points (for that i only subdivided some curves) {a}(n)

2. graft {a;n}(1)

3. measure distance between {a;n}(1) and {a}(n). i expected this to happen for each {a} separately (this would happen if i only had a single list of points at the beginning). resulting distances will have a structure {a;n}(n)

4. sort distances and also sort the original structure {a}(n) accordingly.

but this doesn't work. somewhere in the points 3. or 4. i have a logical mistake. why doesn't the data matching work the way i expect? where did i make a mistake in my thinking?

my solution to this was following, though i believe there must be a more elegant way:

thanks!

Views: 624

Replies to This Discussion

The easiest way to do this would be with the Proximity 3D component:

Can you post the file that you thought would work but didn't?

--

David Rutten

david@mcneel.com

Attachments:

thanks, David. your solution is elegant. but let me ask a more general question:

why does this work for a single branch (the top CRV is the top curve, the bottom CRV is the bottom curve)

and not for more branches on the top level of the hierarchy (the top two curves are in the top CRV, the two bottom curves are in the bottom CRV)

or in other words- how can i treat top-level branches as separate lists?

in fact i would rather know why than how.

It's because gh doesn't recognize that the "a" from {a} is supposed to match the "a" from {a;b}. As soon as you introduce mismatched data structure (as in your graft) gh doesn't identify shared path indices for guiding comparison, and as you can see in your second image, it simply orders the less complex data structure as a flat list in its comparison with the grafted data.

This problem was actually one of the primary reasons I made Tree Sloth last year...for a number of detailing projects I worked on, it constantly came up that I had what I called "ancestral" data that I wanted to match to "offspring" for comparisons. I got sick of shifting lists, counting, duplicating...so I wrote a component called "Propagate Ancestors" which basically allows for you to duplicate objects of less complex path structure such that they match your objects with more complex structure. It's over in Milkbox if you want it...has a few other useful data structure components in it as well (for example, the "List Compare" component would also help you out for the problem you first describe above)... http://www.grasshopper3d.com/group/milkbox/forum/topics/tree-sloth

yes, thank you! that is it.

"propagating ancestors" manually was also my solution. your components are much better though. kudos!

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service