## Graph Mapper – Example 2.4

This is a simple script to introduce a tool in Grasshopper that has some uses, but which I myself haven’t used that much. It takes a graph to remap values (Hence GraphMapper) using some mathematical functions (e.g. sine curves, parabolas, etc…) While it is good for playing around, I don’t find it *too* useful since I’m generally not interested in expressing pure mathematical functions in design, and when I do I usually use the expression command. But it has its uses, although it can be a bit tricky to set up.

**Step One **– Setup a grid of points. This time I did it similarly to Example 1.3 so by changing the way you graft the X and Y points, the direction of the graph effect changes. Examples in the first row below have the points grafted in the X direction, while examples in the second row have the exact same settings but the points grafted in the Y direction. You could also do this with a rectangular grid of points and using the “Flip Matrix” component to change the orientation of the effect. Note one other thing I did, if you want to move the grid around in space, you can draw a reference point in space and use this to start the series deconstructing the X and Y values of the referenced point per the script image.

**Step Two – **Draw the circles and setup an initial size. Here I have a function to link the circle size to grid spacing so I don’t have to worry about changing the base circle size if I change the spacing. It is usually a good idea to have as few input parameters as possible and I don’t want to have to readjust both the Grid spacing *and* the base circle size every time.

**Step Three **– Now to setup the graph mapper. This can be tricky sometimes, but generally it needs a Range input (not to confuse with domain or series) The range, then confusingly has a domain. In this case the Domain will be numbers between 0 and 1. Range outputs a list of numbers similar to a series, but this time the Range of numbers is evenly spaced through the domain. Another thing with range is you often need to setup an expression in the N input (N-1; right click and choose the Expression command and type in N-1) because it will give you otherwise one more number than you need, and the last series of circles will be scaled twice.

So graph mapper takes this range and maps the series of numbers between 0 and 1 based on the graph. With the parabola example show in the screenshot, the numbers towards the middle of the range will be closer to 1 while the numbers at the end of the range will be closer to 1. You can later change these graphs to sine curves, bezier curves, perlin noise curves….

One more step, since I don’t want anything scaled by zero I remapped the range into a domain between .34 and 1.0. On second thought, I probably could have just input this into the domain at the beginning…. sigh…

**Step Four** – Scale the circles

Below are a few examples of possible output. The first row are various frequencies of sine curves. The first and second row have identical graphs, but I changed the way the two X and Y series are grafted together. The last row has a perlin noise curve and some exponential curves.

And here is a screenshot of the script…