(*^
::[ Information =
"This is a Mathematica Notebook file. It contains ASCII text, and can be
transferred by email, ftp, or other text-file transfer utility. It should
be read or edited using a copy of Mathematica or MathReader. If you
received this as email, use your mail application or copy/paste to save
everything from the line containing (*^ down to the line containing ^*)
into a plain text file. On some systems you may have to give the file a
name ending with ".ma" to allow Mathematica to recognize it as a Notebook.
The line below identifies what version of Mathematica created this file,
but it can be opened using any other version as well.";
FrontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.2";
MacintoshStandardFontEncoding;
fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8, 24, "Times";
fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6, 18, "Times";
fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6, 14, "Times";
fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20, 18, "Times";
fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15, 14, "Times";
fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12, 12, "Times";
fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times";
fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L-5, 12, "Courier";
fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier";
fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R65535, L-5, 12, "Courier";
fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier";
fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, B65535, L-5, 12, "Courier";
fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, 12, "Courier";
fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, 10, "Geneva";
fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = leftheader, inactive, L2, 12, "Times";
fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, 12, "Times";
fontset = leftfooter, inactive, L2, 12, "Times";
fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times";
fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times";
paletteColors = 128; automaticGrouping; currentKernel;
]
:[font = title; inactive; preserveAspect; startGroup]
Convert Uniform Polyhedra To POV-Ray
Spheres, Cylinders, and Triangles
:[font = subsubtitle; inactive; preserveAspect]
by
Russell Towle
July, 1997
:[font = section; inactive; Cclosed; preserveAspect; startGroup]
Discussion
:[font = text; inactive; preserveAspect; endGroup]
This notebook is very limited in its scope: it reads in Roman Maeder's UniformPolyhedra.m and PolyhedraExamples.m, and then defines a function ToPOV[filename_String, n_Integer]. ToPOV creates a file containing POV-Ray (Persistence of Vision Ray Tracer) directives for spheres of radius R1 (upon each vertex of the nth uniform polyhedron), cylinders of radius R2 (upon each edge of the nth uniform polyhedron) and triangles (each face of the nth uniform polyhedron is divided into co-planar triangles). Within POV, this file is then read into a scene file which declares the values of R1 and R2, the radii of the spheres and cyclinders, respectively.
Within POV it is at the user's disgression whether to actually render the group of spheres, or the group of cylinders, or the group of triangles, and what colors and textures to assign to them. The example POV scene file below is merely a point of beginning.
Several of the uniform polyhedra may not be rendered at all within Mathematica, except on special machines. PolyhedraExamples.m contains this caveat:
(* :Limitations: the polyhedra Nos. 69, 72, 74, and 75 cannot be shown with Display[] (usually used implicitly from within Show[]) because of limitations in the built-in renderer. They can be shown with Live[] on machines with suitable graphics hardware.*)
However, POV handles these easily.
Several functions used in this notebook were copied from Maeder's POVray.m package, and of course the uniform polyhedra themselves also depend upon Maeder's work.
;[s]
9:0,0;144,3;177,0;180,3;185,0;982,1;993,0;1067,2;1325,0;1526,-1;
4:5,13,9,Times,0,12,0,0,0;1,13,9,Times,2,12,0,0,0;1,13,10,Courier,1,12,0,0,0;2,13,9,Times,1,12,0,0,0;
:[font = section; inactive; Cclosed; preserveAspect; startGroup]
Initialization
:[font = input; initialization; preserveAspect]
*)
<",
",", "<", Infix[nForm /@ r[[1,2]], ", "], ">"," ",r[[2]],"}" ]
ballmake[txt_:"", r_List] /; Length[r] == 2 :=
SequenceForm[txt,"{", "<", Infix[nForm /@ r[[1]], ", "], ">",
" ",r[[2]],"}" ]
facemake[txt_:"", r_List] /; Length[r] == 3 :=
SequenceForm[txt,"{", "<", Infix[nForm /@ r[[1]], ", "], ">",
",", "<", Infix[nForm /@ r[[2]], ", "], ">",
",", "<", Infix[nForm /@ r[[3]], ", "], ">","}" ]
(*
:[font = message; inactive; preserveAspect; endGroup]
General::spell1:
Possible spelling error: new symbol name "protected"
is similar to existing symbol "Protected".
:[font = input; initialization; preserveAspect; endGroup]
*)
ToPOV[filename_String,n_Integer]:=
Block[{a,b,c,f,h,q1,q2,v,balls,sticks,faces,obj,zaq},
obj=NumberedPolyhedron[n];
v=VertexCoordinates[obj];
(*find face indices and make edge indices*)
a=FaceList[obj];
b=Map[Join[#,{First[#]}]&, a ];
h=Map[Partition[#,2,1]&,b];
h=Flatten[h,1];
(*find all edges remove duplicates*)
c=Table[
Position[h,x_ /; x == h[[i]] || x == Reverse[h[[i]]] ],{i,Length[h]}];
f=Map[Take[#,1]&, Union[c]];
f=Flatten[f,2];
zaq=Table[ v[[ h[[ f[[i]] ]] ]],{i,Length[f]}];
(*create faces and divide into triangles*)
poly=Map[v[[ #]]&,a];
poly=Map[toTriangles[#]&,poly];
q1=Map[Ball[#,R1]&,Chop[v]];
q2=Map[Rod[#,R2]&,Chop[zaq]];
balls=ColumnForm[Map[ballmake["sphere",# ]&,q1],Left];
sticks=ColumnForm[Map[cyllmake["cylinder",# ]&,q2],Left];
faces=ColumnForm[Map[facemake["triangle",# ]&,Chop[Flatten[poly,1]]],Left];
strm=OpenWrite[filename,
FormatType->OutputForm,
PageWidth->Infinity];
Write[strm,"#declare RODS = union{"];
Write[strm,sticks];
Write[strm,"}"];
Write[strm,"#declare BALLS = union{"];
Write[strm,balls];
Write[strm,"}"];
Write[strm,"#declare FACES = union{"];
Write[strm,faces];
Write[strm,"}"];
Close[strm]
]
(*
:[font = section; inactive; Cclosed; preserveAspect; startGroup]
List of Uniform Polyhedra
:[font = input; preserveAspect; startGroup]
ColumnForm[Table[{i,standard[[i]]},{i,Length[standard]}]]
:[font = output; output; inactive; preserveAspect; fontLeading = 0; endGroup; endGroup]
{1, {"tetrahedron", w1[3, 2, 3]}}
{2, {"truncated tetrahedron", w2[2, 3, 3]}}
{3, {"octahemioctahedron", w2[3/2, 3, 3]}}
{4, {"tetrahemihexahedron", w2[3/2, 3, 2]}}
{5, {"octahedron", w1[4, 2, 3]}}
{6, {"cube", w1[3, 2, 4]}}
{7, {"cuboctahedron", w1[2, 3, 4]}}
{8, {"truncated octahedron", w2[2, 4, 3]}}
{9, {"truncated cube", w2[2, 3, 4]}}
{10, {"rhombicuboctahedron", w2[3, 4, 2]}}
{11, {"truncated cuboctahedron", w3[2, 3, 4]}}
{12, {"snub cube", w0[2, 3, 4]}}
{13, {"small cubicuboctahedron", w2[3/2, 4, 4]}}
{14, {"great cubicuboctahedron", w2[3, 4, 4/3]}}
{15, {"cubohemioctahedron", w2[4/3, 4, 3]}}
{16, {"cubitruncated cuboctahedron", w3[4/3, 3, 4]}}
{17, {"great rhombicuboctahedron", w2[3/2, 4, 2]}}
{18, {"small rhombihexahedron", w3[3/2, 2, 4]}}
{19, {"stellated truncated hexahedron", w2[2, 3, 4/3]}}
{20, {"great truncated cuboctahedron", w3[4/3, 2, 3]}}
{21, {"great rhombihexahedron", w3[4/3, 3/2, 2]}}
{22, {"icosahedron", w1[5, 2, 3]}}
{23, {"dodecahedron", w1[3, 2, 5]}}
{24, {"icosidodecahedron", w1[2, 3, 5]}}
{25, {"truncated icosahedron", w2[2, 5, 3]}}
{26, {"truncated dodecahedron", w2[2, 3, 5]}}
{27, {"rhombicosidodecahedron", w2[3, 5, 2]}}
{28, {"truncated icosidodechedon", w3[2, 3, 5]}}
{29, {"snub dodecahedron", w0[2, 3, 5]}}
{30, {"small ditrigonal icosidodecahedron", w1[3, 5/2, 3]}}
{31, {"small icosicosidodecahedron", w2[5/2, 3, 3]}}
{32, {"small snub icosicosidodecahedron", w0[5/2, 3, 3]}}
{33, {"small dodecicosidodecahedron", w2[3/2, 5, 5]}}
{34, {"small stellated dodecahedron", w1[5, 2, 5/2]}}
{35, {"great dodecahedron", w1[5/2, 2, 5]}}
{36, {"dodecadodecahedron", w1[2, 5/2, 5]}}
{37, {"truncated great dodecahedron", w2[2, 5/2, 5]}}
{38, {"rhombidodecadodecahedron", w2[5/2, 5, 2]}}
{39, {"small rhombidodecahedron", w3[2, 5/2, 5]}}
{40, {"snub dodecadodecahedron", w0[2, 5/2, 5]}}
{41, {"ditrigonal dodecadodecahedron", w1[3, 5/3, 5]}}
{42, {"great ditrigonal dodecicosidodecahedron", w2[3, 5, 5/3]}}
{43, {"small ditrigonal dodecicosidodecahedron", w2[5/3, 3, 5]}}
{44, {"icosidodecadodecahedron", w2[5/3, 5, 3]}}
{45, {"icositruncated dodecadodecahedron", w3[5/3, 3, 5]}}
{46, {"snub icosidodecadodecahedron", w0[5/3, 3, 5]}}
{47, {"great ditrigonal icosidodecahedron", w1[3/2, 3, 5]}}
{48, {"great icosicosidodecahedron", w2[3/2, 5, 3]}}
{49, {"small icosihemidodecahedron", w2[3/2, 3, 5]}}
{50, {"small dodecicosahedron", w3[3/2, 3, 5]}}
{51, {"small dodecahemidodecahedron", w2[5/4, 5, 5]}}
{52, {"great stellated dodecahedron", w1[3, 2, 5/2]}}
{53, {"great icosahedron", w1[5/2, 2, 3]}}
{54, {"great icosidodecahedron", w1[2, 5/2, 3]}}
{55, {"great truncated icosahedron", w2[2, 5/2, 3]}}
{56, {"rhombicosahedron", w3[2, 5/2, 3]}}
{57, {"great snub icosidodecahedron", w0[2, 5/2, 3]}}
{58, {"small stellated truncated dodecahedron", w2[2, 5, 5/3]}}
{59, {"truncated dodecadodecahedron", w3[5/3, 2, 5]}}
{60, {"inverted snub dodecadodecahedron", w0[5/3, 2, 5]}}
{61, {"great dodecicosidodecahedron", w2[5/2, 3, 5/3]}}
{62, {"small dodecahemicosahedron", w2[5/3, 5/2, 3]}}
{63, {"great dodecicosahedron", w3[5/3, 5/2, 3]}}
{64, {"great snub dodecicosidodecahedron", w0[5/3, 5/2, 3]}}
{65, {"great dodecahemicosahedron", w2[5/4, 5, 3]}}
{66, {"great stellated truncated dodecahedron", w2[2, 3, 5/3]}}
{67, {"great rhombicosidodecahedron", w2[5/3, 3, 2]}}
{68, {"great truncated icosidodecahedron", w3[5/3, 2, 3]}}
{69, {"great inverted snub icosidodecahedron", w0[5/3, 2, 3]}}
{70, {"great dodecahemidodecahedron", w2[5/3, 5/2, 5/3]}}
{71, {"great icosihemidodecahedron", w2[3/2, 3, 5/3]}}
{72, {"small retrosnub icosicosidodecahedron", w0[3/2, 3/2, 5/2]}}
{73, {"great rhombidodecahedron", w3[3/2, 5/3, 2]}}
{74, {"great retrosnub icosidodecahedron", w0[3/2, 5/3, 2]}}
{75, {"great dirhombicosidodecahedron", w0[3/2, 5/3, 3, 5/2]}}
{76, {"pentagonal prism", w2[2, 5, 2]}}
{77, {"pentagonal antiprism", w0[2, 2, 5]}}
{78, {"pentagrammic prism", w2[2, 5/2, 2]}}
{79, {"pentagrammic antiprism", w0[2, 2, 5/2]}}
{80, {"pentagrammic crossed antiprism", w0[2, 2, 5/3]}}
;[o]
{1, {tetrahedron, 3|2 3}}
{2, {truncated tetrahedron, 2 3|3}}
{3, {octahemioctahedron, 3/2 3|3}}
{4, {tetrahemihexahedron, 3/2 3|2}}
{5, {octahedron, 4|2 3}}
{6, {cube, 3|2 4}}
{7, {cuboctahedron, 2|3 4}}
{8, {truncated octahedron, 2 4|3}}
{9, {truncated cube, 2 3|4}}
{10, {rhombicuboctahedron, 3 4|2}}
{11, {truncated cuboctahedron, 2 3 4|}}
{12, {snub cube, |2 3 4}}
{13, {small cubicuboctahedron, 3/2 4|4}}
{14, {great cubicuboctahedron, 3 4|4/3}}
{15, {cubohemioctahedron, 4/3 4|3}}
{16, {cubitruncated cuboctahedron, 4/3 3 4|}}
{17, {great rhombicuboctahedron, 3/2 4|2}}
{18, {small rhombihexahedron, 3/2 2 4|}}
{19, {stellated truncated hexahedron, 2 3|4/3}}
{20, {great truncated cuboctahedron, 4/3 2 3|}}
{21, {great rhombihexahedron, 4/3 3/2 2|}}
{22, {icosahedron, 5|2 3}}
{23, {dodecahedron, 3|2 5}}
{24, {icosidodecahedron, 2|3 5}}
{25, {truncated icosahedron, 2 5|3}}
{26, {truncated dodecahedron, 2 3|5}}
{27, {rhombicosidodecahedron, 3 5|2}}
{28, {truncated icosidodechedon, 2 3 5|}}
{29, {snub dodecahedron, |2 3 5}}
{30, {small ditrigonal icosidodecahedron, 3|5/2 3}}
{31, {small icosicosidodecahedron, 5/2 3|3}}
{32, {small snub icosicosidodecahedron, |5/2 3 3}}
{33, {small dodecicosidodecahedron, 3/2 5|5}}
{34, {small stellated dodecahedron, 5|2 5/2}}
{35, {great dodecahedron, 5/2|2 5}}
{36, {dodecadodecahedron, 2|5/2 5}}
{37, {truncated great dodecahedron, 2 5/2|5}}
{38, {rhombidodecadodecahedron, 5/2 5|2}}
{39, {small rhombidodecahedron, 2 5/2 5|}}
{40, {snub dodecadodecahedron, |2 5/2 5}}
{41, {ditrigonal dodecadodecahedron, 3|5/3 5}}
{42, {great ditrigonal dodecicosidodecahedron, 3 5|5/3}}
{43, {small ditrigonal dodecicosidodecahedron, 5/3 3|5}}
{44, {icosidodecadodecahedron, 5/3 5|3}}
{45, {icositruncated dodecadodecahedron, 5/3 3 5|}}
{46, {snub icosidodecadodecahedron, |5/3 3 5}}
{47, {great ditrigonal icosidodecahedron, 3/2|3 5}}
{48, {great icosicosidodecahedron, 3/2 5|3}}
{49, {small icosihemidodecahedron, 3/2 3|5}}
{50, {small dodecicosahedron, 3/2 3 5|}}
{51, {small dodecahemidodecahedron, 5/4 5|5}}
{52, {great stellated dodecahedron, 3|2 5/2}}
{53, {great icosahedron, 5/2|2 3}}
{54, {great icosidodecahedron, 2|5/2 3}}
{55, {great truncated icosahedron, 2 5/2|3}}
{56, {rhombicosahedron, 2 5/2 3|}}
{57, {great snub icosidodecahedron, |2 5/2 3}}
{58, {small stellated truncated dodecahedron, 2 5|5/3}}
{59, {truncated dodecadodecahedron, 5/3 2 5|}}
{60, {inverted snub dodecadodecahedron, |5/3 2 5}}
{61, {great dodecicosidodecahedron, 5/2 3|5/3}}
{62, {small dodecahemicosahedron, 5/3 5/2|3}}
{63, {great dodecicosahedron, 5/3 5/2 3|}}
{64, {great snub dodecicosidodecahedron, |5/3 5/2 3}}
{65, {great dodecahemicosahedron, 5/4 5|3}}
{66, {great stellated truncated dodecahedron, 2 3|5/3}}
{67, {great rhombicosidodecahedron, 5/3 3|2}}
{68, {great truncated icosidodecahedron, 5/3 2 3|}}
{69, {great inverted snub icosidodecahedron, |5/3 2 3}}
{70, {great dodecahemidodecahedron, 5/3 5/2|5/3}}
{71, {great icosihemidodecahedron, 3/2 3|5/3}}
{72, {small retrosnub icosicosidodecahedron, |3/2 3/2 5/2}}
{73, {great rhombidodecahedron, 3/2 5/3 2|}}
{74, {great retrosnub icosidodecahedron, |3/2 5/3 2}}
{75, {great dirhombicosidodecahedron, |3/2 5/3 3 5/2}}
{76, {pentagonal prism, 2 5|2}}
{77, {pentagonal antiprism, |2 2 5}}
{78, {pentagrammic prism, 2 5/2|2}}
{79, {pentagrammic antiprism, |2 2 5/2}}
{80, {pentagrammic crossed antiprism, |2 2 5/3}}
:[font = section; inactive; Cclosed; preserveAspect; startGroup]
Example
:[font = input; preserveAspect]
(*Preview the uniform polyhedron.*)
(*Do not attempt nos. 69, 72, 74, or 75.*)
ShowPolyhedron[41];
:[font = input; preserveAspect; startGroup]
(*Set the directory to which the file will be written.*)
SetDirectory["Starlight:POV-Ray 3.0:"]
:[font = output; output; inactive; preserveAspect; endGroup]
"Starlight:POV-Ray 3.0"
;[o]
Starlight:POV-Ray 3.0
:[font = input; preserveAspect; startGroup]
(*Write the POV file named "ditrigonal" for polyhedron 41.*)
ToPOV["ditrigonal",41]
:[font = output; output; inactive; preserveAspect; endGroup; endGroup]
"ditrigonal"
;[o]
ditrigonal
:[font = section; inactive; Cclosed; preserveAspect; startGroup]
Sample POV scene file
:[font = text; inactive; preserveAspect; fontSize = 14]
In this example, POV version 3.0 syntax is invoked, but version 2.x will also work, if the first line is removed altogether. The uniform polyhedron file is called with an #include statement below, after the radii of the spheres and cylinders have been #declare-d. In this example the file is called "shub-niggurath," which is the name assigned to uniform polyhedron #69 in Maeder's list by George Olschevsky and Bruce Chilton, who tired of the "small retrosnub ditrigonal icosidodecahedron" terminology, and turned to the stories of H.P Lovecraft for an alternative. The text below may be copied to your Clipboard and pasted directly into an empty POV scene file. Note: the actual sizes of the uniform polyhedra vary, and either the camera position or its lens length (the magnitude of its "direction" vector) may need adjustment.
:[font = text; inactive; preserveAspect; fontSize = 14; endGroup; endGroup]
#version 3.0 // use POV-Ray 3.0 syntax
#include "colors.inc"
#include "shapes.inc"
#include "textures.inc"
#include "metals.inc"
#default { texture { pigment {color rgb <1,1,1>} finish {phong 0.1 ambient 0.2 diffuse .6} }}
camera {
location <0, -3.5, 7>
direction <0, 3, 0>
up <0, 0, 1.>
right <4/3, 0, 0> // 4 to3 aspect ratio (i.e., 320X240, 640X480, etc.)
sky <0., 0., 1.>
look_at <0, 0, 0.>
rotate<0,5,0>
}
light_source { <0, 0, 44>
color rgb <1, 1, 1>}
plane{z,-3
pigment{
checker
color rgb <1,.5,.5>
color rgb <.5,.5,1>
}
}
#declare R1 = .075 //Balls
#declare R2 = .0375 //Sticks
#include "shub-niggurath"
object{ RODS
texture{T_Silver_1A}
}
object{ BALLS
texture{Gold_Metal}
}
object{FACES}
^*)