# teaching machines

## Icosahedron, Part 2

Several hours later, I have now found the difference between an octahedron and an icosahedron. I had been stuck on generating the coordinates of the octahedron. A little reading and experimentation directed my attention to the cube circumscribing the icosahedron. The way I’ve set things up, its vertices are all [±u, ±u, ±u], where u is t + 1. (And curiously, since t is the golden ratio, t + 1 is the same as t * t.)

An octahedron is a dual of a cube, meaning its six vertices are just the six centroids of the circumscribing cube. With those 6 vertices stitched together to form eight faces, I had an octahedron, from which I subtracted the icosahedron.

As Dr. Ward used to say, “Viola!” (sic):



to wireframe vertices, faces
for fi to size faces
face = faces[fi]
for vi to 3
p = vertices[face[vi]]
moveto p[0], p[1], p[2]
end
home
forget
end
end

t = (1 + 5 ^ 0.5) / 2.0
u = t + 1

isoVertices = {
{-1, t, 0},
{1, t, 0},
{-1, -t, 0},
{1, -t, 0},
{0, -1, t},
{0, 1, t},
{0, -1, -t},
{0, 1, -t},
{t, 0, -1},
{t, 0, 1},
{-t, 0, -1},
{-t, 0, 1}
}

isoFaces = {
{0, 11, 5},
{0, 5, 1},
{0, 1, 7},
{0, 7, 10},
{0, 10, 11},
{1, 5, 9},
{5, 11, 4},
{11, 10, 2},
{10, 7, 6},
{7, 1, 8},
{3, 9, 4},
{3, 4, 2},
{3, 2, 6},
{3, 6, 8},
{3, 8, 9},
{4, 9, 5},
{2, 4, 11},
{6, 2, 10},
{8, 6, 7},
{9, 8, 1}
}

octaVertices = {
{0, 0, u},
{u, 0, 0},
{0, 0, -u},
{-u, 0, 0},
{0, u, 0},
{0, -u, 0}
}

octaFaces = {
{0, 1, 4},
{1, 2, 4},
{2, 3, 4},
{3, 0, 4},
{0, 3, 5},
{3, 2, 5},
{2, 1, 5},
{1, 0, 5}
}

wireframe isoVertices, isoFaces
wireframe octaVertices, octaFaces

.rgb = {1, 1, 0}
iso = trimesh isoVertices, isoFaces
.rgb = {1, 0, 1}
oct = trimesh octaVertices, octaFaces

-- iso -- uncomment to yield the icosahedron
oct - iso

var mupDiv = jQuery('#mup_icosahedron');
mupDiv.closest('pre').replaceWith(mupDiv);
document.getElementById('mup_form_icosahedron').submit();

to wireframe vertices, faces
for fi to size faces
face = faces[fi]
for vi to 3
p = vertices[face[vi]]
moveto p[0], p[1], p[2]
end
home
forget
end
end

t = (1 + 5 ^ 0.5) / 2.0
u = t + 1

isoVertices = {
{-1, t, 0},
{1, t, 0},
{-1, -t, 0},
{1, -t, 0},
{0, -1, t},
{0, 1, t},
{0, -1, -t},
{0, 1, -t},
{t, 0, -1},
{t, 0, 1},
{-t, 0, -1},
{-t, 0, 1}
}

isoFaces = {
{0, 11, 5},
{0, 5, 1},
{0, 1, 7},
{0, 7, 10},
{0, 10, 11},
{1, 5, 9},
{5, 11, 4},
{11, 10, 2},
{10, 7, 6},
{7, 1, 8},
{3, 9, 4},
{3, 4, 2},
{3, 2, 6},
{3, 6, 8},
{3, 8, 9},
{4, 9, 5},
{2, 4, 11},
{6, 2, 10},
{8, 6, 7},
{9, 8, 1}
}

octaVertices = {
{0, 0, u},
{u, 0, 0},
{0, 0, -u},
{-u, 0, 0},
{0, u, 0},
{0, -u, 0}
}

octaFaces = {
{0, 1, 4},
{1, 2, 4},
{2, 3, 4},
{3, 0, 4},
{0, 3, 5},
{3, 2, 5},
{2, 1, 5},
{1, 0, 5}
}

wireframe isoVertices, isoFaces
wireframe octaVertices, octaFaces

.rgb = {1, 1, 0}
iso = trimesh isoVertices, isoFaces
.rgb = {1, 0, 1}
oct = trimesh octaVertices, octaFaces

-- iso -- uncomment to yield the icosahedron
oct - iso