Modeling the paper Mobius Band

At some point, perhaps in grade school, most people encounter the Mobius band: a simple shape made from a rectangular strip of paper by giving one end a half-twist before looping it around and gluing it to the other. The resulting surface has many interesting properties, both aesthetic and mathematical. Perhaps the most famous artistic image of it is from MC Escher:

Last September I was contacted by someone interested in 3D printing a steel Mobius band. I said “no problem” and within a few minutes had written down an explicit parameterization (set of equations) and had one modeled. When I sent this to the client, he was unhappy. The band I had modeled was mathematically a Mobius band, but not the one you’d get if you made it out of paper. It was stretched in various places, which paper just won’t do without tearing. Here’s an image of the one I made, with the image of a gum wrapper added to it so you can see the stretching.

Once I understood the problem, I realized just how non-trivial it is. In fact, after asking lots of mathematicians, I now believe that it’s unknown how to explicitly find a parameterization for a Mobius band that you’d get from a strip of paper. Here’s a more general problem: Given a 3D curve in space, what shape would a rectangular strip of paper take on if it was bent so the line down its center followed the curve? (For the mathematicians: obvious conditions, such as having Gaussian curvature zero, or being a ruled surface, are not sufficient.)

To satisfy the client, I just virtually “hand”-modeled something that looked close to photos of a paper model. Here was the resulting piece, 3D printed in steel by Shapeways.

I didn’t think much more about this problem until about a month ago, when I was contacted by an artist who wanted to 3D-print various surfaces with a uniform grid of holes, to sew beads on. I realized immediately that the uniformity of the grid forced the kinds of surfaces she was interested to be those that could be made by bending a rectangular strip of paper!

This time I had more tools at my disposal. I’m now much more familiar with Kangaroo, a program for simulating objects endowed with physical properties. Kangaroo is a freely available extension of Grasshopper, a plug-in for Rhino 3D. (Rhino is a popular CAD package used primarily by architects, jewelry designers, artists and many of those mathematicians I know who do any 3D modeling.)

The way one works with Kangaroo is to define a set of geometric objects, and assign various forces to them. Those forces can be internal (e.g. turning line segments of the model into springs) or external (e.g. simulated gravity). After some internet searching I knew Kangaroo could be useful for the paper bending problem. Back in 2011 Marten Nettelbladt posted some videos with similar Kangaroo experiments. In particular, in this video he sets the positions of each end of the strip in space, and the program finds the position of the rest of it.  However, he doesn’t post his GH script there, and I was a little stuck figuring it out on my own (it turned out that was because I was trying to do it with Kangaroo2, when its much easier with the older Kangaroo.)

I then came across this discussion in the Grasshopper forum in which Daniel Gonzales Abalde shares a script that is very similar to what I was looking for. In that script he simulates the drooping of a sheet of paper with user-determined corner points. The key to making it work is the following:

  1. Triangulate the “paper” surface with a triangular grid of (roughly) equilateral triangles.
  2. For each internal edge, apply a relatively weak  “hinge force” to keep the adjacent triangles in roughly the same plane. This is what makes the extrinsic geometry similar to physical paper.
  3. Apply a strong spring force along each edge of the triangulation, with each spring having equal rest-length, to preserve the intrinsic geometry of the object.

The first step turned out to be the hardest, since there was no uniform triangular grid component in Grasshopper, or any of the zillions of plug-ins I have installed. But Gonzales’ post had some hints how to do this, and soon I was able to define such grids on cylinders and Mobius bands.

My first test was to try it out on a surface where I definitely knew the answer. The idea was to begin with a planar annulus (washer-shaped surface) and apply Kangaroo forces that would turn it in to something one could make from a rectangular strip of paper. If it worked, I knew I’d end up with a round cylinder. Once again, the graphic that is imprinted on the surface is there so you can see the internal distortion (stretching) of the surface initially, and how that distortion goes away in the final conformation.

 

When I was sure it worked, I moved on to the Mobius Band. The final frame in this video is precisely the Mobius band shape I had been after since last September: its the shape of a Mobius band made from a rectangular strip of paper.

 

Next, for fun, it only took a few seconds to change the initial definition of my object so that the Mobius band was made with three half-twists, instead of one (technically, its a Mobius band if it is made with any odd number of half-twists.) The resulting surface was precisely one of the ones the bead artist I’ve been working with was interested in.

