algorithmic modeling for Rhino

Data matching is a problem without a clean solution. It occurs when a component has access to differently sized inputs. Imagine a component which creates line segments between points. It will have two input parameters which both supply point coordinates (Stream A and Stream B). It is irrelevant where these parameters collect their data from, a component cannot "see" beyond its in- and output parameters:

As you can see there are different ways in which we can draw lines between these sets of points. The Grasshopper plugin currently supports three matching algorithms, but many more are possible. The simplest way is to connect the inputs one-on-one until one of the streams runs dry. This is called the "Shortest List" algorithm:

the "Longest List" algorithm keeps connecting inputs until all streams run dry, this is the default behaviour for components:

Finally, the "Cross Reference" method makes all possible connections:

This is potentially dangerous since the amount of output can be humongous. The problem becomes more intricate as more input parameters are involved and when the volatile data inheritance starts to multiply data, but the logic remains the same.

Imagine we have a point component which inherits its x, y and z values from remote parameters which contain the following data:

X coordinate: {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0}

Y coordinate: {0.0, 1.0, 2.0, 3.0, 4.0}

Z coordinate: {0.0, 1.0}

If we combine this data in the "Shortest List" fashion, we get only two points since the "Z coordinate" contains only two values. Since this is the shortest list it defines the extent of the solution:

The "Longest List" algorithm will create ten points, recycling the highest possible values of the Y and Z streams:

"Cross Reference" will connect all values in X with all values in Y and Z, thus resulting in 10×5×2 = a hundred points:

Every component can be set to obey one of these rules (the setting is available in the menu).

Note the one big exception to this behaviour. Some components EXPECT to get a list of data in one or more of their input fields. The polyline component for example creates a polyline curve through an array of input points. More points in the input parameter will result in a longer polyline, not in more polylines. Input parameters which are expected to yield more than one value are called List Parameters and they are ignored during data matching.

For sample files, go here...

Views: 2842


You need to be a member of Grasshopper to add comments!

Join Grasshopper

Comment by deli dumrul on October 29, 2015 at 8:06am

hi, i am trying cross reference but there is two input only, so i can not connect z with anything. can you explain that?

Comment by cmrhm on May 19, 2010 at 9:11am
People have difficulties to explain this concept. Thanks for the good work.


Search Grasshopper


  • Add Photos
  • View All

© 2017   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service