def __init__(self):
        self.sphereList = []  #sphere for each node
        self.rodList = []  #unused
        self.manageRodList = [
        ]  #rods connecting nodes to centre management node

        r = 1.0  #radius of circle that nodes are in
        delta_theta = (2.0 * math.pi) / G.NUMNODES  #angle between nodes
        theta = 0

        self.management = v.sphere(
            pos=v.vector(0, 0, 0), radius=0.1,
            colour=v.color.blue)  #management node in centre
        self.label = v.label(
            pos=(1, 1, 0),
            text='0')  #label for amount of disparities at that point in time
        self.label_cum = v.label(pos=(-1, 1, 0),
                                 text='0')  #cumulative total number of above

        for i in range(0, G.NUMNODES):
            circ = v.sphere(pos=v.vector(r * math.cos(theta),
                                         r * math.sin(theta), 0),
                            radius=0.1,
                            color=v.color.green)
            self.sphereList.append(circ)
            print 'circle no. ', i, ' coords ', r * math.cos(
                theta), ' ', r * math.sin(theta)
            theta += delta_theta
            rod = v.cylinder(pos=(0, 0, 0),
                             axis=(self.sphereList[i].pos),
                             radius=0.005,
                             color=v.color.white)
            self.manageRodList.append(rod)
Пример #2
0
def go():
    r = np.array([1.017, 0.0])  # initial x,y position for earth
    v = np.array([0.0, 6.179])  # initial vx, vy

    # draw the scene, planet earth/path, sun/sunlight
    scene = vp.display(
        title='Planetary motion',  # scene start 
        background=(.2, .5, 1),
        forward=(0, 2, -1))
    planet = vp.sphere(pos=r,
                       radius=0.1,
                       make_trail=True,
                       material=vp.materials.earth,
                       up=(0, 0, 1))
    sun = vp.sphere(pos=(0, 0),
                    radius=0.2,
                    color=vp.color.yellow,
                    material=vp.materials.emissive)
    sunlight = vp.local_light(pos=(0, 0), color=vp.color.yellow)  #scn end

    t, h = 0.0, 0.001
    while True:
        vp.rate(200)  # limit animation speed
        r, v = ode.leapfrog(earth, r, v, t, h)  # integrate
        planet.pos = r  # move planet
        if (scene.kb.keys): scene.kb.getkey(), scene.kb.getkey()  #pause
Пример #3
0
def show_protective(nparticles):
    # create scene
    scene = visual.display(title='Protective zones', width=600, height=400, center=(0,0,0))
    scene.select()

    # read in positions, state and protective zones
    positions = (numpy.genfromtxt('position.dat'))[:nparticles]
    state = (numpy.genfromtxt('state.dat'))[:nparticles]
    zones = (numpy.genfromtxt('fpt.dat'))[:nparticles]

    # go through particles and display them
    for i in range(nparticles):
        # color the spheres according to state
        cball = visual.color.green

        if (state[i,0]==1):
            cball = visual.color.red
        else:
            cball = visual.color.blue

        if (state[i,3]==1):
            cball = visual.color.yellow
            
        if (state[i,3]==2):
            cball = visual.color.orange

        visual.sphere(pos=(positions[i,0], positions[i,1], positions[i,2]), radius=zones[i], color=cball)
        visual.label(pos=(positions[i,0], positions[i,1], positions[i,2]), text='{0:d}'.format(i))
Пример #4
0
    def show_ladybug(self, H=None):
        '''Show Ladybug in Visual Python at origin or at the translated position
        if parameter is given.

        TODO: Implement an additional translation H and show at new position.'''
#        vis.ellipsoid(width=0.12, length=0.08, height=0.08,
#                      color=vis.color.red, opacity=0.2)
        vis.arrow(axis=(0.04, 0, 0), color=(1,0,0) )
        vis.arrow(axis=(0, 0.04, 0), color=(0,1,0) )
        vis.arrow(axis=(0, 0, 0.04), color=(0,0,1) )
        colors = [vis.color.red, vis.color.green, vis.color.blue,
                  vis.color.cyan, vis.color.yellow, vis.color.magenta]
        for P in self.LP:
            R = P[:3,:3]
            pos = dot(P[:3],r_[0,0,0,1])
            pos2 = dot(P[:3],r_[0,0,0.01,1])
            vis.sphere(pos=pos, radius=0.002, color=colors.pop(0))
            vis.box(pos=pos2, axis=dot(R, r_[0,0,1]).flatten(),
                    size=(0.001,0.07,0.09), color=vis.color.red,
                    opacity=0.1)
            vis.arrow(pos=pos,
                      axis=dot(R, r_[0.02,0,0]).flatten(),
                      color=(1,0,0), opacity=0.5 )
            vis.arrow(pos=pos,
                      axis=dot(R, r_[0,0.02,0]).flatten(),
                      color=(0,1,0), opacity=0.5 )
            vis.arrow(pos=pos,
                      axis=dot(R, r_[0,0,0.02]).flatten(),
                      color=(0,0,1), opacity=0.5 )
Пример #5
0
def Ch3_Prob5(time):
	base = 57.9#base for distance from the sun. (x = 1 means 57.9 km )
	rad_base = 10*2440#base for the radius of the planets size of each
	#Per_base = 88# base for the period
	
	sun = sphere(pos = [0,0,0], radius = .5)
	mercu = sphere(pos = [(57.90/base), 0, 0], radius = (2440.0/rad_base))
	venus = sphere(pos = [(108.2/base), 0, 0], radius = (6052.0/rad_base))
	earth = sphere(pos = [(149.6/base), 0, 0], radius = (6371.0/rad_base))
	marss = sphere(pos = [(227.6/base), 0, 0], radius = (3386.0/rad_base))
	
	#frequencies
	Fmerc = 2*pi/88
	Fvenu = 2*pi/224.7
	Feart = 2*pi/365.3
	Fmars = 2*pi/687.0
	
	#colors
	sun.color = color.yellow
	mercu.color = color.gray(0.5)
	earth.color = color.blue
	marss.color = color.red
	
	for t in arange(0,time,0.01):
		#print t
		rate(100)
		mercu.pos = [(57.90/base)*cos(Fmerc*t), (57.90/base)*sin(Fmerc*t), 0]
		venus.pos = [(108.2/base)*cos(Fvenu*t), (108.2/base)*sin(Fvenu*t), 0]
		earth.pos = [(149.6/base)*cos(Feart*t), (149.6/base)*sin(Feart*t), 0]
		marss.pos = [(227.6/base)*cos(Fmars*t), (227.6/base)*sin(Fmars*t), 0]
	return 'done'
