Grasshopper

algorithmic modeling for Rhino

Hi
Does anyone know how to perform Set operations in grasshopper. Understanding a list as a Set the following operations could be performed.

Union of the sets A and B, denoted AB, is the set of
all objects that are a member of A,
or B, or both. The union of {1, 2, 3} and {2, 3, 4}
is the set {1, 2, 3, 4}.
Intersection of the sets A and B, denoted AB, is the set of
all objects that are members of both A
and B. The intersection of {1, 2, 3} and {2, 3, 4}
is the set {2, 3}
set difference of U and A, denoted U \ A. The complement of {1,2,3}
relative to {2,3,4} is {4} , while, conversely, the complement of {2,3,4} relative to {1,2,3}
is {1}
Symmetric difference of sets A and B is the set of all objects that are a member of exactly one of A and B
(elements which are in one of the sets, but not in both). For instance,
for the sets {1,2,3} and {2,3,4} , the symmetric difference set is {1,4} . It is the set difference of the union and
the intersection, (AB) \ (A
B)
.
Cartesian product of A and B, denoted A × B, is the set
whose members are all possible ordered
pairs (a,b) where a is a member of A
and b is a member of B.
Power set of a set A is the set
whose members are all possible subsets of A.
For example, the power set of {1, 2} is { {}, {1}, {2}, {1,2} }

This is a link to Set theory explanation
http://en.wikipedia.org/wiki/Set_theory


Thanks

Views: 802

Replies to This Discussion

Hi Frane,

are you just talking numbers, or are these sets supposed to contain any kind of data?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David

In a few months I will start to teach math at an architecture faculty and I will use Grasshopper as the main tool to provide graphical explanations and practical examples. One of the subjects is Set theory, so for this purpose just numbers would be fine.
Nonetheless I have found situations in which I could use it for other data such as points or lines, so I think it would be useful to have these operations for any kind of data.
Integers and Strings are easy, floating point numbers (and thus points and geometry) might suffer from binary noise. I assume that when set A contains a value 1.69999999999997 and set B contains a value 1.7000000000001648 they were meant to be the same. But where do I draw the line?

Anyway, I'll see if I have some time to add few components. It sounds easy enough, especially if I restrict myself to numbers at first.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Maybe to solve the case of floating point numbers you can leave an input to set the tolerance.

Thanks
I don't know if there's an easier way but I just tried to perform a union an Intersection on two sets of numbers and got a result. See attached

I tried to generate a cull pattern from a cross referenced Equals component but due to the flat output I had to divide it up using domains to get the correct series.

The inverted Pattern will produce a set difference as well.

To create a Union you could combine the two lists and delete any duplicate points (Search this forum for a method)
Attachments:
Wow... that's amazing.
I tried to reproduce it myself but without luck... maybe it is because I don't really understand it... when I can I will try it again

Thanks
Hi Danny,

Could you post the definition? I too tried to recreate it but with no luck - I guess you've set some certain values to the components which we don't see in the screenshot.

Anyway, here's a simple one that works for sets containing unique (non-repeating) elements:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service