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:
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 <strong>dodec-04.pov</strong> +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 } <strong>#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 } <br /></strong>
Figure 5: A pentagon constructed from five cylinders
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 <strong>dodec-05.pov</strong> +W640 +H360 +A<br /><br />#include "golds.inc"<br /><br />background{ color rgb<0.2,0.2,0.45>}<br /><br />camera {<br /> location <0, -8, 0><br /> up <0, 1, 0><br /> right <-1.78, 0, 0><br /> look_at <0, 0, 0><br /> angle 60<br /> rotate <0, 0, 0><br />}<br /><br />light_source {<br /> <100,-100,100><br /> color rgb<1,1,1>*2.0<br />}<br /><br />#declare phi = (1 + sqrt(5)) / 2;<br />#declare c = 1 / phi;<br /><br /> #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<br /><br /><strong>#declare dodecahedron = <br />union {<br /> Pentagon( c, 0, phi, -c, 0, phi, -1, 1, 1, 0, phi, c, 1, 1, 1)<br /> Pentagon(-c, 0, phi, c, 0, phi, 1, -1, 1, 0, -phi, c, -1, -1, 1)<br /> Pentagon( c, 0, -phi, -c, 0, -phi,-1, -1, -1, 0, -phi, -c, 1, -1, -1)<br /> Pentagon(-c, 0, -phi, c, 0, -phi, 1, 1, -1, 0, phi, -c, -1, 1, -1)<br /> Pentagon( 0, phi, -c, 0, phi, c, 1, 1, 1, phi, c, 0, 1, 1, -1)<br /> Pentagon( 0, phi, c, 0, phi, -c,-1, 1, -1,-phi, c, 0, -1, 1, 1)<br /> Pentagon( 0,-phi, -c, 0, -phi, c,-1, -1, 1,-phi, -c, 0, -1, -1, -1)<br /> Pentagon( 0,-phi, c, 0, -phi, -c, 1, -1, -1, phi, -c, 0, 1, -1, 1) <br /> Pentagon( phi, c, 0, phi, -c, 0, 1, -1, 1, c, 0, phi, 1, 1, 1)<br /> Pentagon( phi,-c, 0, phi, c, 0, 1, 1, -1, c, 0, -phi, 1, -1, -1)<br /> Pentagon(-phi, c, 0, -phi, -c, 0,-1, -1, -1,-c, 0, -phi,-1, 1, -1)<br /> Pentagon(-phi,-c, 0, -phi, c, 0,-1, 1, 1,-c, 0, phi,-1, -1, 1)<br />}<br /><br />object {<br /> dodecahedron<br /> texture { T_Gold_5A } <br /> scale 1.25 <br />}<br /></strong>
Figure 6: The Final Scene