Пример #6
0
 def draw_node_list(self, radius=2.0):
     if self._nodes == None:
         print "ERROR: you have to set/load node list before drawing them."
         exit(1)
     for i in range(1,len(self._nodes)):
         x, y = self._nodes[i][0], self._nodes[i][1]
         vs.sphere(display=self.route_window, pos=vs.vector(x,y,0),
                   radius=radius, color=vs.color.blue)
Пример #7
0
def sphere():
    from visual import sphere,color
    L = 5
    R = 0.3
    for i in range(-L,L+1):
        for j in range(-L,L+1):
            for k in range(-L,L+1):
                sphere(pos=[i,j,k],radius=R,color=color.blue)
Пример #8
0
def main():
    from visual import sphere
    L = 5
    R = 0.3
    for i in range(-L, L + 1):
        for j in range(-L, L + 1):
            for k in range(-L, L + 1):
                sphere(pos=[i, j, k], radius=R)
Пример #9
0
def set_scene(r):   # r = position of test body
    vp.display(title='Restricted 3body', background=(1,1,1))
    body = vp.sphere(pos=r, color=(0,0,1), radius=0.03, make_trail=1)
    sun = vp.sphere(pos=(-a,0), color=(1,0,0), radius=0.1)
    jupiter = vp.sphere(pos=(b, 0), color=(0,1,0), radius=0.05)
    circle = vp.ring(pos=(0,0), color=(0,0,0), thickness=0.005,
                     axis=(0,0,1), radius=1)      # unit circle
    return body
Пример #10
0
def main():
    if len(argv) < 3:
        raise Exception('>>> ERROR! Please supply values for black hole mass [>= 1.0] and spin [0.0 - 1.0] <<<')
    m = float(argv[1])
    a = float(argv[2])
    horizon = m * (1.0 + sqrt(1.0 - a * a))
    cauchy = m * (1.0 - sqrt(1.0 - a * a))
    #  set up the scene
    scene.center = (0.0, 0.0, 0.0)
    scene.width = scene.height = 1024
    scene.range = (20.0, 20.0, 20.0)
    inner = 2.0 * sqrt(cauchy**2 + a**2)
    ellipsoid(pos = scene.center, length = inner, height = inner, width = 2.0 * cauchy, color = color.blue, opacity = 0.4)  # Inner Horizon
    outer = 2.0 * sqrt(horizon**2 + a**2)
    ellipsoid(pos = scene.center, length = outer, height = outer, width = 2.0 * horizon, color = color.blue, opacity = 0.3)  # Outer Horizon
    ergo = 2.0 * sqrt(4.0 + a**2)
    ellipsoid(pos = scene.center, length = ergo, height = ergo, width = 2.0 * horizon, color = color.gray(0.7), opacity = 0.2)  # Ergosphere
    if fabs(a) > 0.0:
        ring(pos=scene.center, axis=(0, 0, 1), radius = a, color = color.white, thickness=0.01)  # Singularity
    else:
        sphere(pos=scene.center, radius = 0.05, color = color.white)  # Singularity
    ring(pos=scene.center, axis=(0, 0, 1), radius = sqrt(isco(a)**2 + a**2), color = color.magenta, thickness=0.01)  # ISCO
    curve(pos=[(0.0, 0.0, -15.0), (0.0, 0.0, 15.0)], color = color.gray(0.7))
    #cone(pos=(0,0,12), axis=(0,0,-12), radius=12.0 * tan(0.15 * pi), opacity=0.2)
    #cone(pos=(0,0,-12), axis=(0,0,12), radius=12.0 * tan(0.15 * pi), opacity=0.2)
    #sphere(pos=(0,0,0), radius=3.0, opacity=0.2)
    #sphere(pos=(0,0,0), radius=12.0, opacity=0.1)
    # animate!
    ball = sphere()  # Particle
    counter = 0
    dataLine = stdin.readline()
    while dataLine:  # build raw data arrays
        rate(60)
        if counter % 1000 == 0:
            ball.visible = False
            ball = sphere(radius = 0.2)  # Particle
            ball.trail = curve(size = 1)  #  trail
        data = loads(dataLine)
        e = float(data['v4e'])
        if e < -120.0:
            ball.color = color.green
        elif e < -90.0:
            ball.color = color.cyan
        elif e < -60.0:
            ball.color = color.yellow
        elif e < -30.0:
            ball.color = color.orange
        else:
            ball.color = color.red
        r = float(data['r'])
        th = float(data['th'])
        ph = float(data['ph'])
        ra = sqrt(r**2 + a**2)
        sth = sin(th)
        ball.pos = (ra * sth * cos(ph), ra * sth * sin(ph), r * cos(th))
        ball.trail.append(pos = ball.pos, color = ball.color)
        counter += 1
        dataLine = stdin.readline()
Пример #11
0
 def marks(self):
     marks_list = []
     new_time = self.time
     while new_time >= 5:
         marks_list.append(int(new_time))
         new_time = new_time - 5.0
     marks_list.append(int(0))
     for marks in marks_list:
         sphere(pos=(marks, marks * 1.1, 0), radius=0, label=str(marks) + " seconds")
Пример #12
0
    def __init__(self, joint, num, length, height=LEGS_HEIGHT, width=LEGS_WIDTH):
        """
        """
        super(Tars3D, self).__init__(joint, num, length, height, width, (0, 0, 1))

        visual.cylinder(frame=self, pos=(0, 0, -(width+5)/2), radius=(height+1)/2, axis=(0, 0, 1), length=width+5, color=visual.color.cyan)
        visual.box(frame=self, pos=((length-5)/2, 0, 0), length=length-5/2, height=height, width=width , color=visual.color.yellow)
        visual.sphere(frame=self, pos=(length-5/2, 0, 0), radius=5)
        self.rotate(angle=math.radians(180), axis=self._axis)
Пример #13
0
def set_scene(R, r):        # create bodies, velocity arrows
    vp.display(title='Three-body motion', background=(1,1,1))
    body, vel = [], []      # bodies, vel arrows
    c = [(1,0,0), (0,1,0), (0,0,1), (0,0,0)]    # RGB colors
    for i in range(3):
        body.append(vp.sphere(pos=r[i],radius=R,color=c[i],make_trail=1))
        vel.append(vp.arrow(pos=body[i].pos,shaftwidth=R/2,color=c[i]))
    line, com = vp.curve(color=c[3]), vp.sphere(pos=(0,0), radius=R/4.)
    return body, vel, line
