[Edu-sig] OT: calculating dodeca icosa solid assembly angles

kirby urner kirby.urner at gmail.com
Sat Jan 20 05:25:39 CET 2007

> For the icosahedron, I think you should focus on the 20 almost-regular
> tetrahedra, with slices parallel to the bases (the 20 facets) defining the
> thin outer shell of your handsome wooden and/or plastic casement.

I could do the same for the pentagonal dodeca if you like.

Here's a start, but I end with a subtle bug, with discussion:

>>> from rbf import Pentdodeca
>>> mypd = Pentdodeca()
>>> mypd.vertices
{'a': vector(-0.5, 0.5, 0.5), 'c': vector(0.5, -0.5, 0.5), 'b':
vector(0.5, 0.5, 0.5), 'e': vector(-0.5, 0.5, -0.5), 'd': vector(-0.5,
-0.5, 0.5), 'g': vector(0.5, -0.5, -0.5), 'f': vector(-0.5, -0.5,
-0.5), 'i': vector(0.309016994374947, 0, 0.809016994374947), 'h':
vector(0.5, 0.5, -0.5), 'k': vector(0, 0.809016994374947,
0.309016994374947), 'j': vector(-0.309016994374947, 0,
0.809016994374947), 'm': vector(-0.809016994374947, 0.309016994374947,
0), 'l': vector(0, 0.809016994374947, -0.309016994374947), 'o':
vector(0.809016994374947, 0.309016994374947, 0), 'n':
vector(-0.809016994374947, -0.309016994374947, 0), 'q': vector(0,
-0.809016994374947, 0.309016994374947), 'p': vector(0.809016994374947,
-0.309016994374947, 0), 's': vector(0.309016994374947, 0,
-0.809016994374947), 'r': vector(0, -0.809016994374947,
-0.309016994374947), 't': vector(-0.309016994374947, 0,
>>> mypd.faces
[('o', 'p', 'c', 'i', 'b'), ('r', 'f', 'n', 'd', 'q'), ('n', 'f', 't',
'e', 'm'), ('e', 'l', 'k', 'a', 'm'), ('j', 'a', 'k', 'b', 'i'), ('q',
'd', 'j', 'i', 'c'), ('j', 'd', 'n', 'm', 'a'), ('p', 'g', 'r', 'q',
'c'), ('g', 's', 't', 'f', 'r'), ('k', 'l', 'h', 'o', 'b'), ('h', 'l',
'e', 't', 's'), ('h', 's', 'g', 'p', 'o')]
>>> def addvects(shape, thelist):
	total = shape.vertices[thelist[0]]
	for vertex in thelist[1:]:
		total += shape.vertices[vertex]
	return total

>>> altitude = addvects(mypd, ('o', 'p', 'c', 'i', 'b'))

What you might not get from the above addvects, is that it
messes with the actual vertex 'o' inside of mypd.  This is
because "to assign" means "to share a pointer with"
(thus upping the reference count, staving off garbage
collection).  So in passing the polyhedron itself as the first
parameter, and referencing into it with the first letter (string),
makes 'total' subject to rebinding.  With successive additions
of vectors 'p', 'c', 'i' and 'b', the vector named 'o' gets updated.

An ugly solution would be to do something with 'copy'.
Copy has been tucked away in a separate module to make
it less tempting.  Better to think *with* the shared reference
model than against it.  A better solution would be to initialize
'total' as a fresh zero vector.


More information about the Edu-sig mailing list