Grasshopper

algorithmic modeling for Rhino

Number of different items in a list within a tolerance

If we have a simple list of n floats, in this case for example 7 items {1.0, 1.1, 1.2, 2.0, 2.1, 3.0, 3.5}

The number of different items within a tolerance of 0.1 is 5 since

{ (1.0, 1.1), 1.2, (2.0, 2.1), 3.0, 3.5}

The number of different items within a tolerance of 0.5 is 3 since

{ (1.0, 1.1, 1.2), (2.0, 2.1), (3.0, 3.5) }

Can we achieve this in gh? using sets? without using python component.

Views: 917

Replies to This Discussion

Maybe this?

Attachments:

Thanks Daniel, that's a nice way around!

Only issue is: if tolerance is 0.1 say, the number of different items should be 4; 0.1 and 0.2 should be taken as one but 0.3 should be classed as a different item as it can not be clubbed with 0.1. The 0.2 will go inside the 0.1 cluster but 0.3 need to create its own cluster or type.

In case of points it works but in case of data its slightly different may be. Are we missing anything here?

What is your rule then that .3 should be out. being .3 is .1 away from .2. Should it be that .2 is copied to go with .1 and .3. or if .3 should be alone then the rule is that it is within tolerance in descending order. Or is it that all numbers in a group must be within a tolerance form every other number in that group and ones only in tolerance of some in that group form some misfit group?

Since .2 is clubbing with .1 it forms a set, for example. It can be that .1 is a set and .2 and .3 is another set. But the main things is that the difference between numbers in any set should not be more than the tolerance.

Hi there,

i have a C# component. maybe you can try to translate it into GH logic. My solution is a temp list to store the right items. For this kind of problems i allways use C# scripted components. I need just two for loops and i have a solution. I know, in this maneer you will never learn GH... but however it works

Cheers,

R

Attachments:

Hi Raul, Is this a bug? within one set the numbers vary a lot.

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