Пример #14
0
def set_scene(R, r):  # create bodies, velocity arrows
    vp.display(title='Three-body motion', background=(1, 1, 1))
    body, vel = [], []  # bodies, vel arrows
    c = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (0, 0, 0)]  # RGB colors
    for i in range(3):
        body.append(vp.sphere(pos=r[i], radius=R, color=c[i], make_trail=1))
        vel.append(vp.arrow(pos=body[i].pos, shaftwidth=R / 2, color=c[i]))
    line, com = vp.curve(color=c[3]), vp.sphere(pos=(0, 0), radius=R / 4.)
    return body, vel, line
Пример #15
0
 def draw_node_list(self, radius=2.0):
     if self._nodes == None:
         print "ERROR: you have to set/load node list before drawing them."
         exit(1)
     for i in range(1, len(self._nodes)):
         x, y = self._nodes[i][0], self._nodes[i][1]
         vs.sphere(display=self.route_window,
                   pos=vs.vector(x, y, 0),
                   radius=radius,
                   color=vs.color.blue)
Пример #16
0
 def addSmallSphere(self, point, colour=None, opacity=1., material=None):
     if not VISUAL_INSTALLED:
         return
     if colour == None:
         colour = visual.color.blue
     visual.sphere(pos=point,
                   radius=0.00012,
                   color=geo.norm(colour),
                   opacity=opacity,
                   materiall=material)
Пример #17
0
    def __init__(self, color=None, *args, **kwargs):
        """ Init CoordinatesSystem3D object
        """
        super(CoordinatesSystem3D, self).__init__(*args, **kwargs)

        if color is None:
            visual.sphere(frame=self, radius=3, color=visual.color.gray(0.5))
            visual.arrow(frame=self, axis=(1, 0,  0), length=30, color=visual.color.cyan)
            visual.arrow(frame=self, axis=(0, 0, -1), length=30, color=visual.color.magenta)
            visual.arrow(frame=self, axis=(0, 1,  0), length=30, color=visual.color.yellow)
Пример #18
0
def create_cube():
    visual.scene.range = (256, 256, 256)
    visual.scene.center = (128, 128, 128)

    t = range(0, 256, 51)
    for x in t:
        for y in t:
            for z in t:
                pos = x, y, z
                color = (x / 255.0, y / 255.0, z / 255.0)
                visual.sphere(pos=pos, radius=10, color=color)
Пример #19
0
def create_color_cube():
    visual.scene.range = (256, 256, 256)
    visual.scene.center = (128, 128, 128)
    color_dict, rgbs = color_list.read_colors()
    for rgb in color_dict.values():
        r = int(rgb[1:3], 16)
        g = int(rgb[3:5], 16)
        b = int(rgb[5:7], 16)
        pos = (r, g, b)
        color = (r / 255.0, g / 255.0, b / 255.0)
        visual.sphere(pos=pos, radius=10, color=color)
Пример #20
0
def set_scene(r):  # r = position of test body
    vp.display(title='Restricted 3body', background=(1, 1, 1))
    body = vp.sphere(pos=r, color=(0, 0, 1), radius=0.03, make_trail=1)
    sun = vp.sphere(pos=(-a, 0), color=(1, 0, 0), radius=0.1)
    jupiter = vp.sphere(pos=(b, 0), color=(0, 1, 0), radius=0.05)
    circle = vp.ring(pos=(0, 0),
                     color=(0, 0, 0),
                     thickness=0.005,
                     axis=(0, 0, 1),
                     radius=1)  # unit circle
    return body
Пример #21
0
def create_color_cube():
    visual.scene.range=(256,256,256)
    visual.scene.center=(128,128,128)
    color_dict,rgbs=color_list.read_colors()
    for rgb in color_dict.values():
        r=int(rgb[1:3],16)
        g=int(rgb[3:5],16)
        b=int(rgb[5:7],16)
        pos=(r,g,b)
        color=(r/255.0,g/255.0,b/255.0)
        visual.sphere(pos=pos,radius=10,color=color)
Пример #22
0
 def marks(self):
     marks_list = []
     new_time = self.time
     while (new_time >= 5):
         marks_list.append(int(new_time))
         new_time = new_time - 5.0
     marks_list.append(int(0))
     for marks in marks_list:
         sphere(pos=(marks, marks * 1.1, 0),
                radius=0,
                label=str(marks) + ' seconds')
Пример #23
0
 def addSphere(self, sphere, colour=None, opacity=1., material=None):
     """docstring for addSphere"""
     if not Visualiser.VISUALISER_ON:
         return
     
     if isinstance(sphere, geo.Sphere):
         if colour == None:
             colour = visual.color.red
         if np.allclose(np.array(colour), np.array([0,0,0])):
             visual.sphere(pos=sphere.centre, radius=sphere.radius, opacity=opacity, material=material)
         else:
             visual.sphere(pos=sphere.centre, radius=sphere.radius, color=geo.norm(colour), opacity=opacity, material=material)
Пример #24
0
def PlotElevator(filename):
  try:
    f = open(filename,'r')
    data = json.loads(f.read())
    f.close()
  except Exception as e:
    return str(e)

  print(data["L0"])
  pos = []
  for i in range(data["SavedSteps"]):
    if not None in [elem for s1 in data["Position"][i] for elem in s1]:
      pos.append(data["Position"][i])
    else:
      break

  pos = array(pos)
  vel = array(data["Velocity"])
  scene = vs.display(title='3D representation', x=500, y=0, width=1920, height=1080, background=(0,0,0), center=pos[0][-1])
  string = vs.curve(pos=pos[0], radius=50)
  earth = vs.sphere(radius=R_earth_equator)
  asteroid = vs.sphere(pos=pos[0][-1],radius=1e3, color=vs.color.red)
  anchor = vs.sphere(pos=pos[0][0],radius=1e2, color=vs.color.green)

  label_avg_l0 = vs.label(pos=pos[0][-1], text="t: %3.1f" % (data["Time"][0],))

  body = 1
  nt = 0
  while True:
    vs.rate(60)
    if scene.kb.keys: # event waiting to be processed?
        s = scene.kb.getkey() # get keyboard info
        if s == "d":
          if body == -1:
            body = 0
          elif body == 0:
            body = 1
          else:
            body = -1

    if body == 1:
      scene.center = (0,0,0)
    else:
      scene.center = pos[nt][body]
    string.pos=pos[nt]
    asteroid.pos=pos[nt][-1]
    anchor.pos=pos[nt][0]
    label_avg_l0.pos = asteroid.pos
    label_avg_l0.text = "t: %3.1f" % (data["Time"][nt],)
    if nt + 1 >= pos.shape[0]:
      nt = 0
    else:
      nt += 1
