Constructive Solid Geometry

I will post about intersections in the near future, and I think it is instructive to explain how easy it is these days to visualize intersections of sets. For instance, an infamous Calculus problem asks to compute the volume of the intersection of two cylinders of equal radius whose axes intersect at a right angle:

This image shows the union of the two cylinders. It can be rendered in PoVRay using the following code:

```#declare color1 = rgb <0.824802, 0.572810, 0.332621>;
#declare color2 = rgb <0.288963, 0.391247, 0.546639>;

union {
object {
cylinder {<3,0,0>,-<3,0,0>, 1}
pigment {color color1}
}
object {
cylinder {<0,3,0>,-<0,3,0>, 1}
pigment {color color2}
}
scale .4
rotate <90,30,0>
rotate <-30,0,0>
}
```

To make this a complete scene file, you need to add before this camera and light source settings, for instance:

```global_settings { assumed_gamma 2.2 }

#include "colors.inc"

camera {
location <0,0,-4>
angle 40
right x*image_width/image_height
up y
look_at <0,0,0>
}

#default {
finish {
ambient .1
diffuse .3
specular .2
}
}

light_source {
<3,3,-8> color White
}
light_source {
<3,-3,-8> color White
}
light_source {
<-3,3,-8> color White
}
light_source {
<-3,-3,-8> color White
}

background {color White}
```

To render the intersection above, you just need to replace union by intersection.
While amusing, this doesn’t help to solve the problem. The main idea is to slice the two cylinders with planes parallel to the two axes of the cylinders, and to realize that you will get squares, because both cylinders are cut into parallel strips. One way to visualize that is by slicing the two cylinders with thin slabs, and throwing away every other slab, like so:

The PoVRay code for this uses a simple loop and intersects the two cylinders with a union of slabs. Note that the plane primitive represents a half space, given by normal vector and distance to the origin. So a slab is nothing but the difference of two half planes:

```intersection {
object {
cylinder {<3,0,0>,-<3,0,0>, 1}
pigment {color color1}
}
object {
cylinder {<0,3,0>,-<0,3,0>, 1}
pigment {color color2}
}
union {
#declare height = -1;
#declare step=.05;
#while (height <1)
difference {
plane {<0,0,1>,height+step/2}
plane {<0,0,1>,height}
pigment {color color3}
}
#declare height = height+step;
#end
}
}
```

Finally, let’s try to incorporate more of the two cylinders so that it becomes clear in a single image that we are intersecting cylinders. We do this by adding the differences between one cylinder and a slightly larger copy of the other cylinder as follows:

```intersection {
union {
intersection {
object {
cylinder {<3,0,0>,-<3,0,0>, 1}
pigment {color color1}
}
object {
cylinder {<0,3,0>,-<0,3,0>, 1}
pigment {color color2}
}
}
intersection {
object {
cylinder {<3,0,0>,-<3,0,0>, 1+.3}
pigment {color color1}
inverse
}
object {
cylinder {<0,3,0>,-<0,3,0>, 1}
pigment {color color2}
}
}
intersection {
object {
cylinder {<3,0,0>,-<3,0,0>, 1}
pigment {color color1}
}
object {
cylinder {<0,3,0>,-<0,3,0>, 1+.3}
pigment {color color2}
inverse
}
}
}
union {
#declare height = -1;
#declare step=.1;
#while (height <1)
difference {
plane {<0,0,1>,height+step/2}
plane {<0,0,1>,height}
pigment {color color3}
}
#declare height = height+step;
#end
}
}
```

I imagine Archimedes would have been pleased.

Polyhedra at an Exhibition

When in 1873 Victor Hartmann died, Modest Mussorgsky visited a memorial exhibition with his friend’s drawings. Deeply impressed, he wrote a suite for piano – Pictures at an Exhibition.
The Pictures are lost, but the music survived.

Around 1910, Wassili Kandinski painted the first abstract painting. Instead of depicting recognizable things from nature, he painted abstract shapes. He even developed a theory how emotions should relate to abstract colors and shapes.

This brought the visual arts closer to music, and it is maybe not a big surprise that Kandinsky ‘composed’ a ballet for abstract shapes, to be performed to Mussorgsky’s Pictures at an Exhibition.
Kandinsky’s ballet is lost, but the idea survived.

In the spring semester 2003, I taught the class Exploring Mathematical Ideas to undergraduates majors and minors at Indiana University in Bloomington, with the idea to recreate a modern version of the ballet, using computer graphics.

I introduced polyhedra in class early on, and used the raytracer PoVRay as an illustrational tool.

The students had to learn the basics of raytracing with PoVRay in the first half of the class.

Then we assigned one piece of the music to each student, picked a few polyhedra, created 3D models (in PoVRay), designed a few scenes, and rendered keyframes.

Then we turned to animations: What was a constant (a color, the coordinate of a point, the size of an object) could now suddenly depend on a time parameter.

This proves the concept of a variable instantly useful, and shows that being able to write down formulas for functions allows to control these geometric quantities according to the design of the scene.

How did we synchronize? The answer is: We didn’t. I didn’t ask my students to synch the movie to the music. In fact, it is usually easier to synch the music to the movie by employing a live player, than the other way round. Some of the students tried it nevertheless and succeeded amazingly well.

With some more effort, one would be able to use parameters of the music (like sound amplitude) as an input for the raytracer parameters, but our project was a zero budget project, and we didn’t have the technology.

In particular, this would require the ability to precisely align the video track with the sound track. Our (free) software did not even generate the video tracks to the correct duration…

So, instead the goal was to catch the mood of the scene, and I believe this was quite successful.

How to overcome copyrights? Using Mussorgsky’s music from commercial production so that you can publicly show the movie and distribute it is next to impossible. While Mussorgsky’s piano score is in the public domain, neither the various orchestrations are, nor are any recordings.

I was lucky to find a freely downloadable version of the orchestration by Carl Simpson, recorded by the Ithaca Symphony Orchestra under Hrant Cooper. They all and the publisher gave us permission to use the music for this class, and to show the movie. This was an interesting exercise in copyright law!

That the images on this page are so small has a reason: After a hard drive crash, the sources for the movie scenes were lost. What survives, are these images, and a low quality version of the entire 35 minute movie.