Grasshopper

algorithmic modeling for Rhino

Hi fellow GrassHoppers.I'm having a little problem here. 
I'm willing to assing a series of events to a series of points, and I'd like this assignment to depend on a couple of conditions.
At the moment there are only four, in two pairs, that give four different scenarios.
I have managed to identify the two pairs in separate boolean streams, but my problem comes at the point of combining them.
I'd like to get a stream with the four different states (represented on the panel below) and then find the component (or combination of) that would allow me to assing one state to each point depending on their fullfilment of the different conditions.

In this example, lets say I'd like the x>0 and y>o point to have three sides, and make it change to four sides when I "manually" drag it under X axis so its y<0.

Don't know if I made myself clear, but thank you guys in advance.boolean%20switches.gh

Views: 2170

Attachments:

Replies to This Discussion

Miguel,

Boolean values are synonymous to 0s and 1s, so you can add the results of the conditional tests.  If you use Boolean values for testing, the scenario currently setup has 3 different results not 4.  To get 4 different results another test would need to be added or you have to use a different testing logic.

Hope this helps!

Attachments:

Hi David. Will look at your file as soon as I arrive at the office. Anyway, I'm having doubts on the number of results with two boolean conditions. My "guess" (quite illiterate on the topic) is the 4 possibilities are 00, 01, 10, 11. I even developed a truth table (I think that's the name) for it. My problem is I don't know how to elaborate the definition in GH... :(

Hi Miguel, here's my two cents. First option derived from your def, second one based on angles with the x-axis.

Attachments:

Darn! I can't properly look at your files (update problems on my laptop) but I guess the keysearch component gave me a new direction to look. Thx!

Would it help if I uploaded a screencapture of the definitions? I made these in 090056, but I didn't use any components that weren't available in 090014.
I think the second version is the more flexible way (you can easily adjust the number of 'regions'/pie-parts
by dividing the domain by sth else than 4).

Attachments:

Conditionals are not that straightforward to set in 'raw' GH. Another option is scripting a small C# component and nest your booleans:

private void RunScript(List<Point3d> P, List<int> sideCount, ref object S)
  {

    List<int> sides = new List<int>();

    foreach (Point3d p in P) {
      if (p.X <= 0) {
        if (p.Y <= 0) sides.Add(sideCount[2]);
        else  sides.Add(sideCount[1]);
      } else {
        if (p.Y <= 0) sides.Add(sideCount[3]);
        else  sides.Add(sideCount[0]);
      }
    }

    S = sides;

  }

And update! ;)

Attachments:

Thx Jose! But unluckily it doesn't solve my problem. Can't code at the level of translating your solution to my problem (which is much more complicated than adding polygons to points ;)) that relates to making some events happen in determinate circumstances. But again, thanks a lot.

Managed to do it. And, correct me if I'm wrong, I think is a somewhat "elegant" way...

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service