Grasshopper

algorithmic modeling for Rhino

Hello, I'm relatively new to the hole Grasshopper world but so far this forum as been much helpful in learning bits of Grasshopper by myself.

I'm working on a small project right now and I need to create a distribution of values which is probably super simple to do but I can't find a solution by myself.

Basically, I want to create a range of numbers that go from 6 to 26 with 24 steps. I can do this with the Range component but I also need to add a condition. In this case, I want the sum of those numbers to be equal to a specific number.

Anybody would have a solution to suggest?

Thanks!

Vincent

Views: 483

Replies to This Discussion

This def gives you a series of numbers starting at 6, ending at 26 and with 24 steps (i.e. 25 numbers in total)

The sum is 400.

If you wanted to change the sum to equal another number you could work out the difference between the target and 400 and subtract this from the numbers in the series that are between 6 and 26 but you need to think about how exactly you will do this... you can't just divide the difference by 23 and take this from each number as it would make some numbers less than 6.

Attachments:

Forget that ^^^

This sort of does what you want but it will only work for certain target values.

It spreads the difference between 400 and the target value over 23 values and deducts or adds them to the range of numbers.

No doubt you could spread this across the range in a distributed way.

see if the file attaches this time...

Attachments:

Hi Martin, 

Thanks for your answer. I see what you mean. It's not exactly what I want to do but it makes me think that the step count is not that important. I don't know if it would help to make this parameter a variable.

For instance: how many steps do I need inside a domain from 6 to 26 so that the sum of the numbers will equal 400.

I think you also need to decide on whether you want constant steps or not so when you graph the values you get a straight line or a curve.

There is probably some clever maths that will do this too but I'm not that clever!

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service