Grasshopper

algorithmic modeling for Rhino

3 questions: lower integer, positive numbers, single-out grid item

HI All,


Still relatively new with Grasshopper here, but loving every minute of it and what it's empowering me to do. I have some basic questions that hopefully you guys can help:


1. make into *lower* integer:

if I have three numbers, example:  3.36, 4.30, 6.87 applying an Integer filter will give me as result: 3, 4, 7. Instead I want the lowest of the two closest integers to the. In this case: 3, 4, 6. 


2. make into positive numbers: 

If I have a single number or a list of numbers such as "3.5, -1.2,  4, -5" I'd like to turn it into: "3.5, 1.2, 4, 5"


3. Single out specified item from grid:

If I have a grid of say 5 rows in U by 4 columns in V, like this:


ooooo

ooooo

ooooo

ooooo


I'd like to extract from the list:

3A: the first item such as this (replaced with the x):


ooooo

ooooo

ooooo

xoooo


using the filter for 1st item gives me this [undesired] result (replaced with the x):


ooooo

ooooo

ooooo

xxxxx


3B: Then I'd like to say, give me first item of last row (replaced with the x):


xoooo

ooooo

ooooo

ooooo


I'd appreciate any help with these questions.


Gustavo

Views: 1402

Replies to This Discussion

Gustavo, for item # 2 can you use the function ABS = Absolute value... ABS ( -1.2 ) = 1.2 ok

I do not understand # 1, some times I like to use this:

Add to the number 0.5, sample: 4.3 + 0.5 would give me 4.7 then, I get the int ( 4.7) = 4 ok, but if I have 4.6 + 0.5 = 5.1 and then, int ( 5.1 ) = 5

Hope this helps!

How is Boston? We are frozen here in Miami, like 52 :-)
Hey! Mi Profesor Don Andrés!

Thanks for the tips. I do not see the same results you do with #1. Integer always rounds to the closest whole number, in the case of 4.7 it would be 5 (not what I want). In the case of 5.2 it would give me 5 (that's good). I got it to work with this 'chapuza':


#2: Thanks for the Abs tip. Believe it or not I have not been using functions yet, so now I just re-learned how to do it. Thanks!

#3. This is hard one to explain. I'll make a video later and re-post.

Boston is like always on the daylight-savings day: it makes me think real hard why on Earth do I still live here when another winter is coming :)

Totally unrelated, I have a feeling that we'll need some Grasshopper re-fresh/level II course sometimes around February or so ;)
for #1 use the Floor() function...
There are two common ways to round the nearest integer than is smaller than or equal to your value. You can use an F(x) component and apply the Floor() function on your number or you can subtract 0.5 from the value and then round normally.

--
David Rutten
david@mcneel.com
Seattle, WA
ahh! The Floor function is what I needed, thanks Luis and David. And David you simple solution of subtracting .5 to anything would always work without knowing more functions! But that's the type of stuff that separates your from the rest of us :)
now I'm trying an alternative to #3 that will solve my original issue plus the next issue that came up. So here it goes my next question:

I want to end up with a symmetrical-looking array from top to bottom, and I just realized that a staggered-pair on the hex grid is a single line, and not two lines as I originally thought. This is my challenge now:


Any ideas of how to endup with my original list of point except the ones that I culled?

Thanks!
If you know the integers of the items you've culled then you can apply these to a cull index component on the original list. Or on the cull pattern component there is an invert option for the pattern.
Hi Danny,

Thanks for that help. If I understood correctly, and nothing blows up, I think I have it working now...

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