POLY.MP: DEFINITION OF REGULAR CONVEX POLYHEDRA IN METAPOST

version 1.0, 8 April 1998 Denis Roegel (roegel@loria.fr) This package defines the five regular convex polyhedra classes and must be used with the 3d package. Each object definition is parameterized by an instance identification. All polyhedra are normalized (centered on the origin and inscriptible in a sphere of radius 1). The polyhedra are defined with a certain number of points and faces. The points comprise both the vertices and the center of the object. It might be useful to remind the Euler formula linking the number of faces f, vertices v and edges e in polyhedra with no hole in dimension 3: f + v − e = 2. This can be verified in the following table:

type  faces vertices edges
tetrahedron  4  4  6
cube  6  8  12
octahedron  8  6  12
dodecahedron  12  20  30
icosahedron  20  12  30

For more details, see the documentation enclosed in the distribution. message ; TETRAHEDRON (4 faces)

Construction of a tetrahedron:

One face is with h = c\sqrt{3}/2

The angle α between two faces is given by sin(α/2) = \frac{c/2}{c\sqrt{3}/2} = 1/\sqrt{3}

def set tetrahedron points(expr inst) = set obj point(1, 0, 0, 0); set obj point(2, 1, 0, 0); set obj point(3, cosd(60), sind(60), 0); % 60 = 360/6 sinan = 1/ sqrt(3); cosan = sqrt(1 − sinan ∗∗ 2); an = 180 − 2 ∗ angle((cosan, sinan)); new face point(4, 1, 2, 3, an); normalize obj (inst)(1, 2, 3, 4); set obj point(5, 0, 0, 0); % center of tetrahedron

enddef;

vardef def tetrahedron(expr inst) = new obj points(inst, 5); % 4 vertices and the center new obj faces(inst, 4); % 4 faces in the definition set tetrahedron points(inst);

set obj face(1,  ,  );
set obj face(2,  ,  );
set obj face(3,  ,  );
set obj face(4,  ,  );

enddef; CUBE (HEXAHEDRON) (6 faces)

The definition of a cube is straightforward.

def set cube points(expr inst) = set obj point(1, 0, 0, 0); set obj point(2, 1, 0, 0); set obj point(3, 1, 1, 0); set obj point(4, 0, 1, 0); set obj point(5, 0, 0, 1); set obj point(6, 1, 0, 1); set obj point(7, 1, 1, 1); set obj point(8, 0, 1, 1); normalize obj (inst)(1, 7); % 1 and 7 are opposite vertices set obj point(9, 0, 0, 0); % center of cube

enddef;

vardef def cube(expr inst) = new obj points(inst, 9); % 8 vertices and the center new obj faces(inst, 6); % 6 faces in the definition set cube points(inst);

set obj face(1,  ,  );
set obj face(2,  ,  );
set obj face(3,  ,  );
set obj face(4,  ,  );
set obj face(5,  ,  );
set obj face(6,  ,  );

enddef; OCTAHEDRON (8 faces)

A section of a pyramid is:

The height of this pyramid is given by H^{2} = (c\sqrt{3}/2)^{2} − (c/2)^{2} = c^{2}/2, hence H = c/\sqrt{2}

def set octahedron points(expr inst) = set obj point(1, 0, 0, 0); set obj point(2, 1, 0, 0); set obj point(3, 1, 1, 0); set obj point(4, 0, 1, 0); set obj point(5, .5, .5, 1/ sqrt(2)); set obj point(6, .5, .5, −1/ sqrt(2)); normalize obj (inst)(5, 6); % 5 and 6 are opposite vertices set obj point(7, 0, 0, 0); % center of octahedron

enddef;

vardef def octahedron(expr inst) = new obj points(inst, 7); % 6 vertices and the center new obj faces(inst, 8); % 8 faces in the definition set octahedron points(inst);

set obj face(1,  ,  );
set obj face(2,  ,  );
set obj face(3,  ,  );
set obj face(4,  ,  );
set obj face(5,  ,  );
set obj face(6,  ,  );
set obj face(7,  ,  );
set obj face(8,  ,  );

enddef; DODECAHEDRON (12 faces) Two adjacent faces (pentagons) of the dodecahedron are as follows:

The angle between the faces is the angle between \overrightarrow{OA} and \overrightarrow{OB}. OA = OB = d_{3} as defined in

d_{1} = 2r sin(π/5), d_{2} = 2r sin(2π/5) and d_{3} = d_{1} sin(2π/5) = 2r sin(π/5) sin(2π/5) The angle α is defined by the following conditions:

Thus d_{2}^{2} = d_{3}^{2} + d_{3}^{2} − 2d_{3}^{2} cos α, which leads to cos α = 1 − \frac{d_{2}^{2}}{2d_{3}^{2}} = −\frac{cos(2π/5)}{2 sin^{2}(π/5)}