Пример #25
0
def set_scene(r):     # r = init position of planet
    # draw scene, mercury, sun, info box, Runge-Lenz vector
    scene = vp.display(title='Precession of Mercury', 
                       center=(.1*0,0), background=(.2,.5,1))
    planet= vp.sphere(pos=r, color=(.9,.6,.4), make_trail=True,
                      radius=0.05, material=vp.materials.diffuse)
    sun   = vp.sphere(pos=(0,0), color=vp.color.yellow,
                      radius=0.02, material=vp.materials.emissive)
    sunlight = vp.local_light(pos=(0,0), color=vp.color.yellow)
    info = vp.label(pos=(.3,-.4), text='Angle') # angle info
    RLvec = vp.arrow(pos=(0,0), axis=(-1,0,0), length = 0.25)
    return planet, info, RLvec
Пример #26
0
def create_cube():
    visual.scene.range=(256,256,256)
    visual.scene.center=(128,128,128)


    t=range(0,256,51)
    for x in t:
        for y in t:
            for z in t:
                pos=x,y,z
                color=(x/255.0,y/255.0,z/255.0)
                visual.sphere(pos=pos,radius=10,color=color)
Пример #27
0
 def addSmallSphere(self, point, colour=None, opacity=1.0):
     if not Visualiser.VISUALISER_ON:
         return
     if colour is None:
         colour = visual.color.blue
     try:
         colour = visual.vec(*colour)
     except TypeError:
         pass
     point = tuple(point)
     pos = visual.vec(*point)
     visual.sphere(pos=pos, radius=0.00012, color=norm(colour), opacity=opacity)
Пример #28
0
 def addSphere(self, sphere, colour=None, opacity=1.):
     """docstring for addSphere"""
     if not Visualiser.VISUALISER_ON:
         return
     
     if isinstance(sphere, Sphere):
         if colour == None:
             colour = visual.color.red
         if np.allclose(np.array(colour), np.array([0,0,0])):
             visual.sphere(pos=visual.vec(sphere.centre), radius=sphere.radius, opacity=opacity)
         else:
             visual.sphere(pos=visual.vec(sphere.centre), radius=sphere.radius, color=norm(colour), opacity=opacity)
Пример #29
0
 def addSphere(self, sphere, colour=None, opacity=1., material=visual.materials.plastic):
     """docstring for addSphere"""
     if not Visualiser.VISUALISER_ON:
         return
     
     if isinstance(sphere, geo.Sphere):
         if colour == None:
             colour = visual.color.red
         if np.allclose(np.array(colour), np.array([0,0,0])):
             visual.sphere(pos=sphere.centre, radius=sphere.radius, opacity=opacity, material=material)
         else:
             visual.sphere(pos=sphere.centre, radius=sphere.radius, color=geo.norm(colour), opacity=opacity, material=material)
Пример #30
0
def generate_obstacles(n):
	from random import randint

	obstacles = []

	for i in range(n):
		x = randint(RADIUS, WIDTH - RADIUS)
		y = randint(RADIUS, LENGTH - RADIUS)
		obstacles.append( (x, y) )
		sphere(pos = vector(x, RADIUS, y), radius = RADIUS,
			   color = color.red)

	return obstacles
Пример #31
0
    def render_updates(self):
        if self.object is None:
            return

        if abs(self.last_trail_at -
               PhysicalObject.get_total_time()) > TRAIL_AFTER_TIME:
            # if(self.trail_count >= NUM_TRAILS)
            sphere(pos=self.object.pos,
                   radius=RADIUS_TRAIL,
                   color=self.object.color)
            # print("Trail created")
            self.last_trail_at = PhysicalObject.get_total_time()

        self.object.pos = self.get_scaled_pos()
Пример #32
0
def sodium_chloride(side):
    from visual import sphere,color
    from numpy import sqrt,array

    sodium_r = 190
    chloride_r = 79
    rbigger = max(sodium_r,chloride_r)
    rsmaller = min(sodium_r,chloride_r)
    sodium_big = sodium_r == rbigger

    spacing = (rsmaller+rbigger)

    sodium_color = color.red
    chloride_color = color.green

    for x in range(side):
        for y in range(side):
            for z in range(side):
                sphere(pos=2*spacing*array([x,y,z]),
                    radius=sodium_r if sodium_big else chloride_r,
                    color=sodium_color if sodium_big else chloride_color)
                sphere(pos=2*spacing*array([x+.5,y,z]),
                    radius=chloride_r if sodium_big else sodium_r,
                    color=chloride_color if sodium_big else chloride_color)
                sphere(pos=2*spacing*array([x,y+.5,z]),
                    radius=chloride_r if sodium_big else sodium_r,
                    color=chloride_color if sodium_big else chloride_color)
                sphere(pos=2*spacing*array([x,y,z+.5]),
                    radius=chloride_r if sodium_big else sodium_r,
                    color=chloride_color if sodium_big else chloride_color)
def draw_spatial_center(mol):
    xyz = [0, 0, 0]
    tot = 0
    for at in mol.atoms:
        tot += at.mass

    for at in mol.atoms:
        c = at.mass
        xyz[0] += at.x * c
        xyz[1] += at.y * c
        xyz[2] += at.z * c
    xyz[0] /= tot
    xyz[1] /= tot
    xyz[2] /= tot
    sphere(pos=xyz, radius=0.5, color=color.blue)
def draw_spatial_center(mol):
    xyz = [0,0,0]
    tot = 0
    for at in mol.atoms:
        tot+= at.mass

    for at in mol.atoms:
        c = at.mass
        xyz[0] += at.x*c
        xyz[1] += at.y*c
        xyz[2] += at.z*c
    xyz[0]/= tot
    xyz[1]/= tot
    xyz[2]/= tot
    sphere(pos= xyz,radius=0.5,color=color.blue)
