Scary Mathematica Movies for Halloween
October 29, 2010 — Jon McLoone, International Business & Strategic Development
With Halloween approaching, I thought that I would plumb new depths in frivolous uses of Mathematica by making some scary pumpkin movies. Woooo!
If your nerves can take the sheer horror of it all, turn the lights down and dare to read on…
The first thing I had to do was come up with the basic pumpkin shape, a sphere with ripples running from pole to pole. Pretty easy to do if we think of it as an inequality.
There are two subtleties to notice. If we use ArcTan[y/x] to work out the angle around the equator, the branch cut stops the ripples from lining up nicely, so I used the two argument form of ArcTan instead. The other is that I don’t want the pumpkin to be solid, as I want to put candles inside, so the surface has an inner boundary too, even though we can’t see it yet.
The next thing I needed to do was get a knife out and start digging holes in our pumpkin. I used traditional triangular holes. Again, thinking in terms of inequalities makes this pretty easy.
I then combined the two to get a familiar pumpkin face, and while I was at it, I added a simple stalk using the Tube primitive:
It’s the right shape, but hardly very scary. As with many cheap horror films, the answer lies in the lighting. Mathematica gives us great control over lighting with spotlights, directed lights, point sources, and ambient lighting in any number, position, and color that we want. For spooky, though, I kept it simple. First, I got rid of the last mathematical details of the plot:
And then I showed it with just three point sources: two yellow ones placed inside the sphere to give candle light and one well outside the sphere to cast some deep shadows:
With a little more creativity and time spent on faces and lighting, I am sure there are plenty of scarier pumpkins to be made, but this is good enough to start making some movies with.
First, I wanted to try to make the lighting more dynamic by making the exterior light move and the candles flicker. The flicker is achieved by choosing each candle brightness randomly from one frame to the next. I tried some smooth lighting changes, but they didn’t look like flickering. Having two candles instead of one made the light not just flicker brighter and dimmer, but appear to jump around a bit. The exterior light simply orbited around the pumpkin. All I had to do was generate 180 frames and then export them to an AVI file. This produced a rather large uncompressed AVI file, so I then compressed it into another format using Adobe Premiere Elements. I also used this to manually add the spooky (!) soundtrack.
Spooky, but not scary. So my second movie, “Attack of the Killer Pumpkins”, combined the lighting with some movement. I wanted to have the pumpkin emerge into the light. I should probably have done that by controlling the attenuation of the light from one source, but I decided that rather than set a global lighting model, I would light each pumpkin individually and just have the light source get brighter as it approached the camera. Not a reflection of the “reality” that I am modeling, but it seemed easier to me.
Then I generated a list of pumpkin positions according to time. Each zoomed linearly in the y direction (out of the screen) and oscillated with different amplitudes and frequencies in z (up and down). Working out the trajectories and timing was done by trial and error using a Manipulate of spheres, so that I zoomed them in and out in real time. Rendering a high-quality pumpkin of a specified brightness in each position to make the movie file takes too long for experimentation.
The final step was to view the whole scene from very close, so that I got lots of spooky perspective.
Again, format conversion and the added soundtrack were done manually.
Now turn the lights back on, and do try to remember that it was all just make-believe!