<div>&nbsp;</div>
<div>Here&#39;s some field tested code that I think showcases what a student</div>
<div>interested in computer graphics might eyeball and run, after some </div>
<div>background in the basic syntax.&nbsp; </div>
<div>&nbsp;</div>
<div>True, there&#39;s stuff going on behind the scenes (another module, plus </div>
<div>VPython, all well documented).</div>
<div>&nbsp;</div>
<div>I&#39;ll plan to use this with my high schoolers in April.&nbsp; I want them to </div>
<div>see what real Python really looks like, to get ideas from, for doing </div>
<div>graphics of their own.</div>
<div>&nbsp;</div>
<div>We also use VRML, maybe just projected on the big screen in front.</div>
<div>&nbsp;</div>
<div>Kirby</div>
<div>&nbsp;</div>
<div>
<p>&quot;&quot;&quot;<br>coupler.py<br>by K. Urner, (gpl) 2007 <a href="http://4dsolutions.net">4dsolutions.net</a></p>
<p>Documentation for Coupler:</p>
<p>The Coupler is a space-filling irregular octahedron defined<br>by three mutually orthogonal quadrilaterals:&nbsp; one square and<br>two congruent rhombi.&nbsp; This module constructs these quadri-<br>laterals and displays them in VPython.
</p>
<p>In the concentric hierarchy, the Coupler&#39;s volume = 1 (i.e.<br>is same as tetrahedron&#39;s defined by 4 unit-radius CCP balls).</p>
<p><a href="http://www.rwgrayprojects.com/synergetics/s09/figs/f86431.html">http://www.rwgrayprojects.com/synergetics/s09/figs/f86431.html</a></p>
<p>URL for stickworks.py:<br><a href="http://www.4dsolutions.net/ocn/python/stickworks.py">http://www.4dsolutions.net/ocn/python/stickworks.py</a></p>
<p>Documentation for stickworks.py:<br><a href="http://www.4dsolutions.net/ocn/stickworks.html">http://www.4dsolutions.net/ocn/stickworks.html</a></p>
<p>Relevant VRML worlds by sw dharmraj (see Synergeo on Yahoo!):<br><a href="http://members.westnet.com.au/dharmraj/vrml/coupler.wrl">http://members.westnet.com.au/dharmraj/vrml/coupler.wrl</a><br><a href="http://members.westnet.com.au/dharmraj/vrml/KmiteCube.wrl">
http://members.westnet.com.au/dharmraj/vrml/KmiteCube.wrl</a></p>
<p>See also:&nbsp; Richard Hawkins Digital Archive:<br><a href="http://www.newciv.org/Synergetic_Geometry/">http://www.newciv.org/Synergetic_Geometry/</a></p>
<p>&quot;&quot;&quot;</p>
<p>from stickworks import Vector, Edge, axes<br>from math import sqrt</p>
<p>sqrt2 = sqrt(2)<br>apexd = sqrt2/2.0</p>
<p># convention nx for -x (negative x)<br>x = Vector((1,0,0))<br>y = Vector((0,1,0))<br>nx = Vector((-1,0,0))<br>ny = Vector((0, -1, 0))</p>
<p>apex = Vector((0, 0, apexd))<br>napex = Vector((0, 0, -apexd))</p>
<p><br>class Square (object) :<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp; Coupler Square Equator in XY plane<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;</p>
<p>&nbsp;&nbsp;&nbsp; def __init__(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edge.color = (1,0,0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.edges = [Edge(x,y), Edge(y,nx),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edge(nx,ny), Edge(ny,x)]</p>
<p>&nbsp;&nbsp;&nbsp; def draw(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for e in self.edges:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.draw()<br>&nbsp;&nbsp;&nbsp; <br>class Fx (object) :<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp; Coupler Equator in XZ plane<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;</p>
<p>&nbsp;&nbsp;&nbsp; def __init__(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edge.color = (0,1,0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.edges = [ Edge(x, apex), Edge(apex, nx),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edge(nx, napex), Edge(napex, x)]</p>
<p>&nbsp;&nbsp;&nbsp; def draw(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for e in self.edges:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.draw()<br>&nbsp;&nbsp;&nbsp; <br>class Fy (object) :<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp; Coupler Equator in YZ plane<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;</p>
<p>&nbsp;&nbsp;&nbsp; def __init__(self):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.edges = [ Edge(y, apex), Edge(apex, ny),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edge(ny, napex), Edge(napex, y)]</p>
<p>&nbsp;&nbsp;&nbsp; def draw(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for e in self.edges:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.draw()<br>&nbsp;&nbsp;&nbsp; <br>def test():<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp; Draw a Coupler centered at (0,0,0) with XYZ Axes<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot;</p>
<p>&nbsp;&nbsp;&nbsp; # blue axes, please<br>&nbsp;&nbsp;&nbsp; Edge.color = (0,0,1)<br>&nbsp;&nbsp;&nbsp; axes(2,2,2)</p>
<p>&nbsp;&nbsp;&nbsp; # create equator objects<br>&nbsp;&nbsp;&nbsp; ofy = Fy()<br>&nbsp;&nbsp;&nbsp; ofx = Fx()<br>&nbsp;&nbsp;&nbsp; osq = Square()</p>
<p>&nbsp;&nbsp;&nbsp; # draw the rhombi<br>&nbsp;&nbsp;&nbsp; Edge.color = (0,1,0)<br>&nbsp;&nbsp;&nbsp; ofy.draw()<br>&nbsp;&nbsp;&nbsp; ofx.draw()</p>
<p>&nbsp;&nbsp;&nbsp; # draw the square&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Edge.color = (1,0,0)&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; osq.draw()</p>
<p>if __name__ == &#39;__main__&#39;:<br>&nbsp;&nbsp;&nbsp; test()<br>&nbsp;&nbsp;&nbsp; </p></div>