Playing with Math and Programming

Koch Snowflake model

A 3d model of a koch snowflake, which can be printed in plastic, metal, and a variety of other materials.

How I came to be a 3d-modeler

When I was a little kid, probably about five years old, my dad built a computer in our unfinished basement. The walls were bare cement and the floor was rough concrete, with unpainted drywall for walls and exposed floor joists for a ceiling. It was cool in the summer and cold in the winter, and it always felt a little damp. That first home computer matched the look and feel of the basement. The keyboard was just that – keys attached to a board. A jumble of wires connected the keyboard to an open motherboard, which was connected by another jumble of wires to a bare cathode ray tube. I remember learning some programming basics, and then writing a number-guessing game. It was a simple game. It started by inviting the user to play: “I’m thinking of a number. Can you guess it?” If you entered 50 it might respond, “Too high! Please guess again.” You would then enter 25 and it would say, “Too low! Please guess again.” You’d enter 42, and it would say, “That is correct! Please play again!” I remember my family playing the game, and feeling a tremendous satisfaction when the program worked for them.

I did not become obsessed with programming or video games after that. I remember spending more time playing the original Adventure (“You are standing at the edge of a dark forest…”) than trying to write my next program. We played Adventure on a terminal my dad had in the basement when he worked at Digital Equipment Corporation in the 70’s. That computer didn’t even have a monitor. Every line of output was noisily hammered out onto a wide sheet of accordion paper by a rudimentary dot-matrix print head. It’s a very visceral memory of early computing, and I am still amazed that we can work with computers that sit on our laps, and fit in our pockets.

In college I learned to program in C and made a program that generated wireframe plots of 3-d functions. I enjoyed the work of implementing a program well enough to show that my ideas worked, but I had none of the ambition required to make a polished piece of software that worked well for an end user. I was always more interested in playing with math, and playing with programming. Shortly after learning C I read Chaos by James Gleick, and set up a spreadsheet that generated one of the data sets. It was amazing to graph that data set and see an image of a fern emerge. It was incredible to have a home computer with enough processing power to play with these concepts myself as I read about them. These experiences when I was younger help me never take the increasing power of today’s computers for granted.

The Chaos Game - Fern

Successive iterations of a fern-generation algorithm: 10, 100, 1000, and 10000 points.

Last year I discovered Project Euler while teaching Python to some students. Project Euler is a set of about 350 math challenges that can be solved by writing a short program. You earn a new badge for every 25 problems you solve. I solved a couple of the problems, and became invested enough to want the first badge. The problems got hard enough for me around number 25 that I started spending more time than I could justify on them, especially with a new baby on the way. Still, I loved solving a problem that 150,000 people had solved, then moving on to a problem that only 135,000 people had solved, and moving on to successively more exclusive groups of solvers. About 5,000 people have reached or passed the first level. That is not the most exclusive group, but it was still a satisfyingly small group to become a part of. After submitting a successful problem solution, you can read posts about how other people solved the problem. I love having the opportunity to see how people with much more mathematical experience than I have think about these problems. This is one of the lasting strengths of the internet, that it lets us mingle amongst the smartest people in any field, as long as we conduct ourselves respectfully among them. I left Project Euler after earning that first badge, which coincided with the birth of our first baby. But I will go back to it at some point. There is plenty of value in solving harder math problems for fun. I want our child to grow up seeing his mom and I do things like Project Euler just for fun. I also know that solving problems like these keeps our minds young.

Koch Snowflake Ornament

Koch Snowflake, printed in stainless steel. Now available on shapeways.com.

I can’t remember the first time I heard about 3d printers, but I remember being amazed at the thought of a print head flying not just across a sheet of paper, but all through space to create an actual object. I had heard of advances in 3d printing, but it wasn’t until I read a Wired magazine article about making things that I understood the overall process well enough to try it out. The article laid out the simple approach: design a 3d object using a CAD program, and then upload the file to a 3d printing site such as Shapeways. The people at Shapeways will print your object in any number of materials including white or colored plastic, stainless steel, and silver. Some objects can even be printed in sandstone, ceramics, and glass. I considered a few CAD programs and settled on openSCAD, a script-based design program. I like the scripting approach because I want to write a set of instructions for a design that I can then make slight adjustments to, rather than drawing things out with a mouse. Every year Erin and I each pick out one new holiday ornament for our tree. I decided to make her an ornament for this holiday season, and I settled on making a Koch snowflake. I ended up writing a Python program that generated an openSCAD script, which then generated a file I could upload to Shapeways. It took longer than I thought it would, but it worked. I ordered several versions of the ornament, in plastic and in stainless steel. The package arrived a couple weeks later, and I took my time opening it. Holding a solid object that had started out as an abstract mathematical design was a little surreal. I held the heavy ornament in my hand for a while, turning it over repeatedly, feeling its weight and texture and admiring the details that had come through. Holding the physical ornament in my hand closed a circle for me that began when I wrote that first number-guessing game so long ago.

Ever getting an early start in python

Ever getting an early start in python

Having a baby makes me more focused than ever.  I want most of my playing to produce something meaningful now. So today my playing centers around creating high-quality work with students, and producing software that is actually used by other people. I can’t wait to teach students the simple process of getting started with 3d modeling, and see where they go with it as they discover for themselves the joy of playing with math, and playing with programming.

Advertisements

About ehmatthes

Teacher, hacker, new dad, outdoor guy
This entry was posted in modeling and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s