Grasshopper

algorithmic modeling for Rhino

Circles on grid image sampler with only three to six different radius sizes

So I have this file that samples an image, nothing special there.

As in the tutorial I want to create circles on a grid based on the image sampler. Nothing special there as well. Now this creates a grid with circles that are mostly unique in radius. I want to have like 3 to 6 radius instead if a unique one for each circle. I can't seem to find out how i filter items in a list based on value and round them off to a certain number.

So I have values ranging from 0 to 1 (e.g. 0.128123451238) and i only want the radius values 0-0.33-0.66 and 1. 

Views: 1259

Replies to This Discussion

Something like this ?

Attachments:

Thanks for the effort.

I hope someone else finds it usefull as I came up with the solution myself a second after I posted it spending the whole morning grinding my gears on it. 

I did it like this now: see attachments.

In your file, it rounds both up and down as for example i want numbers lower than 0.165 to go to 0 where numbers between 0.165 and 0.5 round to 0.33 etc. Thanks for the effort anyways!

Attachments:

Hi Wouter,

 

there are several ways of doing this of course. If your target radii are easily represented by a mathematical progression (say 2.0, 3.5, 5.0, 6.5, 8.0) then you can use an expression to modify your unique radii. Something along the lines of:

RC = Int((RU - C0) / C1) * C1 + C0

 

Where RC is the constrained radius, RU the unique radius, C0 the first number in the series and C1 the step size:

 

 

Basically this is some form of advanced rounding not to whole numbers but numbers with specific intervals.

 

Another approach would be to define all allowed radii ahead of time and then find the most similar one in that list using the [Find Similar Member] component:

 

--

David Rutten

david@mcneel.com

Tirol, Austria

 

ps. Please don't close discussions. I could no longer post my original reply.

--

David Rutten

david@mcneel.com

Tirol, Austria

I'm sorry. Did not know it was not allowed.

I solved it by simply multiplying all values of the list by the amount of circle radius I want in the end, then rounding it off to integers and dividing back with the amount of radius again.

So if i want three sizes of radius, I multiply by three to get a range of numbers from 0 to 3, round the numbers with decimals off to integers, getting only values of 0,1,2 and 3 and dividing by 3 again to get values of 0- 0.33-0.66 and 1, which i wanted. I can increase the number of steps by dividing and multiplying with higher numbers. 

Thanks for your effort!

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