# Bringing Zombies to Life… Is That an Oxymoron?

October 30, 2013 — Allison Taylor, Public Relations

I was lucky enough in college to be able to double-major in physics and film/media. One of the coolest connections that formed from these completely opposite subjects was the use of Mathematica. What started out as just a computational tool for all the work in my physics classes turned into an experimental playground for the digital animation I was creating in my film classes.

Mathematica is an ideal program to model the true science of motion. And as you’ll come to see, it looks complicated, but is actually quite simple!

Let’s start with understanding some basic human anatomy (or zombie anatomy, since this post is technically about zombies):

Our zombie (henceforth referred to as “Ted,” because… well, that’s what I named him) is currently just your basic stick figure. Each leg is made up of a thigh, calf, and foot; each arm is a shoulder, forearm, and hand. And he has a torso, a neck, and a head. Between each line we’re going to place a joint, which will allow Ted to move his limbs and give us our animation control—think of us as puppeteers pulling strings.

So let’s define our function to depend only on the joint rotation angles plus a single set of coordinates from which Ted will be built around, and lastly, a “face” variable that will come in handy later

As we build Ted, we’re going to have to do some parenting. No, not that kind of parenting! (Though Ted does appreciate love and attention.)

That’s parenting!

We can do this in Mathematica by taking advantage of the fact the code is read linearly—what is written first will be evaluated first, and the evaluation only changes if the code following it tells it to.

So how do we properly parent limbs? Well, my elbow is always going to follow my shoulder, but my shoulder is not always going to follow my elbow. So in the code, the rotation of my shoulder has to come before my elbow. Following this logic, we can also see that nearly everything comes to a point at the hip—if you bend over, both of your arms, your torso, your neck, and your head all must follow.

So here is Ted, all grown up! I think we did a pretty good job parenting, don’t you?

He’s still a stick-figure, though. So with a little more code (ugh, not more code), we can easily transfer our lines into rectangles. Oh, I almost forgot—let’s give Ted his face:

Much better! But we still have yet to actually bring him to life. First, some ambiance (with parts that will move when we animate it!):

Right now our function depends mostly on angles. And if we want to make Ted walk, we need him to bend the joints in his legs by continuously picking them up and putting them down, and repeat this motion indefinitely. What sort of motion does this?

Sinusoidal motion, of course! These are some rather arbitrary functions I made up to have Ted walk. With some tweaking, we can apply these functions to our angles and… Ted is alive!

To see a few other cool features of Mathematica, and how we can make the above applet interactive (how about importing your own image as Ted’s face?), download the notebook and try out the code yourself. Happy Halloween!

 Fun and quite practical. I will be using some of this. Thanks! Posted by Glen    October 30, 2013 at 6:27 pm
 Very cool and a joy to read! In addition to realistic motion, I thought that the background and the personalized-photo ideas were brilliant. Posted by Tal Einav    November 14, 2013 at 2:31 pm