Grasshopper

algorithmic modeling for Rhino

Sort similar vectors inside different branches

Hi,

I have a tree with four branches, inside each branch there are four vectors. These four branches contain almost the same four vectors (they are not exactly the same but they are very similar from one branch to another).

I need to sort the four vectors in each branch so that the similar ones have the same rank in the branch (as an example, I wrote a rank they could have if they were sorted out the way I need them to be).

Do you know how I could manage to do this?

Thanks,

Views: 916

Attachments:

Replies to This Discussion

Are these similarities easily encoded using a single number? For example Length or XY angle or Angle from unit Z? If so, I'd compute these numbers for all vectors, then use Sort with those numbers as keys.

If they aren't and if you really want to order all vectors in all higher branches according to their similarity with the first branch, some other approach will be needed. I suspect treating the vectors as points and using Closest Point is the way forward.

Attachments:

Thank you David, it worked well using a single number. I unitized the vectors and used the X parameter as a key and it was enough to sort them this time.

Your solution with closest point will be useful to me in the next part of my GH : I need to compare the 4 vectors of each branch with many others and dispatch the list of the many others in four lists (each one corresponding to one of the four vectors). Until now I was splitting the four vector and use dispatch for each of the four comparisons, but I think I can be more effective with Closest Point.

Thanks again!

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