MathDL - The MAA Mathematical Sciences Digital Library
Search

Search Loci: Developers:

Keyword

  Advanced Search
The Mathematical Association of America
The National Science Digital Library Project
The National Science Foundation
Register Sign In

Loci: Developers

Creating Photo-realistic Images and Animations

by Michael Grady (Southern Utah Univ.)

A Pentagon:

We'll construct our dodecahedron from twelve congruent pentagons. Suitable coordinates for the 20 vertices of a dodecahedron centered at the origin are as follows:

\((\pm 1, \pm 1, \pm 1)\)
\((0, \pm 1/\phi, \pm\phi)\)
\((\pm 1/\phi, \pm\phi, 0)\)
\((\pm\phi, 0, \pm 1/\phi)\)

where \(\phi = (1+\sqrt5)/2\) is the golden ratio [3].

The POV-Ray scene description language is “Turing Complete”, which means it is capable of expressing any algorithm expressible by the familiar programming languages like C++ or Java. It has branching and looping constructs and allows the description of functions. Functions are most often defined in POV-Ray using the macro construct. We use the macro construct below to define a function called “Pentagon” which takes the coordinates of five points in space as input then constructs a pentagon as output. The union construct allows primitive objects to be gathered into a single compound object. The spheres are added at the endpoints to make the joints smooth. Two constants, phi and c = 1/phi are declared and used to make the code more readable. The code below creates one of the pentagons that form the final scene. Save it as dodec-04.pov and render it (Figure 5).  (Changes from dodec-03.pov above are indicated in boldface.)

// povray +P +I dodec-04.pov +W640 +H360 +A

#include "golds.inc"

background{ color rgb<0.2,0.2,0.45>}

camera {
        location <0, -8, 0>
        up <0, 1, 0>
        right <-1.78, 0, 0>
        look_at <0, 0, 0>
        angle 60
        rotate <0, 0, 0>
}

light_source {
        <100,-100,100>
        color rgb<1,1,1>*2.0
}

#declare phi = (1 + sqrt(5)) / 2;
#declare c = 1 / phi;

#macro Pentagon(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5)
        union{
                cylinder {<x1, y1, z1>,   <x2, y2, z2>,  0.1}
                sphere {<x1, y1, z1>, 0.1}
                cylinder {<x2, y2, z2>,  <x3, y3, z3>, 0.1}
                sphere {<x2, y2, z2>, 0.1}
                cylinder { <x3, y3, z3>, <x4, y4, z4>, 0.1}    
                sphere {<x3, y3, z3>, 0.1}          
                cylinder { <x4, y4, z4>, <x5, y5, z5>, 0.1}
                sphere {<x4, y4, z4>, 0.1}        
                cylinder { <x5, y5, z5>, <x1, y1, z1>, 0.1}
                sphere {<x5, y5, z5>, 0.1}
        }            
#end

object {
        Pentagon( 0, -phi, c, 0, -phi, -c, 1, -1, -1, phi, -c, 0, 1, -1,  1)
        texture { T_Gold_5A }
        scale 1.25
}  

pentagon with texture
Figure 5: A pentagon constructed from five cylinders

The Final Scene:

The only thing left is to add the remaining 11 pentagons. Note that we have declared a dodecahedron to be the union of twelve pentagons. The code  is given below -- save it as dodec-05.pov and render it (Figure 6).  (Changes from dodec-04.pov are indicated in boldface.)

// povray +P +I dodec-05.pov +W640 +H360 +A

#include "golds.inc"

background{ color rgb<0.2,0.2,0.45>}

camera {
location <0, -8, 0>
up <0, 1, 0>
right <-1.78, 0, 0>
look_at <0, 0, 0>
angle 60
rotate <0, 0, 0>
}

light_source {
<100,-100,100>
color rgb<1,1,1>*2.0
}

#declare phi = (1 + sqrt(5)) / 2;
#declare c = 1 / phi;

#macro Pentagon(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5) union{ cylinder {<x1, y1, z1>, <x2, y2, z2>, 0.1} sphere {<x1, y1, z1>, 0.1} cylinder {<x2, y2, z2>, <x3, y3, z3>, 0.1} sphere {<x2, y2, z2>, 0.1} cylinder { <x3, y3, z3>, <x4, y4, z4>, 0.1} sphere {<x3, y3, z3>, 0.1} cylinder { <x4, y4, z4>, <x5, y5, z5>, 0.1} sphere {<x4, y4, z4>, 0.1} cylinder { <x5, y5, z5>, <x1, y1, z1>, 0.1} sphere {<x5, y5, z5>, 0.1} } #end

#declare dodecahedron =
union {
Pentagon( c, 0, phi, -c, 0, phi, -1, 1, 1, 0, phi, c, 1, 1, 1)
Pentagon(-c, 0, phi, c, 0, phi, 1, -1, 1, 0, -phi, c, -1, -1, 1)
Pentagon( c, 0, -phi, -c, 0, -phi,-1, -1, -1, 0, -phi, -c, 1, -1, -1)
Pentagon(-c, 0, -phi, c, 0, -phi, 1, 1, -1, 0, phi, -c, -1, 1, -1)
Pentagon( 0, phi, -c, 0, phi, c, 1, 1, 1, phi, c, 0, 1, 1, -1)
Pentagon( 0, phi, c, 0, phi, -c,-1, 1, -1,-phi, c, 0, -1, 1, 1)
Pentagon( 0,-phi, -c, 0, -phi, c,-1, -1, 1,-phi, -c, 0, -1, -1, -1)
Pentagon( 0,-phi, c, 0, -phi, -c, 1, -1, -1, phi, -c, 0, 1, -1, 1)
Pentagon( phi, c, 0, phi, -c, 0, 1, -1, 1, c, 0, phi, 1, 1, 1)
Pentagon( phi,-c, 0, phi, c, 0, 1, 1, -1, c, 0, -phi, 1, -1, -1)
Pentagon(-phi, c, 0, -phi, -c, 0,-1, -1, -1,-c, 0, -phi,-1, 1, -1)
Pentagon(-phi,-c, 0, -phi, c, 0,-1, 1, 1,-c, 0, phi,-1, -1, 1)
}

object {
dodecahedron
texture { T_Gold_5A }
scale 1.25
}

dodecahedron
Figure 6: The Final Scene

Grady, Michael, "Creating Photo-realistic Images and Animations," Loci (October 2009), DOI: 10.4169/loci003351



Discuss this article

Be the first to start a discussion about this article.

start a new discussion thread

MathDL Homepage MathDL Homepage National Science Digital Library The Mathematical Association of America