Grasshopper

algorithmic modeling for Rhino

# Cross Reference; what is it, how does it work, why would I need it?

As of Grasshopper 0.9 components no longer offer a Cross Reference option in their pop-up menus. This feature was removed because I felt it was not flexible enough. Now, you can achieve Cross Reference matching with a dedicated component which creates combinations of items. You can find the [Cross Reference] component in the Sets.List panel.

When Grasshopper iterates over lists of items, it will match the first item in list A with the first item in list B. Then the second item in list A with the second item in list B and so on and so forth. Sometimes however you want all items in list A to combine with all items in list B, the [Cross Reference] component allows you to do this.

Here we have two input lists {A,B,C} and {X,Y,Z}. Normally Grasshopper would iterate over these lists and only consider the combinations {A,X}, {B,Y} and {C,Z}. There are however six more combinations that are not typically considered, to wit: {A,Y}, {A,Z}, {B,X}, {B,Z}, {C,X} and {C,Y}. As you can see the output of the [Cross Reference] component is such that all nine permutations are indeed present.

We can denote the behaviour of data cross referencing using a table. The rows represent the first list of items, the columns the second. If we create all possible permutations, the table will have a dot in every single cell, as every cell represents a unique combination of two source list indices:

Sometimes however you don't want all possible permutations. Sometimes you wish to exclude certain areas because they would result in meaningless or invalid computations. A common exclusion principle is to ignore all cells that are on the diagonal of the table. The image above shows a 'holistic' matching, whereas the 'diagonal' option (available from the [Cross Reference] component menu) has gaps for {0,0}, {1,1}, {2,2} and {3,3}:

If we apply this to our {A,B,C}, {X,Y,Z} example, we should expect to not see the combinations for {A,X}, {B,Y} and {C,Z}:

The rule that is applied to 'diagonal' matching is: "Skip all permutations where all items have the same list index". 'Coincident' matching is the same as 'diagonal' matching in the case of two input lists which is why I won't show an example of it here (since we are only dealing with 2-list examples), but the rule is subtly different: "Skip all permutations where any two items have the same list index".

The four remaining matching algorithms are all variations on the same theme. 'Lower triangle' matching applies the rule: "Skip all permutations where the index of an item is less than the index of the item in the next list", resulting in an empty triangle but with items on the diagonal.

'Lower triangle (strict)' matching goes one step further and also eliminates the items on the diagonal:

'Upper Triangle' and 'Upper Triangle (strict)' are mirror images of the previous two algorithms, resulting in empty triangles on the other side of the diagonal line:

Views: 42598

### Replies to This Discussion

The component looks amazing. Nice idea implementing all this functions and different combinations :)

Awesome, Thanks David.

Hi Yasser,

not like that, at least not yet. You can enter paths into a parameter Set Multiple... item:

--

David Rutten

david@mcneel.com

I see. Thank you

Hi David, i hope you can answer me this question...

How could you use this component to make this combination: AX, AY, AZ, BX, BY, BZ, CX, CY, CZ?

Remember to plug the graft at output B first.

PNG transparency not working properly?

That's the same as the first example Holistic

An alternative to String Join is Concatenate

I wanted to create a dot matrix which in the past Grasshopper version was too easy by clicking 'cross reference' on component's pop-up menu. I finally used f(x,y)= x+y with A and B outputs of cross reference component. Thank so much for your help guys.

Hi! David.

I have a problem, I want to build a surface from points generated by the parametric form but using cross references for every single parametric function, only describing the edge.

how I can fix that?

Thanks for help me

Lucibell

Hi Lucybell,

I think it's better if you post on the main forum and attach the file so people can see what you've got. More people will see it over there.

--

David Rutten

david@mcneel.com

• View All