teaching machines

Madeup Workshop

July 21, 2014 by . Filed under madeup, public.

Biography

It all started with the school bus. I lived twelve miles from town, and every morning I got on the bus at 7 AM. I watched every other kid get picked up. In the afternoon, I watched every other kid get dropped off. At 4 PM, I was home. School started at 8 AM and dismissed at 3 PM. You can do the math. If it takes you an hour to go twelve miles, you are moving at 12 mph. That’s a reasonable speed on a bike where you are in control and the wind through your hair makes you feel alive. But on a bus, where no one is in control and you’re happy to just survive, 12 mph is torture.

By the time I reached middle school, I’d had enough of the bus. I pleaded with Mom to let me go to the public library after school, and then she’d pick me up after work. She agreed.

At the library I met Carrie. She shelved books. She suggested I read the Hobbit, which I immediately fell in love with. From that point on, I was determined to be an author, and I began my first fantasy novel in a big teal 5-subject notebook. There were dragons, and lost jewels, and unsuspecting heroes. At page 105, I realized that in order to publish, I’d have to get my story typed up. Once again, I went to Mom and asked her if she could bring her work computer home on the weekends. She agreed.

I began typing. Then I started making maps of the world of my book. Then I started composing music, the soundtrack for my book. Because all books have soundtracks. And then I became so engrossed in creating things on the computer that I forgot to write more.

The Tool of Tools

I don’t think my experience is all that unique. I believe we are all inventors. Humans have an incredible capacity to imagine. We dream up stories, we envision worlds that never existed, we create whole characters that were never born. But we are also physical beings. We move and we sense. We jump at the chance to express our ideas in a way that others cans see and hear and feel.

There are many tools we can use to turn our ideas into things: a pencil, a paintbrush, a hammer and nails, duct tape, and so on. The tool I fell in love with is the computer. The computer is kind of a mysterious box: one side eats ideas and the other side spits out things. For a long time, I was happy just to feed the box and see what came out the other side. Eventually, though, I had ideas that the box didn’t know what to do with. And thus my ideas had no things.

Good news, though. The box can be taught new things. We can create new idea translators by learning to write code. Out of the box, the computer is a tool for turning some ideas into things. But it’s flexible. It’s really a tool for building new tools to turn new ideas into things.

Madeup

One idea that fascinates me is shape. Like rupees, castles, and my initials mashed together in a 3-D glob. I started building a language to express my ideas about shapes to the computer. The computer could then create geometry and print it in solid form on a 3-D printer. The language is called Madeup. It’s for making things up, literally.

The premise of Madeup is that you use a handful of commands to walk through 3-D space and then generate a solid object based on your path. You can use math and logic to create some very peculiar objects. We’re going to look at four kinds of objects today: dots, tubes, extrusions, and revolutions.

Dot

Let’s start by creating a model of an initial, made out of dots. Who would like to volunteer their initial?

I’ll volunteer mine: C. To help us think about a C out in space, we need some X and Y axes. Let’s draw a C over these.

Now, we need the locations of some of the interesting points on our C. I’ll choose five: the two ends and three bowing out. What are their XY locations?

I can use the locations in a Madeup program that walks the path and then plots dots at each. We aren’t really using the Z axis here, so we just use the value 0 for all the Z coordinates.

moveto 5 0 0
moveto 0 0 0
moveto -3 5 0
moveto 0 10 0
moveto 5 10 0
dots

Here’s what I see when I run this program:

My initial C, sparsely represented by five octahedrons.

My initial C, sparsely represented by five octahedrons.

What do you think? It’s awfully disconnected. And those don’t look like dots. Technically, they are octahedrons, which is Greek for “eight faces.” We can fix that by changing the dots’ radii and increasing their number of faces to something bigger:

nsides = 20
radius = 4
moveto 5 0 0
moveto 0 0 0
moveto -3 5 0
moveto 0 10 0
moveto 5 10 0
dots

These settings produce a bulbous C:

My initial C, bulbously represented by five adjoining spheres.

My initial C, bulbously represented by five adjoining spheres.

This information is enough for you to have a turn. I challenge you to create a snowman out of dots. You can get dots of different sizes by setting the radius and moving, and then setting the radius to something else and moving:

radius = 5
moveto 0 0 0
radius = 10
moveto 0 0 -10
dots

How did it go?

Printing structures made out of dots doesn’t usually go very well. Why not, do you suppose?

Tube