You’ll notice in this video that the surface passes through itself before settling down on a stable configuration. While it’s possible to set up Kangaroo objects that avoid self-intersection, I didn’t bother. That actually led to an interesting experiment. In this final video I tried to find a paper-configuration of the 5-twisted Mobius band, but it just passed through itself and ended up identical to the singly-twisted band. While that’s not the effect I wanted, I  still think it’s interesting to watch.

For those interested, here’s what the GH script looks like. Once I understood how to do it, most of the work went in to the cluster on the left, where I set up a Mobius band with a triangular mesh. The script itself is posted here.

Finally, since my book is still very new, I can’t resist ending this post without some gratuitous advertising with this graphic provided by my publisher…

Modeling the paper Mobius Band

My New Grasshopper book is out!

In the next few posts I’ll briefly pause my discussion of organic modeling techniques, but I will come back to that soon (next up in the series will be on Diffusion Limited Aggregation… very cool stuff!).

Today’s post is simply a brief announcement, just in case anyone missed all of my twitter, facebook, and forum posts about it… My new Grasshopper book has just been published!!

In the first week it has quickly become the #1 new release in Amazon’s “3D Graphic Design” category, and has at times been as high as #3 in that category overall.

Here’s a little more about the content and intended audience than what’s on the publishers website. You can also find this in the discussion at the Grasshopper forum, here.

The book is in three distinct parts. The first part is a fairly basic introduction to the package, and is geared mostly toward beginners.  Here I present several of the most common components with a series of small examples. There are discussions of lists, data trees, data manipulation with components such as Cross Reference and Flip, conditional list processing with the Dispatch and Weave components, curve parameters, surface parameters, mapping geometry with Morph components, and manipulating Meshes.

In the second part I present four advanced tutorials so readers can see how to put together lots of ideas to make complex objects. My hope is that even experts will get something out of looking at these tutorials. They are all original, and experienced Grasshopper users may (hopefully) see Grasshopper get used here in ways they hadn’t seen before. Here’s one of the images from this part, in a tutorial on making custom bevel shapes with only native Grasshopper components:

As stated in the product description, the third pard is a component reference. Most of the work here was taking the help file descriptions of each component and typesetting (read: fighting with LaTeX) them in an easy-to-read format that might be useful for any Grasshopper user.

If the book does well, I’m planning a more advanced sequel. I’m very open to suggestions for content. One person has already suggested I include information on writing your own components, which is something that I think would be good to include. I was also planning on giving some information on the use of several common plug-ins (e.g. Kangaroo, Anemone, Mesh+, etc). Please post other suggestions here!

My New Grasshopper book is out!

Organic Modeling Techniques Part 2: Differential Growth

Before I begin, a quick news update. My Grasshopper book is now completely through the copyediting process, and is with the printer. I’m told it will be available some time in the next few weeks! In the meantime, I’m happy to share the cover art.

Now on to today’s post. As I said in my last post, my goal in this series is to describe modern approaches to modeling organic forms that you wouldn’t find in more classical treatments. So I’m not going to discuss here seashells (logarithmic spirals), sunflowers (phyllotaxis), etc.

I’m excited to write about my newest experiments creating organic forms by a differential growth algorithm. This kind of model is relatively new (as far as I know), but has certainly gained a lot of press for the variety of amazing forms you can generate. If you haven’t seen it yet, I encourage you to check out the amazing video here from Neri Oxman’s group at the MIT media lab. (Her TED talk is also worth watching.) Other great examples are the Floraform sculptures by Jessica Rosenkrantz and Jesse Louis-Rosenberg at Nervous System, like the one shown here:

I’ve long been interested in replicating these kinds of systems with Rhino3D and a Python script, Grasshopper script, or some combination of the two (because that’s the CAD package I know best). Many others have written in to the Grasshopper forum expressing a similar desire, but as far as I know there has been little progress, until now!

The earliest effort I know of in this direction was by Daniel Piker, author of the Grasshopper plug-in “Kangaroo,” originally posted in the discussion here. Kangaroo adds physics based modeling to Grasshopper, allowing the designer to define a variety of forces on a geometry and let the system evolve. The idea behind Piker’s algorithm was to first define a triangulation of a disk where the edges got smaller as you got closer to the outside.

