MARTIAN MOLECULES...

Exploring Chemistry

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

ballpack.py

"""
ballpack.py

by K. Urner for Saturday Academy, Martian Math

Summer camp 2010 @ Reed College

http://www.4dsolutions.net/ocn/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 12-around-1 packing',
         fullscreen= True, autoscale = False,
         background=color.white, scale = vector(0.1, 0.1, 0.1))
    return scene2

def ccp(  ):

    """
    draw 12 spheres around 1
    """

    scene = setscene( )
    scene.select( )

    # 26 points in space (as sums of Qrays)
    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
    i,j,k,l,m,n = a+b, a+c, a+d, b+c, b+d, c+d
    o,p,q,r,s,t = i+j, i+k, i+l, i+m, n+j, n+k
    u,v,w,x,y,z = n+l, n+m, j+l, l+m, m+k, k+j

    # 12 around...
    for locus in [o,p,q,r,s,t,u,v,w,x,y,z]:
        ball = sphere(pos = locus.xyz, color = color.orange, radius = 0.5)

    # 1 at the center (nuclear ball)
    center = sphere(pos = (0,0,0), color = color.red, radius = 0.5)

    print "OK, done..."
    return

if __name__ == "__main__":
    ccp( )

 

PREV | NEXT | TOC | HOME