Now, let’s talk about a different way of generating geometry. First off, please pair up. One of you gets to be the computer. The other gets to be the programmer. The two of you need each other. The computer is mindless but steadfastly obedient and very fast. The programmer is smart but slow and prone to mistakes.

Computers, please close your eyes for a moment. I’m going to secretly tell the programmers what shape we want you to follow. The programmer is going to feed you one command at a time, only telling you when to turn and when to move forward.

All right, programmers. Program your computer to walk this shape: a square.

How did that go?

In Madeup, we make a square very similarly. We start at the origin, then we move forward and turn 90 degrees. Forward and turn. Forward and turn. Forward and turn.

Since we’re in 3-D, we have a lot more choices for turning. Our cars and bikes essentially live in 2-D, so we only have left and right. But airplanes and birds can pitch (turn their nose up or down) and roll (turn upside down). Turning left and right is called yawing. So, we use the yaw and move commands to trace out the path of a square. Lastly, we fit a tube around the path, not just dots this time:

A square tube expressed with a lot of repetition.

A square tube expressed with a lot of repetition.

This program works fine, but there’s a lot of repetition. If we decide to change the size of our square, we have to change it four times. Stuff like this makes experimenting with our ideas painful. One way to make experimenting easier is by pulling that 10 out to a variable:

A square tube with an easily varied side length.

A square tube with an easily varied side length.

This is better. Variables are a pretty big deal when we write code. Still, we’re doing the same forward-turn combination step four times. We can simplify this by expressing the step only once inside a repeat loop that executes it some number of times:

A square compactly expressed using a loop.

A square compactly expressed using a loop.

This is even better. Loops are a pretty big deal when we write code. They make it incredibly easy to experiment. In fact, let’s use this same structure to draw a pentagon. What needs to change?

A couple of things need to change: the count of the loop and the amount we turn by. Let’s pull the count out to a variable. How much do we bend by. Well, all told, we’ll need to turn 360 degrees. If we have four bends to do that in, each bend will have to be 90 degrees. What if we have five bends? Do we need to turn more or less than 90 degrees? What’s a general formula we can use to determine the amount we need to turn in an n-sided polygon?

A pentagon built from a slight generalization of our square program.

A pentagon built from a slight generalization of our square program.

Now here’s your challenge problem: make a spring. Here are some clues that might help:

Extrude

Tubes are great for rope-like objects. To get thicker solids, we might find it easier to trace along the foundation of an object and then pull it up to make the solid. We can do this with the extrude command. Let’s make a star, which takes some enjoyable thinking to get the angles right:

A star, formed by traversing its foundation and then extruding 5 units along the Z axis.

A star, formed by traversing its foundation and then extruding 5 units along the Z axis.

The extrude command takes a direction in which to pull the cross section and the distance to pull. Extruding in different directions can produce some awkward shapes:

A star extruded along the direction (3, 1, 1).

A star extruded along the direction (3, 1, 1).

Time for the challenge: produce an arrow using extrusion.

Revolve

The last kind of object we’ll make today might feel a bit like using a potter’s wheel or a lathe. We use the revolve command for generating objects that have radial symmetry. A lot of objects in our kitchen are like this: bowls, cups, plates, juicers. Candles and lamps too. And flashlights.

In Madeup, to create a surface of revolution, we just walk a path along the object. Let’s create a pulley with some moves and yaws. By default, we revolve around the Y axis. To keep a hollow center, I move away from the vertical axis by pushing out 2 units along the X axis. From there, it’s just a series of bends and moves.

The cross section of a pulley.

The cross section of a pulley.

Satisfied with my outline, I then hit Run to produce the surface of revolution:

A pulley created by revolving its cross section around the Y axis.

A pulley created by revolving its cross section around the Y axis.

If you’re looking for a challenge problem, create a bishop or a rook using the revolve command.

Conclusion

A computer should make you feel 10 feet tall after using it. It draws out our ideas and puts them before us so we can see them and touch them. Every time we look at what’s inside of us, we grow. Writing code forces us to stop and think about a process. After using Madeup, I marvel at shapes much more than I used to. I’m always thinking, “How could I do that?” Computers make real life much more interesting.

For the rest of our time today, I challenge you to make an object of your own devising. Start with a picture on a piece of paper. Determine what geometry command you will use. Bear in mind that Madeup isn’t suitable for all shapes. Once you’ve determined the command, build up the path little by little. Then, let’s print it. Let’s turn your idea into a thing.