Then he placed a relatively strong force at each vertex to move them away from each other, and a weak spring force along each edge to keep the whole thing together. Add in a little smoothing forces, and here’s the result:

This looks a lot like the Nervous System piece pictured above, but there’s a big difference in the algorithm. Once the edges of the disk are defined, the final form that will eventually evolve is essentially determined. In contrast, a typical differential growth algorithm will just keep growing and growing, adding more and more complexity.

Shortly after Piker posted his definition, Vicente Soler wrote a true differential growth algorithm in a Grasshopper script, described in his post here. However, the core of that script is a C# component containing 543 lines of code. I can read C# code, but I wasn’t about to decipher that. I also can’t really write C# code, so even if I understood his program, it wasn’t going to help me create new variants.

Last week I started experimenting with putting Kangaroo forces inside an Anemone loop. For those unfamiliar with Grasshopper, its a visual way of writing a computer program, where you don’t have to know any coding at all. The drawback of Grasshopper is that there are no provisions for looping, which means you can’t easily make recursive structures. Anemone is a plug-in for Grasshopper that enables looping ability.

My idea was to define some geometry, set it in motion for a very short time by subjecting it to some forces,  modify the geometry based on the resulting shape, and repeat. And here’s the result.

The Grasshopper script to create this is available on the Grasshopper forum, here.

Here’s a brief description of my algorithm:

  1. Begin with a  simple triangulation of a cube.
  2. Measure each edge. If any edge is longer than 2, then subdivide it. This is accomplished with three lines of Python code. (The hard part was figuring out how to write a Python script to take advantage of the Plankton half-edge data structure.)
  3. Place a spring along each edge whose rest-length is the length of the edge, additional forces at the vertices spreading them 2 units apart from each other, and a smoothing force.
  4. Evolve the mesh according to the forces by one unit of time.
  5. Go back to step 2.

The exciting thing (to me anyway) about this algorithm is its potential. By adding other forces (gravity, wind, etc) and constraints I can now “grow” a huge new variety of shapes. I’ve only just gotten started!

[UPDATE: I just figured out the way to grow a disk, instead of a sphere, getting me closer to Nervous System’s Floraform sculpture. Here’s a video:]

 

Organic Modeling Techniques Part 2: Differential Growth

Organic Modeling Techniques Part 1: Reaction-Diffusion

Before I get started with today’s post, I’m happy to announce the completion of my book, “Grasshopper: Visual Scripting for Rhinoceros 3D,” which is tentatively to be published March, 2017.  This a basic introduction on the use of Grasshopper for 3D modeling. I wrote it with the Rhino user in mind who would like to start using Grasshopper in their work-flow, although the presumed knowledge of Rhino is kept to a minimum. The book is organized in three parts: Part 1 is a basic run down on how to use Grasshopper, with simple examples to showcase use of the most basic components. In Part 2 contains a handful of more sophisticated examples, to show how you can combine the elements discussed in Part 1 to create complex forms. Part 3 is a reference guide for all of the Grasshopper components.

For those attending the Joint Mathematics Meetings in Atlanta, I’ll be giving a 20 minute presentation on Grasshopper tomorrow (Thursday, January 5th) at 2:00pm in the MAA invited paper session on “Technical Tools for Mathematical 3D Printing.”

2017 looks to be a busy year for me. My design consultancy business has started to take off, which has led to a number of really interesting projects that I’ll be writing about here. One of the topics I’d really like to delve deeper into this year are the ways in which one can mathematically model organic forms for the purpose of art and design work. This is a very old endeavor, but I’m hoping I can contribute in some way.   This series of posts are really my way of cataloging the different strategies I’ve found to attack the problem of organic modeling with mathematics.

Organic forms have inspired design work,  perhaps since “design” was a thing. Last summer, while visiting ICERM in Providence, I was on a tour of the Rhode Island School of Design’s nature lab. The variety of specimens they had was absolutely breathtaking, and all in service to their design students. There was an entire room of human skeletons, endless cases of coral and seashells, a whole lab full of microscopes for studying microscopic forms, etc.

Readers interested in organic forms can do no better than start with D’Arcy Wentworth Thompson’s classic work,  “On Growth and Form,” first published in 1917. As far as I’m concerned, everyone remotely interested in art, design, biology or mathematics should have a copy of this on their bookshelf. Given how old this work is, it’s shocking how much is there: logarithmic spirals and seashells, branching forms of antlers, polyhedra and cell structures, phyllotaxis and plant growth, etc.

