# teaching machines

## Icosahedron, Part 1

One of the important consequences of the internet is that we can now talk freely about icosahedrons. We’re not bound to the interests of those that are geographically near. We can love pretty much anything and find a community that shares our passions somewhere online.

So, this morning, while I was trying to get other things done, I saw people talking about the icosahedron on Twitter. In particular, someone posted a challenge to produce a diff of the octahedron and icosahedron. I wondered if I could do that in Madeup… Long story short, I’m still working on it.

However, the discussion did inspire me to add to Madeup a new solidifier: trimesh. This solidifier breaks from the general mechanic of turning polylines into solids. But it has to. It supports modeling of shapes that aren’t serial in nature. It takes two parameters:

• a list of 3D positions, each representing a single vertex on the model
• a list of faces, each a 3-vector of indices into the positions list

Here it is at work!



t = (1 + 5 ^ 0.5) / 2.0

vertices = {
{-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}
}

faces = {}
to tri i, j, k
moveto vertices[i][0], vertices[i][1], vertices[i][2]
moveto vertices[j][0], vertices[j][1], vertices[j][2]
moveto vertices[k][0], vertices[k][1], vertices[k][2]
home
forget
append faces, {i, j, k}
end

tri 0, 11, 5
tri 0, 5, 1
tri 0, 1, 7
tri 0, 7, 10
tri 0, 10, 11

tri 1, 5, 9
tri 5, 11, 4
tri 11, 10, 2
tri 10, 7, 6
tri 7, 1, 8

tri 3, 9, 4
tri 3, 4, 2
tri 3, 2, 6
tri 3, 6, 8
tri 3, 8, 9

tri 4, 9, 5
tri 2, 4, 11
tri 6, 2, 10
tri 8, 6, 7
tri 9, 8, 1

trimesh vertices, faces

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

t = (1 + 5 ^ 0.5) / 2.0

vertices = {
{-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}
}

faces = {}
to tri i, j, k
moveto vertices[i][0], vertices[i][1], vertices[i][2]
moveto vertices[j][0], vertices[j][1], vertices[j][2]
moveto vertices[k][0], vertices[k][1], vertices[k][2]
home
forget
append faces, {i, j, k}
end

tri 0, 11, 5
tri 0, 5, 1
tri 0, 1, 7
tri 0, 7, 10
tri 0, 10, 11

tri 1, 5, 9
tri 5, 11, 4
tri 11, 10, 2
tri 10, 7, 6
tri 7, 1, 8

tri 3, 9, 4
tri 3, 4, 2
tri 3, 2, 6
tri 3, 6, 8
tri 3, 8, 9

tri 4, 9, 5
tri 2, 4, 11
tri 6, 2, 10
tri 8, 6, 7
tri 9, 8, 1

trimesh vertices, faces