[Edu-sig] Radical Math: debugging help?
kirby urner
kirby.urner at gmail.com
Sun Apr 11 01:41:36 CEST 2010
Below is current source for ch.py, a module for exploring volume
relationships starting with a "ground state" (a default) known as the
concentric hierarchy of polyhedra.
The user begets various polyhedra from their class definitions, then resizes
them at will, perhaps using the * operator in place of the scale method:
>>> import ch
>>> rt = ch.R_Triac()
>>> rt.volume
7.5
>>> rt = rt * pow(2/3., 1/3.)
DEBUG: a star is born: a new R_Triac
>>> rt.volume
5.0000000000000009
>>> rt.edge
0.61771467052713269
>>> rt = ch.R_Triac()
>>> rt.edge
0.70710678118654757
>>> rt.edge_name
'long face diagonal'
The concentric hierarchy is formed from the five Platonics, a primitive set
that is closed under the operation of "make my dual".
When the duals combine, e.g. the tetrahedron with itself, you have the
option to intersect the edges so as to form yet another polyhedron (not
necessarily Platonic).
Here's what you can do with the five Platonics in that regard (i.e. o +
o.dual == something).
tetrahedron + tetrahedron == cube
octahedron + cube == rhombic dodecahedron
icosahedron + pentagonal dodecahedron == rhombic triacontahedron
There's some question as to how to scale these relative to one another, when
defining a ground state.
The tetrahedron, cube, octahedron and rhombic dodecahedron all have obvious
volume relationships if you start in this way.
Anyway, here's my puzzle: I'm using Python 2.6, but my call to
Poly.__init__ within its subclasses would surely be more stylish where
super() used instead.
However, all my trials with super(), have so far resulted in errors.
If you fix this and even provide a clear explanation as to how this fix
works, you might become part of a famous inner circle. The concentric
hierarchy is poised to take the world by storm, at least in NCTM circles.
Here's a lesson plan I've been touting.
http://www.bfi.org/our_programs/bfi_community/synergetics (follow link to
NCTM web site)
Kirby
PS: all the dual combos are rhombohedra i.e. have rhombic faces. You may
criss-cross these diamond faces to get tri-rectangular tetrahedral wedge
shapes that include the center point. In the case of the cube and rhombic
dodecahedron, one gets the same shape, called a Mite in this namespace (for
"minimum tetrahedron" -- it's a space-filler). In the case of the rhombic
triacontahedron, one gets the T-module (T for triacontahedron). Provided
our scaling is done right, 3 * T = Mite (volumetrically speaking). I will
be adding these in a next edition. My thanks to David Koski for technical
assistance on this project.
*====== ch.py ======
from math import sqrt as radical
phi = (1 + radical(5))/2
class Poly:
def __init__(self, edge = 1, edge_name = "edge",
volume = 1, greekname = "Tetrahedron"):
self.edge = edge
self.edge_name = edge_name
self.volume = volume
self.greekname = greekname
def scale(self, scalefactor):
edge = self.edge * scalefactor # edge unbound to self
volume = self.volume * pow(scalefactor, 3) # likewise volume
print("DEBUG: a star is born: a new %s" % self.__class__.__name__)
return self.__class__(edge = edge, edge_name = self.edge_name,
volume = volume, greekname = self.greekname)
__mul__ = __rmul__ = scale # e.g. tetra = tetra * 3
def __repr__(self):
return "Polyhedron of type %s (vol: %s)" % (self.greekname,
self.volume)
class Tetra( Poly ):
pass
class Cube( Poly ):
def __init__(self, edge = 1, edge_name = "face diagonal",
volume = 3, greekname = "Hexahedron"):
Poly.__init__(self, *(edge, edge_name, volume, greekname))
class Octa( Poly ):
def __init__(self, edge = 1, edge_name = "edge",
volume = 4, greekname = "Octahedron"):
Poly.__init__(self, *(edge, edge_name, volume, greekname))
class R_Dodeca( Poly ):
def __init__(self, edge = 1, edge_name = "long face diagonal",
volume = 6, greekname = "Rhombic dodecahedron"):
Poly.__init__(self, *(edge, edge_name, volume, greekname))
class R_Triac( Poly ):
def __init__(self, edge = radical(2)/2, edge_name = "long face
diagonal",
volume = 7.5, greekname = "Rhombic Triacontahedron"):
Poly.__init__(self, *(edge, edge_name, volume, greekname))
class Icosa ( Poly ):
def __init__(self, edge = 1, edge_name = "edge",
volume = 5 * phi**2 * radical(2), greekname =
"Icosahedron"):
Poly.__init__(self, *(edge, edge_name, volume, greekname))
class Cubocta ( Poly ):
def __init__(self, edge = 1, edge_name = "edge",
volume = 20, greekname = "Cuboctahedron"):
Poly.__init__(self, *(edge, edge_name, volume, greekname))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20100410/ff436536/attachment-0001.html>
More information about the Edu-sig
mailing list