Illustrating Mathematics with Grasshopper

I’m currently attending a week-long conference on “Illustrating Mathematics” at the Institute for Computational and Experimental Research in Mathematics (ICERM) at Brown University, in Providence, RI. I was asked to give a workshop here on using the Grasshopper plug-in for Rhino, and thought my talk would make a good blog post.

This is the first time I’ve written a tutorial type of post. I’ll try to say something useful for beginners and experts alike, but first I should say a bit about what Grasshopper is and who its for. Rhino is a popular 3D modeling program. I have the sense that it dominates the architecture world, but the majority of the artists and mathematicians I know who do a lot of  3D modeling also use it. Grasshopper is a free plug-in for Rhino written by David Rutten that allows one to build Rhino objects using a visual scripting “language.” Building these scripts involves dragging and dropping various boxes around a virtual canvas, and drawing lines between them. For example, in the image below I’ve created a circle in the Rhino window (shown on the left) by connecting a circle box to a slider at the “radius” input.

Screen Shot 2016-06-30 at 10.05.01 AM

A word of caution is in order for mac users. Since 2007 Grasshopper was only available for the PC version of Rhino. For a long time the Rhino folks were saying that a mac version was a long way off, if it were to ever happen at all. Then, out of the blue, just a few months ago they released a beta version available for the current mac Rhino3D WIP. It consistently crashes on my mac, but several people I know have been using it without any problems. Presumably it’ll get more stable over the next few months. In the meantime, I use Rhino/Grasshopper in a virtual PC environment on my mac.

It’s worth contrasting the use of Grasshopper to build objects vs building them with a traditional programming language like python, which is another option for Rhino users. Grasshopper has two huge advantages: The first is that Grasshopper doesn’t require you to learn how to code. Second, and more importantly, Grasshopper scripts are interactive. All variables in a grasshopper script can be realized by sliders, allowing the user to see how changes in parameter values effect shape in real-time. This is crucial for making aesthetic choices in object design.

Where Grasshopper really loses to more traditional programming is any place where recursion is required. Grasshopper is generally a poor choice for fractal designs, for example (although there are some third-party work-arounds that function reasonably well, such as Hoopsnake).