def set dodecahedron points(expr inst) = new points(fc)(10); % face centers set point(fc_{1}, 0, 0, 0); set obj point(1, 1, 0, 0); set obj point(2, cosd(72), sind(72), 0); % 72=360/5 rotate in plane(3, fc_{1}, 1, 2); rotate in plane(4, fc_{1}, 2, 3); rotate in plane(5, fc_{1}, 3, 4); cosan = − cosd(72)/(2 ∗ sind(36) ∗ sind(36)); sinan = sqrt(1 − cosan ∗∗ 2); an = 180 − angle((cosan, sinan)); new abs face point(fc_{2}, fc_{1}, 1, 2, an); new abs face point(fc_{3}, fc_{1}, 2, 3, an); new abs face point(fc_{4}, fc_{1}, 3, 4, an); new abs face point(fc_{5}, fc_{1}, 4, 5, an); new abs face point(fc_{6}, fc_{1}, 5, 1, an); rotate in plane(6, fc_{2}, 2, 1); rotate in plane(7, fc_{2}, 1, 6); rotate in plane(8, fc_{2}, 6, 7); rotate in plane(9, fc_{3}, 2, 8); rotate in plane(10, fc_{3}, 8, 9); rotate in plane(11, fc_{4}, 3, 10); rotate in plane(12, fc_{4}, 10, 11); rotate in plane(13, fc_{5}, 4, 12); rotate in plane(14, fc_{5}, 12, 13); rotate in plane(15, fc_{6}, 5, 14); new abs face point(fc_{7}, fc_{2}, 6, 7, an); new abs face point(fc_{8}, fc_{3}, 8, 9, an); new abs face point(fc_{9}, fc_{4}, 10, 11, an); new abs face point(fc_{10}, fc_{5}, 12, 13, an); rotate in plane(16, fc_{7}, 6, 15); rotate in plane(17, fc_{7}, 15, 16); rotate in plane(18, fc_{8}, 7, 17); rotate in plane(19, fc_{9}, 9, 18); rotate in plane(20, fc_{10}, 11, 19); normalize obj (inst)(2, 20); % opposite vertices set obj point(21, 0, 0, 0); % center of dodecahedron free points(fc)(10);

enddef; vardef def dodecahedron(expr inst) =

save cosan, sinan, an; new obj points(inst, 21); % 21 points in the definition new obj faces(inst, 12); % 12 faces in the definition set dodecahedron points(inst);

set obj face(1,  ,  );
set obj face(2,  ,  );
set obj face(3,  ,  );
set obj face(4,  ,  );
set obj face(5,  ,  );
set obj face(6,  ,  );
set obj face(7,  ,  );
set obj face(8,  ,  );
set obj face(9,  ,  );
set obj face(10,  ,  );
set obj face(11,  ,  );
set obj face(12,  ,  );

enddef; ICOSAHEDRON (20 faces) Two faces of an icosahedron are linked in the following way:

where h = c\sqrt{3}/2

d is also a diagonal in a pentagon:

c = 2r sin(π/5), d = 2r sin(2π/5) = 2c cos(π/5) The angle between two faces is computed as follows:

We have (2 cos(π/5))^{2} = 2(\sqrt{3}/2)^{2} − 2(\sqrt{3}/2)^{2} cos α Thus cosα = 1 − \frac{8}{3} cos^{2}(π/5) def set icosahedron points(expr inst) =

set obj point(1, 0, 0, 0); set obj point(2, 1, 0, 0); set obj point(3, cosd(60), sind(60), 0); % 60=360/6 cosan = 1 − ^{8}/_{3} ∗ cosd(36) ∗ cosd(36); sinan = sqrt(1 − cosan ∗∗ 2); an = 180 − angle((cosan, sinan)); new face point(4, 1, 2, 3, an); new face point(5, 2, 3, 1, an); new face point(6, 3, 1, 2, an); new face point(7, 2, 4, 3, an); new face point(8, 3, 5, 1, an); new face point(9, 1, 6, 2, an); new face point(10, 3, 4, 7, an); new face point(11, 3, 7, 5, an); new face point(12, 1, 8, 6, an); normalize obj (inst)(1, 10); % opposite vertices set obj point(13, 0, 0, 0); % center of icosahedron

enddef;

vardef def icosahedron(expr inst) = save cosan, sinan, an; new obj points(inst, 13); % 12 vertices and the center new obj faces(inst, 20); % 20 faces in the definition set icosahedron points(inst);

set obj face(1,  ,  );
set obj face(2,  ,  );
set obj face(3,  ,  );
set obj face(4,  ,  );
set obj face(5,  ,  );
set obj face(6,  ,  );
set obj face(7,  ,  );
set obj face(8,  ,  );
set obj face(9,  ,  );
set obj face(10,  ,  );
set obj face(11,  ,  );
set obj face(12,  ,  );
set obj face(13,  ,  );
set obj face(14,  ,  );
set obj face(15,  ,  );
set obj face(16,  ,  );
set obj face(17,  ,  );
set obj face(18,  ,  );
set obj face(19,  ,  );
set obj face(20,  ,  );

enddef;

endinput