MARTIAN HOMEWORK...

WHAT WE DID IN CLASS TODAY

TO DO: IF NOT ALREADY IN YOUR FOLDER

CUT AND PASTE THE SOURCE CODE BELOW TO AN OPEN FILE WINDOW IN IDLE

AND SAVE IT AS

tetrahedron.py

"""
tetrahedron.py

by K. Urner for Saturday Academy, Martian Math

Summer camp 2010 @ Reed College

http://www.4dsolutions.net/satacad/martianmath/

"""

from stickworks import Qray, Edge, getedges
from visual import *

def setscene ( ):
    """set the stage for our little drama"""    
    scene2 = display(title='Drawing a Duo-Tet Cube',
         fullscreen= True, autoscale = False, 
         background=color.white, scale = vector(0.1, 0.1, 0.1))    
    return scene2

def duotet(  ):

    """
    draw a two tetrahedra (orange and black) in
    a green cube using Qrays from stickworks.py
    """
    
    scene = setscene( )
    scene.select( )

    a, b, c, d = Qray((1,0,0,0)), Qray((0,1,0,0)), Qray((0,0,1,0)), Qray((0,0,0,1))
    e, f, g, h = -a, -b, -c, -d  # dual tetrahedron

    for stick in (a,b,c,d):
        stick.draw()

    for edge in ((a,b), (a,c), (a,d), (b,c), (c,d), (d, b)):
        stick = Edge(*edge)
        stick.color = color.orange
        stick.draw()
        
    for edge in ((e,f), (e,g), (e,h), (f,g), (g,h), (h, f)):
        stick = Edge(*edge)
        stick.color = color.black
        stick.draw()

    cube_faces = [(a,h,c,f),(a,h,b,g),(b,e,c,h),(b,e,d,g),(d,g,a,f),(c,e,d,f)]

    for edge in getedges ( cube_faces ):
        stick = Edge(*edge)
        stick.color = color.green
        stick.draw()
        
    print "OK, done..."
    return
                       
if __name__ == "__main__":
    duotet( )



PREV | NEXT | TOC | HOME