Fortunately, one doesn’t really have to choose between Grasshopper vs more traditional scripting (python, C#, VB). A Grasshopper box can be a user-defined python script, for example, with inputs that are realized by sliders. This gives you the best of both worlds: it simultaneously makes your python scripts interactive, and allows for “easy” recursion in  Grasshopper.

My idea for the workshop was to go through the design process that I used to create my re-usable coffee sleeve/bracelet/very-small-dog collar (available here on Shapeways).

It’s hard to see this in the pictures, but the curves in opposite directions are woven, reminiscent of the old “Chinese finger trap.” This allows it to form-fit to many cup shapes, and makes it fun to just play with. 3D-printing is the only technology I know of that can produce this design in plastic.

The woven aspect of the design was beyond the scope of a 45-minute workshop. At some point I’ll dedicate an entire blog post to various strategies to achieve a woven effect in Rhino/Grasshopper. Here I’ll just describe one way to make a shape, and create slanting curves on it in each direction. The construction I’ll give is not the most efficient way to do this, but it will illustrate a lot of the important concepts of Grasshopper design. First, examine the following image:

Screen Shot 2016-06-30 at 11.09.09 AM

From left to right: First you see a slider that will determine the eventual height of the object. This gets fed into a component that defines an interval of real numbers. That interval is then passed to a box that is set to choose 10 values in it. Those values are finally passed to the z-coordinate of a point (with the x- and y-coordinates being set to 0 by default). One important thing to note is that there is a double line connecting the third and fourth components, whereas the other components are connected by a single line. A single line represents a single piece of data being passed between components; the double line represents a list of data.

Screen Shot 2016-06-30 at 11.16.17 AM

Once the points are defined we feed them to a component that create horizontal planes centered at each point. Those planes are then given to a circle component to define a family of horizontal circles.

Screen Shot 2016-06-30 at 11.23.11 AM

After defining the circles, we choose 10 points on each. Those points then form a list-of-lists, represented by a dashed double line leaving the box. If we feed each of these lists of points in to a component that makes an interpolated curve through them, we just get the horizontal circles back. Compare that to the following:

Screen Shot 2016-06-30 at 11.26.51 AM

Here I’ve inserted a “flip matrix” box. This component re-organizes the data, creating a new list-of-lists. The first one is comprised of the first elements of all of the input lists, the second list is all of the second elements, etc. Now if we create curves through the points in these lists we get the vertical arcs shown at left.

Screen Shot 2016-06-30 at 11.31.52 AM

To make diagonal lines, we introduce a shift.  This is done with the introduction of two new boxes. The first just produces a list of integers between 0 and 9. Those are fed to a component that shifts each list of points. Note the little up-arrow by the word “shift” in the second component. That represents a “graft,” so that the first input list is shifted by 0, the second list shifted by 1, the third shifted by 2, etc. This sort of data-matching is the hardest thing to learn about when using Grasshopper.

One more thing is required to make the desired diagonal cross-crossing pattern. The reason the lines slope one way instead of the other is that we’ve shifted each list by +1. That’s controlled by the “step” input in to the “series” component shown above (the default value is 1). In the image below you see two copies of this collection of components. The lower copy is the same as before, while the upper copy uses a shift of -1. Together, you see that they give the desired effect.

Screen Shot 2016-06-30 at 11.38.44 AM

Finally, to make a 3D-printable object, we must thicken each curve into a tube. This is achieved with the “pipe” component, pictured below.

Screen Shot 2016-06-30 at 12.01.01 PM

Illustrating Mathematics with Grasshopper

Making Big Art with 3D Printing

As I’ve learned more about what people recognize as “fine art,” I’ve come to realize that there are inherent problems in using 3D printing for the direct production of art. I’m not talking about philosophical questions, like whether “real art” should have hand-built elements to it. In this post I’ll discuss more a more technical question: scale vs economics.

In Mathematics, scale is rarely part of the definition of an object. The Mathematical definition of “cube,” for example, makes no mention of how tall it is. However, there is a very real visceral difference in our experience of a physical cube when it is one inch tall, versus when it is ten feet tall. A lot of artwork plays on this. As my friend, Clare Graham would say, larger objects have a certain “gravitas.” An inflatable bunny that’s 10″ tall probably won’t be considered art. These HUGE bunnies by Amanda Parer are.

Scale is one of the biggest obstacles to producing art by 3D Printing.  Home printers top out at about 12″ in capacity, and won’t have the quality to make anything recognized as fine art. These days you’ll hear news articles about giant cement-extruding printers making houses, but someone like me doesn’t have access to that technology. There’s a company called Materialize that has a “Mammoth Stereolithography” machine, but they charge so much to use it that only the highest end artists and designers like Janne Kyttanen can charge enough for their artwork to justify this technology.

The best solution I’ve been able to come up with to the scale problem is to create  triangulated modular designs. I decided to try this to create a large version the seashell model I wrote about in this post.

The larger version I ended up making is about 5.5 feet long. It consists of 153 sticks and 59 nodes. Each stick is a different length and each node is unique. I wrote a grasshopper script to model each node and emboss numbers on them near each “socket,” so I knew which stick went into which node/socket.

Screen Shot 2016-06-10 at 11.54.56 AM

I then printed out a spreadsheet with all of the stick lengths, and hand-cut clear PVC pipes to those lengths with my chop-saw. As I cut them I wrote their number on each end with a marker that I could later wipe off. Then it was a matter of matching up the end of a stick with a particular number with the socket that had the same number, and gluing them together.

It took a few weeks of 3D printing nodes to get through all of them, a week for cutting and labeling PVC sticks, and another week or two to assemble and glue. Here’s the final piece.

1892177_orig

It came out ok, but not really “fine art” quality. I would have had to use more permanent materials than ABS plastic and PVC. The goal of the project was really to see if I could leverage the power of 3D-Printing and still make something of a decent size. I didn’t want to spend much, since I had no idea if any of it was going to work. I believe I spent less than $100 on materials.

I’m not sure this is a viable solution to the fine-art vs scale vs 3D-printing problem. If I were to really try to sell this as a piece of artwork I would have Shapeways print each node in steel and use some kind of metal tubing for the sticks. All connections would have to be welded or soldered instead of glued. Shapeways would charge me an average of $50 to print each steel node, so the printing cost alone could be as much as $3K. That much metal tubing could also be pricey, depending on its quality. And then there’s the fact that I’d either have to learn how to weld, or hire someone to do it for me. (I’m fine with soldering, but it might not be strong enough.) In a high-end gallery such a sculpture might sell for $10K, but as much as half that would go to the gallery. You can see that the numbers start to look dicey very fast.

If anyone reading this has any thoughts on the scale vs 3D-printing problem, please share in the comments!

Making Big Art with 3D Printing