Пример #35
0
 def sCaidalibre(self):
     self.alturaCL=self.alturaCL.get()
     self.velocidadX=self.velocidadX.get()
     try:
         self.alturaCL=float(self.alturaCL)
         self.velocidadX=float(self.velocidadX)
     except:
         self.alerta()
     gdpos=vgraph.gdisplay(x=600,y=0,xtitle='Tiempo',ytitle='Posicion(y)')
     plotpos=vgraph.gcurve(gdisplay=gdpos,color=vs.color.red)
     gdvel=vgraph.gdisplay(x=600,y=600,xtitle='Velocidad',ytitle='Tiempo')
     plotvel=vgraph.gcurve(gdisplay=gdvel,color=vs.color.blue)
     gdacl=vgraph.gdisplay(x=0,y=900,xtitle='Aceleracion',ytitle='Tiempo')
     plotacl=vgraph.gcurve(gdisplay=gdacl,color=vs.color.blue)
     suelo=vs.box(pos=(0,-5,0),length=30,height=0.1,width=1,color=vs.color.blue)
     esferaC=vs.sphere(pos=(0,self.alturaCL,-2),radius=1,color=vs.color.red)
     T=np.sqrt(2*(self.alturaCL+5)/9.8)
     t=0
     while t<T:
         esferaC.pos=(self.velocidadX*t,self.alturaCL-9.8*t**2/2,-2)
         plotpos.plot(pos=(t,self.alturaCL-9.8*t**2/2))
         plotvel.plot(pos=(t,-9.8*t))
         plotacl.plot(pos=(t,-9.8))
         t+=0.001
         vs.rate(100)
Пример #36
0
def draw_axes():
    global x_axis,y_axis,z_axis,axis_ball

    if x_axis:
        x_axis.visible=False
        x_axis=None
    if y_axis:
        y_axis.visible=False
        y_axis=None
    if z_axis:
        z_axis.visible=False
        z_axis=None
    if axis_ball:
        axis_ball.visible=False
        axis_ball=None


    if not axis_enabled:
        return
    use_x=min_x!=max_x
    use_y=min_y!=max_y
    use_z=min_z!=max_z

    zero_coord=(min_x / (min_x - max_x),min_y / (min_y - max_y),min_z / (min_z - max_z))

    if use_x:
        x_axis = visual.arrow(pos=zero_coord, axis=(.3,0,0), shaftwidth=0.01, color=visual.color.red)
    if use_y:
        y_axis = visual.arrow(pos=zero_coord, axis=(0,.3,0), shaftwidth=0.01, color=visual.color.green)
    if use_z:
        z_axis = visual.arrow(pos=zero_coord, axis=(0,0,.3), shaftwidth=0.01, color=visual.color.blue)
    axis_ball = visual.sphere(pos=zero_coord, radius=.02, color=visual.color.yellow)
Пример #37
0
 def run(self):
     '''
     Run the simulation with racers that had been previously added to the world
     by add_racer method.
     '''
     # create the scene with the plane at the top
     visual.scene.center = visual.vector(0,-25,0)
     visual.box(pos=(0,0,0), size=(12,0.2,12), color=visual.color.green)
     # create the visual objects that represent the racers (balls)
     balls = [ visual.sphere(pos=(index,0,0), radius=0.5) for index in xrange(len(self.racers))]
     for ball, racer in zip(balls, self.racers):
         color = visual.color.blue
         try:
             # try to set the color given by a string
             color = getattr(visual.color, racer.color)
         except AttributeError:
             pass
         ball.trail  = visual.curve(color=color)
     while not reduce(lambda x, y: x and y, [racer.result for racer in self.racers]):
         # slow down the looping - allow only self.time_calibration
         # number of loop entries for a second
         visual.rate(self.time_calibration)
         # move the racers
         for racer in self.racers:
             self.__move_racer(racer) 
             
         for ball, racer in zip(balls, self.racers):
             ball.pos.y = -racer.positions[-1][1]
             ball.pos.x = racer.positions[-1][0]
             ball.trail.append(pos=ball.pos)
             
         self.current_time += self.interval
         self.timeline.append(self.current_time)
Пример #38
0
def Ch3_Exa3():
	s = sphere(pos=[1,0,0],radius=0.1)
	for theta in arange(0,10*pi,0.1):
		rate(1)
		x= cos(theta)
		y = sin (theta)
		s.pos = [x,y,0]
Пример #39
0
def calculate(x, y, z, vx, vy, vz, dt, m, g, B2, S0, omega):
    """ Calculate the trajectory of a baseball including air resistance and spin by
repeatedly calling the do_time_step function.  Also draw the trajectory using visual python. """
    t = 0.0
    # Establish lists with initial position and velocity components and time.
    x_list = [x]
    y_list = [y]
    z_list = [z]
    vx_list = [vx]
    vy_list = [vy]
    vz_list = [vz]
    t_list = [t]

    # Set up visual elements.
    mound = visual.box(pos=(0,0,0), length=0.1, width=0.5, height=0.03, color=visual.color.white)
    plate = visual.box(pos=(18,0,0), length=0.5, width=0.5, height=0.03, color=visual.color.white)
    ball = visual.sphere(pos=(x,y,z), radius=0.05, color=visual.color.white)
    ball.trail = visual.curve(color=ball.color)

    while y >= 0.0:
        visual.rate(100) # Limit to no more than 100 iterations per second.
        t, x, y, z, vx, vy, vz = do_time_step(t, dt, x, y, z, vx, vy, vz, m, B2, g, S0, omega)
        x_list.append(x)
        y_list.append(y)
        z_list.append(z)
        vx_list.append(vx)
        vy_list.append(vy)
        vz_list.append(vz)
        t_list.append(t)
        ball.pos = (x,y,z)
        ball.trail.append(pos=ball.pos)

    return t_list, x_list, y_list, z_list, vx_list, vy_list, vz_list
Пример #40
0
def add(i,j,time=tau):
	grid[i,j]=True
	s = sphere(radius=0.5)
	s.pos = i,j #i-50,j-50
	
	color = 1 #time/tau#(1-1*exp(-t/tau)) 
	s.color = color,color,color
Пример #41
0
def draw_crystal(r, attr, types):
	# draw atoms
	for i in range(len(r)):
		xyz,s = np.array(r[i]),np.array(attr[i])
		#choose colour depending on spin direction (make the col vector the unit vector)
		if (s[0]==0 and s[1]==0 and s[2]==0):
			col = np.array((0,0,0))
		else:
			col = s/np.sqrt(np.dot(s,s))
			#and if any are less than zero, add the complementary
			if col[0] < 0:
				col[1]-= col[0]
				col[2] -=col[0]
				col[0] = 0
			if col[1] < 0:
				col[0]-= col[1]
				col[2] -=col[1]
				col[1] = 0
			if col[2] < 0:
				col[0]-= col[2]
				col[1] -=col[2]
				col[2] = 0
		spingro = 0.2 #because mu_B is 10^-24, so we need to make it about ~10^-10 to display
		print xyz,s
		pointer = v.arrow(pos=xyz-s*spingro/2, axis=s*spingro, color=col)
		#draw spheres on the atom sites
		colour,size = atom_colours(types[i])
		pointer = v.sphere(pos=xyz, color=colour, radius=0.1*size)
