Sunday, May 06, 2007

Class Notes (session three)

This week's animated short: Code Guardian by Marco Spitoni and friends. This WWII era fantasy features an improbable universe in which AI amounts to more than a hill of beans, plus the Nazis have a hexapent geoscope.

Marco is completely familiar with film's idioms. Close ups of the pilots in their cockpits sometimes include computer generated camera jitter. One point of sharing this was to emphasize how small a talented team, with the right skills, tools and computers, may nowadays create such a meticulously detailed rendering. All you need is a lot of free time, plus it helps to have a day job that you're good at.

Next we looked at Bill Sheppard's several Mandelbrot Set fractal generators, written in assembly language, runnable under Windows. Multiplication in the complex plane bears some relation to working with vectors, with quaternions even more. We'll look at fractals again in a future class.

Then it was back to our shared stash of Python source code, downloaded from 4D Solutions, and more talk of polyhedra.

By default we pass in a prickly sea urchin of radials, vector-spines emanating from a shared origin. The vector tips are the named vertices of our polyhedron, as in the case of the Icosahedron, originally defined by the 12 corners of 3 mutually orthogonal golden rectangles, with edges 1 x phi. Given the vertex-defining vectors are each named, i.e. keyed to strings of letters, we use a Python dictionary to store them.

Then come the faces, described as consecutive vertices going around each, a circumferential network of edges, each defined by two named vector-vertices. We distill unique edges from the face tuples.
The resulting polyhedron needn't be centered around the origin however; adding the same vector to each radial effectively translates the edges (30 in the case of the icosa (remember: V + F = E + 2)), and hence the entire polyhedral wireframe, to surround a different center. The Polyhedron class overloads __add__ to implement translation.

The generic Polyhedron class (from which the specific polyhedra are subclassed), also supports scaling. Each vector gets multiplied by a scalar this time, with the edge topology (faces) remaining unchanged. The Polyhedron class overloads __mul__ to implement scaling.

One classroom challenge was to dig through the vpython.org documentation to find how to make a scene show up in stereo, given these cheap red/blue frame cardboard glasses I had for each student (answer: pass stereo='redblue' as one of scene2's parameters, in viztoyz).

With class over, I grabbed a few more items at home, then swung by Baibi's to bring her along to NPYM's Spring Willamette Quarterly Meeting at Sky Camp, about 2.5 hours southeast of Portland by car, and where Tara had already gone the night before, with Dave and Jane.

I found Tara with the Junior Friends, playing Shona music on a mirimba.



Related reading: Class 1, Class 2, Python for Math Teachers, Focal Points, Getting Inventive with Vectors