Grasshopper

algorithmic modeling for Rhino

Hi all! I'm new to grasshopper, so maybe this is a very basic problem. But I hope somebody here can help me.

I have two lists with points (list A an list B). I want to compare these two lists in such a way that I get only the points that are in both lists. In other words, I want to know which points that list A and list B have in common. Is there a logic operator (or something else) for that?

thx in advance

Views: 3986

Replies to This Discussion

Here is a way to do it completely in Grasshopper without VB script components.
Image
Attachments:
Here's another way that's slightly more exact... Extract the x,y, and z components of each list. Set up some expressions that compare each component from each list and see if they equal each other (cross reference...also make sure that ). Then, using a Gate And Ternary component (which compares 3 boolean values instead of two), find which indicies are actually coincident. After creating a series component that's the length of the cross referenced list to represent the index numbers, use the Dispatch component with the result from the Gate And... component. Now we divide that number that come out of the dispatch component by the by the length of one of the lists (doesn't matter which one) and then grab the whole number part of the result(this needs to be done in a separate component). Then plug those numbers into the Index into a List Item component and make sure the List that you're extracting those from is the opposite list that you used for the division. See, wasn't that easy ;)

Sometimes, the points may not be right on top of each other in regards to the number of decimal places that a double will go to. So if you're looking for a little "wiggle room" in the point comparison, use the Round function with a few decimal places (3 or 4 is good) to keep the "noise" at the tail end of the doubles from getting in the way.
Attachments:
Thanks for the better method Damien.
If you graft one of the lists first, you get the same result with just one Cull Pattern component:

Thank you for the delivered solutions.

I had the same Problem. I wanted to compare a List of Lines and only get the non-Equals. But I found it was very complicate to construct a solution with the existing Methods. So I made my own, it works with Lines and Points. Curves didn't work yet and I didn't had the time yet, to find out how to get Equals of Curves in C#-Grasshopper-Components. Feel free to use it and if anyone have an idea, about how to compare Curves in a C#-Component, I would be interested.

Attachments:

Comparing lines and curves is a whole different ball game than comparing points, which can be done easily using 'Set Intersection'.  To demonstrate, I created a 'Integer Points' cluster that creates random 3D points where X, Y and Z are all integer values, increasing the likelihood of duplicate points, in blue.  'ExDiff (Set Difference)' returns the points NOT common to both lists, in yellow:

Attachments:

I mean I don't wanted to split the Properties of a Point, Line or Curve into Primitive Types. And Lines and Points can be compared very easy, like in the image below. But a Curve can't be easily compared in the way I did with Points and Lines, I think it's because they're having too much Properties.

Attachments:

So you have two components?  One for points ('DP') and one for lines ('DL')?

Again, for comparing points, I see no need to go beyond standard GH set components.  Here is the same code as before, clustered to look like your 'DP':

Inside the 'CPL' cluster:

Attachments:

Ok you can do that, but I wanted to compare Lines, that won't work. And even for Points I have one Button instead of four.

Yes, my mistake. I see there is no split of Properties in your Solution for Points.

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