Пример #42
0
    def _displayAtoms(self):
        """Display the position of atoms in the system.

        Call this the first time to display the atoms on the visual.
        Call it again to update all the positions.  You don't need to
        re-make the box at every step, it behaves smartly and just
        moves the particles around.
        """
        if visual is None:
            return
        vizColors = self.vizColors
        vizRadius = self.vizRadius
        atoms = self._atoms
        S = self.S
        # Now go add/update all atom positions, etc.
        for i in range(self.S.N):
            pos =    S.atompos[i]
            coords = S.coords(pos, raw=True)
            type_ =  S.atomtype[i]
            radius = vizRadius.get(type_, self.radius)
            color = vizColors.get(type_, visual.color.white)
            # create the particle if not existing yet:
            if len(atoms) <= i:
                atoms.append(visual.sphere(pos=coords, radius=radius))
                atoms[i].opacity = .2
            # update it if it's already there (yes, it re-sets pos...)
            atoms[i].visible = 1
            atoms[i].pos = coords
            if not hasattr(atoms[i], 's12viz'):
                atoms[i].color = color
            atoms[i].radius = radius
        # hide all higher particle numbers:
        for i in range(self.S.N, len(atoms)):
            atoms[i].visible = 0
Пример #43
0
    def __init__(self, pos=(-20, 0, 10), axis=(0, 5, 1), radius=.5, length=0):
        """
        Construct it with a preset or given geometry.
        """
        # calibration (see: calibrate(value))
        self.zero = None

        # a cylinders length MUST NEVER be '0' in pvisual ...
        if length == 0:
            length = 0.000001

        # color and material
        self.hot_color = (1, 0, 0)
        ### for now say: below zero this liquid is expanding...
        self.cold_color = (0.4, 0.4, 1)
        opacity = 1
        material = materials.rough

        # visualize the reservoir
        self.reservoir = sphere(pos=pos, radius=radius*4, color=self.hot_color,\
                            opacity=opacity, material=material)
        # visualize the expander
        self.expander = cylinder(pos=pos, axis=axis, radius=radius,\
                            length=length, color=self.hot_color,\
                            opacity=opacity, material=material)
        # add a label
        p = self.calc_label_pos(pos)
        self.label = label(pos=p, text=u'T: 0.0\xb0C')
Пример #44
0
def golf_ball_calc(x,y,z,vx,vy,vz,dt,m,g,B2,S0,w,w_vector):
    t = 0.0
    x_list = [x]
    y_list = [y]
    z_list = [z]
    vx_list = [vx]
    vy_list = [vy]
    vz_list = [vz]
    t_list = [t]
    v_vector = visual.vector(vx,vy,vz)

    tee = visual.box(pos=(0,0,0), length=0.05, width=0.05, height=0.5,color=visual.color.white)
    ball = visual.sphere(pos=(x,y,z), radius = 0.25, color = visual.color.white)
    ball.trail = visual.curve(color = visual.color.red)

    while y > 0.0:
        visual.rate(100)
        t,x,y,z,vx,vy,vz = golfball_step(t,x,y,z,vx,vy,vz,m,g,B2,S0,w,dt,w_vector,v_vector)
        x_list.append(x)
        y_list.append(y)
        z_list.append(z)
        vx_list.append(vx)
        vy_list.append(vy)
        vz_list.append(vz)
        t_list.append(t)
        v_vector = visual.vector(vx,vy,vz)
        ball.pos = (x,y,z)
        ball.trail.append(pos=ball.pos)

    return t_list,x_list,y_list,z_list,vx_list,vy_list,vz_list
Пример #45
0
 def sResorte(self):
     self.kR=self.kR.get()
     self.masaR=self.masaR.get()
     try:
         self.kR=float(self.kR)
         self.masaR=float(self.masaR)
     except:
         self.alerta()
     gdpos=vgraph.gdisplay(x=600,y=0,xtitle='Tiempo',ytitle='Posicion')
     plotpos=vgraph.gcurve(gdisplay=gdpos,color=vs.color.red)
     gdvel=vgraph.gdisplay(x=600,y=600,xtitle='Velocidad',ytitle='Tiempo')
     plotvel=vgraph.gcurve(gdisplay=gdvel,color=vs.color.blue)
     gdacl=vgraph.gdisplay(x=0,y=900,xtitle='Aceleracion',ytitle='Tiempo')
     plotacl=vgraph.gcurve(gdisplay=gdacl,color=vs.color.green)
     resorte=vs.helix(pos=(0,5,0),axis=(0,0,-1),radius=0.5,color=vs.color.red)
     resfera=vs.sphere(pos=(0,0,0),radius=0.7,color=vs.color.blue)
     t=0
     while t<=100:
         resorte.axis=(0,-5+3*np.cos(np.sqrt(self.kR/self.masaR)*t),-1)
         resfera.pos=(0,3*np.cos(np.sqrt(self.kR/self.masaR)*t),0)
         plotpos.plot(pos=(t,3*np.cos(np.sqrt(self.kR/self.masaR)*t)))
         plotvel.plot(pos=(t,-3*np.sqrt(self.kR/self.masaR)*np.sin(np.sqrt(self.kR/self.masaR)*t)))
         plotacl.plot(pos=(t,-3*(self.kR/self.masaR)*np.cos(np.sqrt(self.kR/self.masaR)*t)))
         t+=0.01
         vs.rate(100)
    def __init__(self, net):
        self.sphereList = []  #list to hold the nodes (as vPython spheres)
        self.rodList = []  #list to hold the edges (as vPython cylinders)
        self.Net = net  #NetworkCreation instance passed by reference
        print 'Start visualising'

        r = 1.0  #radius of circle that nodes are in
        delta_theta = (2.0 * math.pi) / len(
            self.Net.nodeList)  #calculate angle between nodes
        theta = 0  #start 'counter' theta at zero

        for N in self.Net.nodeList:
            sph = v.sphere(pos=v.vector(r * math.cos(theta),
                                        r * math.sin(theta), 0),
                           radius=0.015,
                           color=v.color.green)
            #for each node create a sphere in a position on the circumference of the circle
            self.sphereList.append(sph)  #add this sphere to the list
            theta += delta_theta  #increment the angle by the calculated delta_theta
        for E in self.Net.edgeList:  #for each edge...
            pos1 = self.sphereList[E[
                0]].pos  #take positions of the corresponding nodes from the sphereList
            pos2 = self.sphereList[E[1]].pos
            rod = v.cylinder(pos=pos1,
                             axis=pos2 - pos1,
                             radius=0.0025,
                             color=v.color.white)
            #create a vPython cylinder that stretches between the two nodes
            self.rodList.append(rod)  #add this cylinder to list
