from visual import *

class H2O:
    "water molecule"
    def __init__(self, p):
        self.f = frame(pos = p)
        dy = tan(52.25*pi/180)
        h = 1/(sin(52.25))
        self.O = sphere(radius = 1, pos=(0,0,0),color = (0,0,1), frame = self.f)
        self.H1 = sphere(radius = 0.5, pos=(-dy,1,0), color = (.9,1,.9), frame = self.f)
        self.H2 = sphere(radius = 0.5, pos=(dy,1,0), color = (.9,1,.9), frame = self.f)
        self.b1 = cylinder(radius = 0.1, pos = (0,0,0), axis=(-dy,1,0), color=(1,0,0), frame = self.f)
        self.b2 = cylinder(radius = 0.1, pos = (0,0,0), axis=(dy,1,0), color=(1,0,0), frame = self.f)
        self.wplab = label(pos=(0,1.25,0),text="+", height =20, frame = self.f)
        self.wnlab = label(pos=(0,-1.25,0),text="-", height =20, frame = self.f)
        self.Olab = label(pos=self.O.pos,text="O", height =40, opacity = 0, box=0, frame = self.f)
        self.H1lab = label(pos=self.H1.pos,text="H", height =30, opacity = 0, box=0, frame = self.f)
        self.H2lab = label(pos=self.H2.pos,text="H", height =30, opacity = 0, box=0, frame = self.f)

class CO2:
    "carbon dioxide molecule"
    def __init__(self, p):
        self.f = frame(pos = p)
        dy = tan(45*pi/180)
        h = 1/(sin(180))
        self.C = sphere(radius = .7, pos=(0,0,0),color = (.1,.1,.1), frame = self.f)
        self.O1 = sphere(radius = 1, pos=(-1.75,0,0), color = (1,.1,.1), frame = self.f)
        self.O2 = sphere(radius = 1, pos=(1.75,0,0), color = (1,.1,.1), frame = self.f)
        self.b1 = cylinder(radius = 0.1, pos = (0,0,0), axis=(-1,0,0), color=(1,1,0), frame = self.f)
        self.b2 = cylinder(radius = 0.1, pos = (0,0,0), axis=(1,0,0), color=(1,1,0), frame = self.f)
        #self.plab = label(pos=(0,0,0),text="+", height =20, frame = self.f)
        #self.nlab = label(pos=(0,0,0),text="-", height =20, frame = self.f)
        self.Clab = label(pos=self.C.pos,text="C", height =40, opacity = 0, box=0, frame = self.f)
        self.O1lab = label(pos=self.O1.pos,text="O", height =30, opacity = 0, box=0, frame = self.f)
        self.O2lab = label(pos=self.O2.pos,text="O", height =30, opacity = 0, box=0, frame = self.f)


class CH4:
    "carbon dioxide molecule"
    def __init__(self, p):
        self.f = frame(pos = p)
        dy = tan(109*pi/180)
        h = 1/(sin(180))
        self.C = sphere(radius = .7, pos=(0,0,0),color = (.1,.1,.1), frame = self.f)
        self.H1 = sphere(radius = .5, pos=(-1.0,0,0), color = (1,.1,.1), frame = self.f)
        self.H2 = sphere(radius = .5, pos=(.5,.86,0), color = (1,.1,.1), frame = self.f)
        self.H3 = sphere(radius = .5, pos=(.5,-.5,.7), color = (1,.1,.1), frame = self.f)
        self.H4 = sphere(radius = .5, pos=(.5,-.5,-.7), color = (1,.1,.1), frame = self.f)
        self.b1 = cylinder(radius = 0.1, pos = (0,0,0), axis=(-1,0,0), color=(1,1,0), frame = self.f)
        self.b2 = cylinder(radius = 0.1, pos = (0,0,0), axis=(.5,.86,0), color=(1,1,0), frame = self.f)
        self.b3 = cylinder(radius = 0.1, pos = (0,0,0), axis=(.5,-.5,.7), color=(1,1,0), frame = self.f)
        self.b4 = cylinder(radius = 0.1, pos = (0,0,0), axis=(.5,-.5,.7), color=(1,1,0), frame = self.f)
        #self.plab = label(pos=(0,0,0),text="+", height =20, frame = self.f)
        #self.nlab = label(pos=(0,0,0),text="-", height =20, frame = self.f)
        self.Clab = label(pos=self.C.pos,text="C", height =30, opacity = 0, box=0, frame = self.f)
        self.H1lab = label(pos=self.H1.pos,text="H", height =20, opacity = 0, box=0, frame = self.f)
        self.H2lab = label(pos=self.H2.pos,text="H", height =20, opacity = 0, box=0, frame = self.f)
        self.H3lab = label(pos=self.H3.pos,text="H", height =20, opacity = 0, box=0, frame = self.f)
        self.H4lab = label(pos=self.H4.pos,text="H", height =20, opacity = 0, box=0, frame = self.f)

class NaCl:
    "Sodium Coloride molecule"
    def __init__(self, p):
        self.f = frame(pos = p)
        dy = tan(180*pi/180)
        h = 1/(sin(90))
        self.Cl = sphere(radius = 8.0, pos=(0,-7.1,0),color = (1,.1,.1), frame = self.f)
        self.Na = sphere(radius = 5.0, pos=(0,4.55,0), color = (.1,.1,1), frame = self.f)
        self.b1 = cylinder(radius = 0.1, pos = (0,0,0), axis=(0,1,0), color=(1,0,0), frame = self.f)
        self.wplab = label(pos=(0,10.1,0),text="+", height =20, frame = self.f)
        self.wnlab = label(pos=(0,-16.2,0),text="-", height =20, frame = self.f)
        self.Cllab = label(pos=self.Cl.pos,text="Cl", height =40, opacity = 0, box=0, frame = self.f)
        self.Nalab = label(pos=self.Na.pos,text="Na", height =30, opacity = 0, box=0, frame = self.f)
 

class Si:
    "Sodium Coloride molecule"
    def __init__(self, p):
        self.f = frame(pos = p)
        dy = tan(180*pi/180)
        h = 1/(sin(90))
        self.Si = sphere(radius = 11.1, pos=(0,0,0),color = (.1,.4,.4), frame = self.f)
        #self.b1 = cylinder(radius = 0.1, pos = (0,0,0), axis=(0,1,0), color=(1,0,0), frame = self.f)
        #self.wplab = label(pos=(0,1.1,0),text="+", height =20, frame = self.f)
        #self.wnlab = label(pos=(0,-2.2,0),text="-", height =20, frame = self.f)
        self.Silab = label(pos=self.Si.pos,text="Si", height =40, opacity = 0, box=0, frame = self.f)
 

class Au:
    "Gold atom"
    def __init__(self, p):
        self.f = frame(pos = p)
        dy = tan(180*pi/180)
        h = 1/(sin(90))
        self.Au = sphere(radius = .45, pos=(0,0,0),color = (.8,.9,.3), frame = self.f)
        #self.b1 = cylinder(radius = 0.1, pos = (0,0,0), axis=(0,1,0), color=(1,0,0), frame = self.f)
        #self.wplab = label(pos=(0,1.1,0),text="+", height =20, frame = self.f)
        #self.wnlab = label(pos=(0,-2.2,0),text="-", height =20, frame = self.f)
        #self.Aulab = label(pos=self.Si.pos,text="Au", height =40, opacity = 0, box=0, frame = self.f)
 
