Grasshopper

algorithmic modeling for Rhino

I am using a random component to generate a series of numbers between 0 and 1. Is there a way to apply a 'rule' so to say, that tells the random component to not make any numbers closer together than say, .05?

Would I be right in guessing that if such a function exists, it would be found in the logic tab?

Trying some things out right now, but haven't made much progress. Any advice would be great.

Thanks,
N

Views: 7660

Replies to This Discussion

there's the "distance" function within the expression designer.. it can measure the distance between numbers. perhaps you can split the number stream into "A" and "B" streams, compare the distance, generate a boolean statement true/false if x<=0.5, merge them again and use the boolean output to drive a cull pattern - but then the whole thing would need to loop back, as who knows whether the next number doesn't also edge closer than 0.5?!

I'd still start this way, tho.... ;P
I think I need to hit the textbook(s) to figure out what you mean by the above. But thank you!

I suppose for now I can just add more random seeds and pick the ones I like, but I'm hoping to have a generator that can output variations of the design on it's own. In due time!
You would need to sort your numbers and then take the difference between each pair of adjacent values on the sorted list. Then determine a rule to cull the numbers that produce a difference smaller than your test parameter.

0.3
0.18 : difference = 0.12 < 0.05 : False
0.15 : diff = 0.03 < 0.05 : True : Cull this value
0.09 : diff = 0.06 < 0.05 : False

There is no Random parameter to specify the distribution of values, otherwise the values wouldn't be random.
another alternative perhaps is to generate your random values first by limiting to integers only, so you know for sure that your minimum difference between any 2 numbers is 1.

Since you need it to be 0.05, you can then divide all values by 20 (1/20 = 0.05), so you can make sure that the difference between the values is atleast 0.05.
here is what I described........... at first glance it seems to do what you want... test it tho!! my mind is wandering after a day of this, so no guarantees.... ;D

ya I think it reflects what taz wrote, too, which is a good sign ;)

edit: the final list comes out of the last "cull"
Attachments:
Thank you, I will have a look at the file -- would love to learn what you described. I'll test it out!

Suryansh: Thank you, I managed to get that method to work for me.
cool, let me know how it goes!

I'll have to try out Suryansh' version, too - it's so super cool having many (hopeful!!) solutions to problems, am always learning so much!
So true, this is an amazing community!

I seem to have hit a block at the 'duplicate data' component in your example. It is not showing any output.

The only personal setback I have found with Suryash's method thus far (and yours too I would imagine) is the fact that it sometimes will create duplicate numbers in the range.
Maybe what you want is a series {0.0, 0.5, 1.0, 1.5, . . . } that is then "jittered" using the jitter component {1.0, 0.5, 3.5, 0.0, . . .} and then culled with a certain number of culls in a random pattern {T, F, F, T, F, T, F, F, . . .}.

It sounds like you want a pretty specific kind of randomness. you might want to spend some time exploring combinations of random, jitter, series, range, cull, and dispatch.
Interesting point, thanks for the suggestion. I will read up and experiment with the jitter function, sounds promising.
ah, just tried it on another machine.. you have to set the multi-dimensional slider X domain to a higher "to" value... i.e. 0.0 To 50.0!

the "Y" value modifies the random seed!

And also, I noticed that through the duplicate, the definition simply removes all value pairs that don't work, hence there's no "looping" as I would have feared in my first post.

But so true, Benjamin's idea is pretty cool. Another one to ad ;D
thanks so much!
hello! this discussion accompanies something i am trying to do, but i can't download the file. can someone tell me how to do it? (i tried "save target as"....got unreadable file), then straight downloading got me a pile of HTML>

please help! thanks! or if you have a .jpg of this definition.....

cathryn

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service