Пример #47
0
	def __init__( self ):
		QtCore.QThread.__init__( self )
		self.C = 0
		# it is requred to process input events from visual window
		self.display = visual.display ()
		self.s = visual.sphere( pos=visual.vector( 1, 0, 0 ) )
		self.keep_running=True
Пример #48
0
 def _displayDiff(self):
     """Display arrows for where particles have moved."""
     if self.S0 is None: return
     objs = self._atoms
     S = self.S
     S0 = self.S0
     # Delete all objects:
     for i in range(len(objs)):
         objs[-1].visible = 0
         del objs[-1]
     for i in range(S.N):
         startPos = S.atompos[i]
         endPos = S0.atompos[i]
         if startPos not in self._limit:
             continue
         if startPos == endPos:
             objs.append(visual.sphere(pos=S.coords(startPos), radius=.15))
         else:
             startCoords = S.coords(startPos)
             endCoords   = S0.coords(endPos)
             dist = math.sqrt(sum((endCoords-startCoords)**2))
             if dist > S.L/2:
                 continue
             objs.append(
                 visual.arrow(pos=startCoords, axis=endCoords-startCoords,
                              shaftwidth=.1, headlength=1, fixedwidth=1
                              ))
Пример #49
0
def scalar_field(r,phi,phimin=0,phimax=0,colourtype='rainbow',scale=1):
	field = []
	#work out limits of phi if not provided
	if(phimin==phimax==0):
		phimin = np.min(np.abs(phi))
		phimax = np.max(np.abs(phi))
		#if they're the same because all passed field values are identical
		if(phimin==phimax):
			phimin = 0
	
	for i in range(len(r)):
		#colour from black to white at fmax
		val = (np.abs(phi[i]-phimin))/(phimax-phimin)
		if(colourtype=='rainbow'):
			colour = col_rainbow(val)
			opacity = 1.0
		elif(colourtype=='bw'):
			colour = (val,val,val)
			opacity = 1.0
		elif(colourtype=='rainbow_complex'):
			colour = col_rainbow_complex(val,np.angle(phi[i]))
			opacity = 1.0
		elif(colourtype=='rainbow_complex_transparency'):
			colour = col_rainbow_theta(np.angle(phi[i]))
			opacity = val*0.95 + 0.05 #make it such that the minimum opacity is not zero
		field.append(v.sphere(pos=r[i], color=colour, radius=0.1*scale, opacity=opacity))
	return field
Пример #50
0
 def __init__(self, n=10):
     """Create n Boids and one carrot.
     tracking: indicates whether the carrot follows the mouse
     """
     self.boids = [Boid() for i in range(n)]
     self.carrot = visual.sphere(pos=(1,0,0), radius=0.1, color=(1,0,0))
     self.tracking = False
Пример #51
0
    def __init__(self, ini=None):
        wx.Frame.__init__(self, None)

        self.Splitter = wx.SplitterWindow(self)
        self.p1 = wx.Panel(self.Splitter)
        self.p2 = wx.Panel(self.Splitter)
        self.Splitter.SplitVertically(self.p1, self.p2)
        self.Splitter.SetMinimumPaneSize(20)
        Sizer = wx.BoxSizer()
        Sizer.Add(self.Splitter, 1, wx.EXPAND)
        self.SetSizer(Sizer)

        # create a VPython application, just an copy of the Ball-demo
        floor = visual.box(pos=(0, 0, 0),
                           length=4,
                           height=0.5,
                           width=4,
                           color=visual.color.blue)
        ball = visual.sphere(pos=(0, 4, 0), radius=1, color=visual.color.red)
        ball.velocity = visual.vector(0, -1, 0)
        dt = 0.01

        # initialize the State_Machine and start the timer
        self.VP_State = 0
        self.Old_Size = (0, 0)
        self.Timer = wx.Timer(self)
        # the third parameter is essential to allow other timers
        self.Bind(wx.EVT_TIMER, self._On_Timer, self.Timer)
        self.Timer.Start(100)
Пример #52
0
def PlotSphereEvolution3(f):
  data = json.loads(open(f, "r").read())

  center = (
    (data["SystemSize"][1][0]+data["SystemSize"][0][0])*0.5,
    (data["SystemSize"][1][1]+data["SystemSize"][0][1])*0.5,
    (data["SystemSize"][1][2]+data["SystemSize"][0][2])*0.5
  )

  scene = vs.display(title='3D representation',
    x=0, y=0, width=1920, height=1080,
    center=center,background=(0,0,0)
  )

  vs.box(pos=center,
  length=data["SystemSize"][1][0]-data["SystemSize"][0][0],
  height=data["SystemSize"][1][1]-data["SystemSize"][0][1],
  width= data["SystemSize"][1][2]-data["SystemSize"][0][2],
  opacity=0.2,
  color=vs.color.red)

  spheres = [vs.sphere(radius=data["SphereSize"],pos=(data["Data"][0][0][i], data["Data"][1][0][i], data["Data"][2][0][i])) for i in range(data["SpheresNumber"])]

  nt = 0
  while True:
    vs.rate(60)
    for i in range(data["SpheresNumber"]):
      spheres[i].pos = (data["Data"][0][nt][i], data["Data"][1][nt][i], data["Data"][2][nt][i])
    if nt + 1 >= data["SavedSteps"]:
      nt = 0
    else:
      nt += 1
Пример #53
0
def PlotSpheres3(f):
  data = json.loads(open(f, "r").read())

  scene = vs.display(title='3D representation',
    x=0, y=0, width=1920, height=1080,
    autocenter=True,background=(0,0,0))

  vs.box(pos=(
    (data["SystemSize"][1][0]+data["SystemSize"][0][0])*0.5,
    (data["SystemSize"][1][1]+data["SystemSize"][0][1])*0.5,
    (data["SystemSize"][1][2]+data["SystemSize"][0][2])*0.5
  ),
  length=data["SystemSize"][1][0]-data["SystemSize"][0][0],
  height=data["SystemSize"][1][1]-data["SystemSize"][0][1],
  width= data["SystemSize"][1][2]-data["SystemSize"][0][2],
  opacity=0.2,
  color=vs.color.red)

  spheres = [vs.sphere(radius=data["SphereSize"],pos=(data["Data"][0][i], data["Data"][1][i], data["Data"][2][i])) for i in range(data["SpheresNumber"])]

  vs.arrow(pos=data["SystemSize"][0], axis=(1,0,0), shaftwidth=0.1, color=vs.color.red)
  vs.arrow(pos=data["SystemSize"][0], axis=(0,1,0), shaftwidth=0.1, color=vs.color.green)
  vs.arrow(pos=data["SystemSize"][0], axis=(0,0,1), shaftwidth=0.1, color=vs.color.blue)

  while True:
    vs.rate(60)