I’ve written previously about the mathematics of seashells and branching (vein) structures. In this and future posts I’ll discuss some more modern topics that are now well known, but too new to have been included in Thompson’s book. This first one I’ll tackle is reaction-diffusion equations, which are commonly used to model things like leopard spots, tiger stripes, and finger-prints.

For the non-technical reader, reaction-diffusion equations are a system of differential equations. Typically there are two of them, and they model two competing populations in a 2-dimesnional region of the plane. The best explanation I’ve seen of the mathematics is by Karl Sims, found here. In that web page he describes a discretization of the reaction-diffusion equations called the Gray-Scott model.

The model begins with a 2-dimensional grid. At each grid point there are two numbers, which encode the concentration of chemicals A and B (or size of two populations, etc.). In Sims’ description, A represents food and B represents an organism that eats it. In the model, each grid cell is continually being given chemical A at some “feed rate”, and organism B eats it and reproduces. In places where there is not enough food, organism B dies off with some “kill rate”. Initially concentrations of A and B, and the feed and kill rates, determine the eventual behavior of the system.

In the Fall of 2016 I had an independent study student, Sachi Watase, work with me on the problem of translating the Gray-Scott model to work on an arbitrary mesh. The first step was to code the Gray-Scott model in Python/Rhino3D (later this was done in Python/Processing). Here are some images Sachi generated.

The idea for the project was to take a 2D mesh with any topology, assign concentrations of A and B at each vertex point, and then evolve the system. It was a very computationally demanding project, since the fate of A and B at each vertex depends on a linear combination of the concentrations of A and B at all neighboring vertices.   Exactly which linear combination to choose proved to be a difficult task, especially for meshes with vertices of varying degree (i.e. different numbers of edges coming into each vertex).

Visualization of the results was done in a number of ways. One strategy was to use the level of B as a gray-scale value to color the mesh. Another was to use B as a variable offset amount to add texture, as in the two images above. Below is the result of a reaction-diffusion equation implemented on a toroidal mesh.

In the end we had the most success with a quad mesh with valence four at each vertex (necessarily a torus, for topological reasons), as in the image above. However, I’m hoping this project continues, and sometime this year I’ll be able to share images of interesting textures/colorings on meshes with lots of different topologies.

 

Organic Modeling Techniques Part 1: Reaction-Diffusion

Vein Structures

In honor of Halloween, I thought I’d post some spooky pictures and discuss how they were made. But first, please take a minute to check out my newly redesigned website, which is up and running at http://davidbachmandesign.com. A special thank you goes out to my friend, Ben Benjamin, for his advice on the design.

Anyone who is interested in 3D printing, art, design, and mathematics has most likely come across the work of Jessica Rosekrantz and Jesse Louis-Rosenberg at their company, Nervous System. Many of their designs for lamps, clothing, furniture, etc are generated with biologically inspired algorithms. One of my favorites is a series of lamps they call “Hyphae”. (Photo shown here with permission.)

hyphaelamp_185_large

As they explain here on their website, these lamps were made from their implementation of an algorithm to simulate the veins in a leaf, detailed in the paper  “Modeling and visualization of leaf venation patterns” by Adam Runions & co. (available here). For anyone interested in understanding this algorithm, I highly recommend watching the animation of it on the Nervous System website.

After spending some time understanding this algorithm myself, I decided to try my own implementation. I was interested in growing veins on a meshed surface of arbitrary topology, which turned out to require some significant modification of the original algorithm. After a month or so of fiddling, I finally started to get some results I was happy with, like the veins on this skull:

And this “eyeball”: eyeballsideview

My algorithm is mostly implemented in a Python box of a larger Grasshopper script. Before the algorithm is run the user selects a vertex of the mesh to be the “root,” and a collection of vertices to be the “sources.” These selections are accomplished with the “Select Mesh Vertices” component of the Grasshopper Mesh+ plugin. (As an aside, my Grasshopper textbook is well underway. Look for an announcement in the next few months!)

