Grasshopper

algorithmic modeling for Rhino

Dear all,

An input data will be a value from a list of integers 1 to 20.

when the data value between [1,5], then output is '1'

[6-10], output '2'

[11-15], output '3'

...

How to define this in grasshopper?

Thank you all.

Views: 1551

Replies to This Discussion

Oops. Back in a minute.

Attachments:

Like this?

Brilliant.  I knew there had to be a simpler way.  I don't think it fully answers original question though.  There still needs to be some spaghetti.

Simple mathematics (see Reino):

input = i

Round (i / 5)  

Obviously round UP to the nearest integer. Done.

This is actually a very simple but very useful function to understand in programming if you were to ever get into it. Notice by changing the divisor you will affect the repetition cycle of your number sequence. Rounding down ('Floor' integer divide, vs 'Ceiling' as you need) has the same effect.

Beauty in the maths, not spaghetti. Also super efficient way of getting results from any computer system - avoid conditionals at all costs.

Thanks for explaining in detail.  Very instructive.

Hi, I am number 9. nice to see you again.

This is better.

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