Пример #54
0
    def __init__(self):

        self.NodeList = []
        self.EdgeList = []

        r = 1.0
        delta_theta = (2.0 * math.pi) / len(Net.Nodes)
        theta = 0

        for N in Net.Nodes:
            node = [
                N.ID,
                v.sphere(pos=v.vector(r * math.cos(theta), r * math.sin(theta),
                                      0),
                         radius=0.01,
                         color=v.color.white)
            ]
            theta += delta_theta
            self.NodeList.append(node)
        self.NodeList = dict(self.NodeList)

        for ind in Net.ChansIndex:
            pos1 = self.NodeList[Net.ChansIndex[ind][0]].pos
            pos2 = self.NodeList[Net.ChansIndex[ind][1]].pos
            ID = ind
            rod = v.cylinder(pos=pos1,
                             axis=(pos2 - pos1),
                             radius=0.0025,
                             color=v.color.green)
            edge = [ind, rod]
            self.EdgeList.append(edge)

        self.EdgeList = dict(self.EdgeList)
Пример #55
0
    def __init__(self, pos, moment, scene=None):
        self.pos = pos
        self.moment = moment

        if scene:
            Shape.__init__(self, scene)
            self.obj = sphere(pos=pos, radius=0.5, display=scene)
Пример #56
0
    def _handle_dfs(self, bone, parent, frame, transform_stack):
        # Calculate new direction and position
        direction = (bone.xyz_data[frame, :] -
                     parent.xyz_data[frame, :]).tolist()
        pos = parent.xyz_data[frame, :].tolist()

        # FIXME: Seems inefficient.
        xdir = np.asarray(transform_stack[-1][0, :]).tolist()[0]
        ydir = np.asarray(transform_stack[-1][1, :]).tolist()[0]
        zdir = np.asarray(transform_stack[-1][2, :]).tolist()[0]

        if bone.name in self.bone_data:
            # Retrieve and update objects
            cyl, s, ax = self.bone_data[bone.name]
            cyl.pos = pos
            cyl.axis = direction
            s.pos = bone.xyz_data[frame, :].tolist()
            ax.update(xdir, ydir, zdir, pos)
        else:
            # Create and save objects.
            cyl = visual.cylinder(pos=pos,
                                  axis=direction,
                                  radius=Pose.cyl_radius)

            s = visual.sphere(pos=bone.xyz_data[frame, :].tolist(),
                              radius=Pose.sphere_radius)

            axes = Axes(xdir, ydir, zdir, 0.3, pos=pos, width=0.01)
            self.bone_data[bone.name] = (cyl, s, axes)
Пример #57
0
 def sand(self):
     self.top = cone(pos=(0, self.time * 1.1, 0), axis=(0, -1, 0), color=(1, 1, 0))
     self.bottom = cone(pos=(0, -self.time * 1.1, 0), axis=(0, 1, 0), color=(0.5, 0.5, 0))
     self.falling = cylinder(
         pos=(0, self.time * 0.125, 0), axis=(0, -1, 0), color=(0.5, 0.5, 0), radius=self.time * 0.035
     )
     self.countdown = sphere(pos=(0, self.time * 1.5, 0), radius=0)
Пример #58
0
def add(i, j, time=tau):
    grid[i, j] = True
    s = sphere(radius=0.5)
    s.pos = i, j  #i-50,j-50

    color = 1  #time/tau#(1-1*exp(-t/tau))
    s.color = color, color, color
Пример #59
0
def Ch3_Uses():
	print '-------------------- 3.1 Graphs ---------------------------\n'
	#simple plot
	plt.figure(facecolor="white")
	x = [0.5, 1.0, 2.0, 4.0, 7.0, 10.0]
	y = [1.0, 2.4, 1.7, 0.3, 0.6, 1.8]
	plt.plot (x,y,'ro-')
	plt.show()
	
	#two plots with legends and different colors
	plt.figure(facecolor="white")
	x = linspace(0,12.56,100) #linspace takes three arguments initial and final value and the number of divisions
	y = sin(x)
	z = cos(x)
	plt.plot(x,y,'g-',label = 'sin x')
	plt.plot(x,z,'ro',label = 'cos x')
	#colors allowed by python are r,g,b,c,m,y,k,w for red, green,blue,cyan,magenta,yellow,black,white
	#Styles are -,o,--,s,* for solid line, dots, dash line, squares, stars,
	plt.ylim(-1.1,1.1)
	plt.xlim(-0.5,13)
	plt.xlabel('from 0 to 4pi')
	plt.ylabel('Trigonometric functions')
	plt.title('la verdad')
	leg = plt.legend()
	plt.show()
	
	plt.figure(facecolor="white")
	data = loadtxt("alltxt/ch3-1.txt",float)
	x = data[:,0]
	y = data[:,1]
	plt.plot(x,y)
	plt.show()
	
	print '------------------- 3.2 Scatter --------------------------\n'
	print '------------------- 3.3 Density --------------------------\n'
	plt.figure(facecolor="white")
	data = loadtxt("cpresources/circular.txt",float)
	plt.imshow(data,origin='lower')
	#plt imshow()
	plt.colorbar()
	plt.show()
	
	print '------------------- 3.4 3D Graphics --------------------------\n'
	sphere()
	sphere(radius=0.5, pos=[1.0,-0.2,0.0])
	sphere(color = color.green)
	s = empty(10,sphere)
	for n in range(10):
		s[n]= sphere()
		d = display(background = color.blue)
		display(autoscale=False)#set the automatic zoom off
		
	print '------------------- 3.5 Animations --------------------------\n'
	s = sphere(pos=[0,0,0])
	s.pos = [1,4,3]
	
	return 'done'
Пример #60
0
 def __init__(self, radius, **kwargs):
     self.container = visual.frame(**kwargs)
     self.ledsphere = visual.sphere(
         frame=self.container, pos=(0, 0, 0),
         radius=radius, color=visual.color.white,
         material=visual.materials.emissive
     )
     self.ledlight = visual.local_light(frame=self.container, pos=(0, 0, 0), color=visual.color.white)