Here’s a brief description of my algorithm, with a few simplifications at each step to (hopefully) make it understandable. Feel free to contact me for more details. My apologies for any incomprehensible technical jargon. If you get bored, just scroll down to the end for one more picture! In each iteration of the algorithm we decide how to grow a tree (initially the root vertex) toward the sources.

  1. Compute the shortest path from each source to the tree. Each vertex of the tree at the endpoint of at least one such path is a “growth site.” In the next steps, we determine in which direction to grow from each growth site.
  2. Weight the edges adjacent to each growth site so that an edge picks up one unit of weight if it is the initial edge of a shortest path between the tree and some source.
  3. Find the edge emanating from the growth site closest to the “weighted center” of all of the edges adjacent to it.
  4. “Grow” the tree in the direction of this edge by adding it to the tree.
  5. If the new edge touches a source, remove that source from the collection of sources.
  6. Repeat until all sources are gone.

The above algorithm creates a polygonal tree through the mesh edges. To get a nice veiny structure, only the vertices of each branch are kept track of, together with the total of the edge weights at each. Those vertices are used to construct NURBS curves, and a tapered pipe is made around each curve with radii proportional to the weights.

Unfortunately, the algorithm is very time consuming. The detail of the resulting vein system is limited by how fine of a mesh is used, but in a finer mesh the shortest-path computations, which have to get re-run with every iteration, take much longer. This is why the vein systems I show here are nowhere near as intricate as the one in the Nervous System photo above.

torusvines

There’s been a lot of beautiful work creating tree structures in Grasshopper. For example, there are really nice forum discussions featuring an algorithm of Daniel Gonzales Abalde and various experiments with it, primarily by Nik Wilmore. While these algorithms produce some amazing results in 2 and 3 dimensions, the kinds of trees they produce are structurally different than the ones I’ve shared here. Shortly I will post my own implementation of that algorithm to arbitrary meshes and compare the results.

Vein Structures

3D scanning for fun and profit

Most of my posts so far have been about experiments or challenges in 3-dimensional design for 3D printing. However, it’s possible to get into 3D printing without knowing much about design software, if you have a 3D scanner. In theory, to create an object suitable for 3D printing you can just sculpt it by traditional methods (e.g. carve wood, chisel stone, build up clay, etc.), and scan it.

Unfortunately, in my experience this is often much harder than it sounds. The cheapest scanners are easy to use, but often do not capture enough detail. Slightly better scanners are not as user-friendly and professional grade scanners are out of my price range (they’re often over $10K). Here I’ll post my experience with the scanners I’ve used, and some tips I’ve picked up along the way for successful scanning.

The first scanner I tried was the Sense, by 3D Systems. It’s about $400, and is available for both Mac and PC. There is a newer model now than the one I used, and I don’t know how many improvements they’ve made since then. Basically, the one I used looks like an industrial stapler, and must be tethered to a computer. You aim it at an object, and walk around it. The software tracks the object in real-time, and tries to reconstruct its shape in 3D.

The best thing about the Sense is its cost. It’s cheap, and does a reasonable job with human-sized objects. However, it’s hard to walk around an object with the unit while you are tethered to your computer. It also loses its tracking about 60% of the time, and every time that happens you have to start over.  There are probably tricks to avoid this, but I never found anything that worked great.

With that all said, I did some fun projects with it. The one I like the best was when I scanned all of my family members and turned us into a chess set. I’m the king, my wife the queen, my two boys are the rook and bishop, my dog is the knight, and the Roomba that scurries around our house is the pawn (my son’s idea). With the exception of the Roomba, each was scanned, and accessories (stands, crowns, glasses, and a little dog house) were added afterwards on the computer.  The Roomba was modeled from scratch in Rhino.

An even cheaper low-end 3D scanner isn’t really a scanner at all. 123D Catch, by Autodesk, is a fantastic free smartphone app that often does the job quite nicely. At the time I made the above chess set this program was still giving fairly crude results. Since then it’s improved so much that it is now my go-to solution for quick, cheap scans of relatively large objects. The way it works is that you walk around your object and take lots of pictures. Those pictures get uploaded to Autodesk’s servers, which grind them through some presumably  very sophisticated image processing software. After a relatively short wait, they then provide you with a 3D file of your image. The cool thing is that scale is not an issue. You can scan things as big as a building, or as small as a person. However, very small items are tricky, as they will try to reconstruct everything that your camera has taken a photo of. This instructable has some great information on how to deal with this, although I’ve never personally had much success with using 123D catch to scan small objects.

