[Edu-sig] snap shot of a geometers doodle-pad, in Python (no pictures, but links to some)
kirby urner
kirby.urner at gmail.com
Sun May 4 01:00:04 CEST 2014
I'm archiving this here as a specimen of how Python is so useful in an
educational setting.
You could think of this as pre Python Notebooks, which it is (I'll do a
Notebook version later), and quite spreadsheet-like, as is MathCAD (a
competitor to Mathematica).
The top to bottom flow of a Python script is like MathCAD's: any name
mentioned must already be defined higher up, unless just being introduced
now: enter stage left as in player = ....
What I'm doing is feeding six-edge objects (PlaneNets), i.e. various
tetrahedrons' edges identified in a certain order (fan out from a corner,
then mention opposite triangle edges in the same order), to a volume-maker
that takes edges as inputs (not invented here), and tabulating various
results of investigations, mainly by a guy named Koski in Minnesota, using
the Bucky Fuller stuff (see links below) as a springboard.
Koski and I visited Magnus Wenninger recently, a big name among
polyhedralists, a priest, age 92 or so, check Wikipedia. I got to see
Popko's Divided Spheres in manuscript, well before I got my Kindle edition
(my name goes by in the footnotes brag brag).
You may have heard of a conference named 'Bridges', about bridging art and
math. Koski goes to that sometimes, and Popko. Next one in Korea, last
one in Holland. The vocabulary / terminology used below would have some
currency / truck with that crowd (George and Vi Hart also go, Vi being a
star on Youtube, the author of those whimsical math videos many of you well
know and love).
Anyway, I use the script below to confirm / explore / clarify in my own
mind, what on earth Koski is yakking about. If you're not into
polyhedrons, no need to dive in. If you are, and want to see a relevant
video, here's one of Dave's using vZome, a Java application for ZomeTool
afficionados:
http://worldgame.blogspot.com/2014/03/e-module-mensuration.html
One wrinkle I've noticed but did not show off here, is that the greek
letter phi is standard in Unicode and Python being UTF-8 now accepts that
symbol no problem, as a Python name. I'm not sure how happy mailman and/or
your email client will be with ø = (sqrt(5)+1)/2 but Python handles it just
fine. Calling all greek variable names: the floodgates have opened; use
judiciously and with some caution.
Kirby
==============
"""
Includes:
PlaneNets from Synergetics for A, B, E, T, S
Koski breakdowns of some shapes in E and S vols with phi scaling
Euler volume, modified by Gerald de Jong
http://www.grunch.net/synergetics/quadvols.html
Kirby Urner (c) MIT License
"""
from math import sqrt, hypot
class PlaneNet:
"""Any six edge tet in pattern described in API notes"""
def __init__(self, oa, ob, oc, ab, bc, ca):
self.oa = oa
self.ob = ob
self.oc = oc
self.ab = ab
self.bc = bc
self.ca = ca
class Tetrahedron:
"""
Takes six edges of tetrahedron with faces
(a,b,d)(b,c,e)(c,a,f)(d,e,f) -- returns volume
if ivm and xyz
"""
def __init__(self, a,b,c,d,e,f):
self.a, self.a2 = a, a**2
self.b, self.b2 = b, b**2
self.c, self.c2 = c, c**2
self.d, self.d2 = d, d**2
self.e, self.e2 = e, e**2
self.f, self.f2 = f, f**2
def ivm_volume(self):
return ((self._addopen()- self._addclosed() -
self._addopposite())/2) ** 0.5
def xyz_volume(self):
return sqrt(8/9) * self.ivm_volume()
def _addopen(self):
a2,b2,c2,d2,e2,f2 = self.a2, self.b2, self.c2, self.d2, self.e2,
self.f2
sumval = f2*a2*b2
sumval += d2 * a2 * c2
sumval += a2 * b2 * e2
sumval += c2 * b2 * d2
sumval += e2 * c2 * a2
sumval += f2 * c2 * b2
sumval += e2 * d2 * a2
sumval += b2 * d2 * f2
sumval += b2 * e2 * f2
sumval += d2 * e2 * c2
sumval += a2 * f2 * e2
sumval += d2 * f2 * c2
return sumval
def _addclosed(self):
a2,b2,c2,d2,e2,f2 = self.a2, self.b2, self.c2, self.d2, self.e2,
self.f2
sumval = a2 * b2 * d2
sumval += d2 * e2 * f2
sumval += b2 * c2 * e2
sumval += a2 * c2 * f2
return sumval
def _addopposite(self):
a2,b2,c2,d2,e2,f2 = self.a2, self.b2, self.c2, self.d2, self.e2,
self.f2
sumval = a2 * e2 * (a2 + e2)
sumval += b2 * f2 * (b2 + f2)
sumval += c2 * d2 * (c2 + d2)
return sumval
PHI = sqrt(5)/2 + 0.5
D = 1.0
R = D/2
def volume(net):
return Tetrahedron(net.oa, net.ob, net.oc, net.ab, net.bc, net.ca
).ivm_volume()
# Fig. 913.01 A Quanta Module
# http://www.rwgrayprojects.com/synergetics/s09/figs/f1301.html
a = D
EF = a * sqrt(6) / 12
EC = a * sqrt(6) / 4
ED = a * sqrt(2) / 4
FC = a * sqrt(3) / 3
CD = a/2
DF = a * sqrt(3) / 6
Amod = PlaneNet(EF, EC, ED, FC, CD, DF)
Avol = volume(Amod)
print("Amod volume = :", Avol)
# Fig. 916.01 B Quanta Module
# http://www.rwgrayprojects.com/synergetics/s09/figs/f1601.html
a = D
EA = a * sqrt(2) / 2
EC = a/2
EB = a * sqrt(6) / 12
AC = a/2
CB = a * sqrt(2) / 4
BA = a * sqrt(6) / 4
Bmod = PlaneNet(EA, EC, EB, AC, CB, BA)
Bvol = volume(Bmod)
print("Bmod volume = :", Bvol)
# Fig. 986.411A T & E Module
# http://www.rwgrayprojects.com/synergetics/s09/figs/f86411a.html
h = R
OC = h
OA = h * sqrt((5 - sqrt(5))/2)
OB = h * sqrt((9 - 3 * sqrt(5))/2 )
CA = (h/2) * (sqrt(5) - 1)
AB = h * sqrt(5 - 2 * sqrt(5))
BC = (h/2) * (3 - sqrt(5))
Emod = PlaneNet(OC, OA, OB, CA, AB, BC)
Evol = volume(Emod)
print("Emod volume = :", Evol)
# Fig. 986.411A T & E Module
# http://www.rwgrayprojects.com/synergetics/s09/figs/f86411a.html
h = R * pow(2/3,1/3) * (PHI / sqrt(2))
OC = h
OA = h * sqrt((5 - sqrt(5))/2)
OB = h * sqrt((9 - 3 * sqrt(5))/2 )
CA = (h/2) * (sqrt(5) - 1)
AB = h * sqrt(5 - 2 * sqrt(5))
BC = (h/2) * (3 - sqrt(5))
Tmod = PlaneNet(OC, OA, OB, CA, AB, BC)
Tvol = volume(Tmod)
print("Tmod volume = :", Tvol)
# Fig. 988.13A S Quanta Module Edge Lengths
# http://www.rwgrayprojects.com/synergetics/s09/figs/f8813a.html
a = D
FG = (a/2) * sqrt(3) * sqrt(7-3*sqrt(5))
FE = a * sqrt(7 - 3*sqrt(5))
FH = (a/2) * (sqrt(5)-1)
GE = (a/2) * sqrt(7 - 3*sqrt(5))
EH = (a/2) * (3 - sqrt(5))
HG = (a/2) * sqrt (7 - 3*sqrt(5))
Smod = PlaneNet(FG, FE, FH, GE, EH, HG)
Svol = volume(Smod)
print("Smod volume = :", Svol)
print("================")
sFactor = Evol / Svol
s3 = Svol * pow(PHI, -3)
e3 = Evol * pow(PHI, -3)
print("VE: ", 20, 420 * Svol + 100 * s3)
print("Icosa: ", 20 * sFactor ** 1, 420 * Evol + 100 * e3)
print("BizzaroTet: ", 20 * sFactor ** 2, 360 * Svol + 85 * s3)
print("Small Guy: ", 20 * sFactor ** 3, 360 * Evol + 85 * e3)
import unittest
class Test_Tetrahedron(unittest.TestCase):
def test_unit_volume(self):
tet = Tetrahedron(D, D, D, D, D, D).ivm_volume()
self.assertAlmostEqual(tet, 1.0)
def test_unit_volume2(self):
tet = Tetrahedron(R, R, R, R, R, R).xyz_volume()
self.assertAlmostEqual(tet, 0.1178511)
def test_phi_edge_tetra(self):
tet = Tetrahedron(D, D, D, D, D, PHI)
self.assertAlmostEqual(tet.ivm_volume(), 0.70710678)
def test_right_tetra(self):
e = hypot(sqrt(3)/2, sqrt(3)/2) # right tetrahedron
tet = Tetrahedron(D, D, D, D, D, e).xyz_volume()
self.assertAlmostEqual(tet, 1.0)
if __name__ == "__main__":
unittest.main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20140503/84ebb4bc/attachment.html>
More information about the Edu-sig
mailing list