In the last few years I’ve gotten a lot more serious about my design work, and have at times needed a professional quality scanner. As I mentioned above, most of those are well over $10K, which I just can’t afford. The first thing I tried was an ultra-cheap solution: the Ciclop scanner, a diy open source laser scanner by bq which can supposedly capture very fine details.  It uses two cheap lasers pointed at a small object on a turntable, and a webcam to capture the resulting pattern on the object. I spent hours getting it all put together and set up, but was never able to get a decent scan, so eventually I just gave up in frustration.

Finally, I decided I should bite the bullet and spend more than a few hundred bucks, but I still didn’t have near enough for a high-end machine. The best compromise I found is the Einscan-S, which sells for about $1000. This machine projects a changing white-light pattern on an object, and captures the result in stereo with two cameras. The model I bought came with a turntable, but I never found that very useful.

The Einscan software allows for a turntable mode and a free-scan mode. What I normally do is place an object on the turntable from the Ciclop scanner, and use free-scan mode to capture lots of images of it in different positions. Each time an image is captured, the software reconstructs more of its 3-dimensional form. It rarely loses tracking from one image to the next, and when it does you can just discard the last image. Here’s a scan I did recently of a bronze statue of Alice (from Alice in Wonderland), by the artist Karen Mortillaro. (More on my collaboration with her in a later post!).

Notice the white powder on the original bronze statue in the photo. That’s a standard trick in 3D scanning, where you evenly coat your object with baby powder so it gets picked up by the scanner’s cameras better.

You can see in the picture that the smallest details, like the texture of the hair, are not present in the scan. That may be the difference between a professional quality scanner and an almost-professional quality one, although those particular details may be too small even for the best scanners.

The Einscan-S is not as easy to use as, say, 123D catch. However, it definitely picks up a lot more detail. It does not detect color information, which is fine if you are like me, and only interested in 3D printing the resulting objects. The biggest drawback is the size limitations. I have only been able to get it to capture objects less than 12″ tall.

Einscan now has a “pro” version that looks a lot like the Sense. They claim it will capture even more detail than the “S” version, larger sizes, and color. I don’t know how many of their claims are accurate, and it costs about three times as much. If I ever get to play with one, I’ll post those results here!

3D scanning for fun and profit

BOBs!

I’m back from a long hiatus… The second half of the summer was busy with travel, and the beginning of the semester is always a difficult time. Only now are things settling down, and I can (hopefully) get back to regular posting.

In the last few months my design consulting business has really taken off, and I will be writing soon about some of those projects. Unfortunately, right now none of them are at a state that can be talked about, so I’m going to go back to one of my oldest experiments with 3D printing.

When he was about 6 or 7 my very creative son had made a little game for himself by taking wine corks and turning them into little characters. He’d stick toothpicks in them for arms and legs, use thumbtacks for shields or hats, etc. He called them “BOBs” (because they float!). Not many have survived in the intervening years, but recently my younger son was cleaning out his room and came across these.

img_6886

These were made around the time I started experimenting with 3D printing, so it was natural to try 3D printed cork accessories. It was also before I started using Rhino3D. All modeling was done with Cheetah3D, an inexpensive  CAD program only available for Macs, which turned out to be surprisingly good for this sort of project.

I made two experiments: “Hiker BOB” and “Top Hat BOB”. Each had pants, a hat, and a little accessory. Hiker BOB’s accessory was a belt with a water bottle, and Top Hat BOB had a collar with a bow tie. Both were printed at Shapeways.

img_6882

The ironic thing is that shortly after making these, my son stopped playing with his BOBs. One explanation is that he just outgrew this sort of toy. But I also wonder if I’d somehow spoiled it for him. Maybe the act of making his BOBs was the real fun, and by providing him with pre-made parts I had ruined it. I created an object that would sit on a shelf and be looked at, rather than played with. Or maybe he just discovered video games.

For years I contemplated trying to mass market my 3D printed BOBs. However, I don’t know the first thing about how to start that process, and I was more interested in other pursuits than trying to find out. Recently my wife came across a product called “Corkers,” which is basically the same thing: plastic accessories to turn corks into little characters. Oh well… I guess I missed the boat on that!

BOBs!