Exemple #1
0
    def frame_rel(self,frame_rel,*args):
        if len(args)==1:
            scale = args[0]
        else:
            if frame_rel == None:
                scale = 1
            else:
                scale = frame_rel.axis.scale

        visible = self.visible
        visible_label = self.visible_label
        visible_frame = self.axis.visible
        visible_frame_label = self.axis.visible_label
        color = self.color
        self.visible = False
        del self.__frame_rel
        del self.__frame_obj
        if frame_rel == None:
            self.__frame_rel = None
            self.__frame_obj = visual.frame(dis=self.__dis,visible=visible)
        else:
            self.__frame_rel = frame_rel
            self.__frame_obj = visual.frame(frame=self.__frame_rel.__frame_obj,pos=self.__dis,visible=visible)


        self.__frame_obj.axis = self.__rot[:,0]
        self.__frame_obj.up = self.__rot[:,1]
        self.__point_obj = visual.points(frame=self.__frame_obj,pos=(0,0,0),color=color,size=4,size_units="pixels",shape="round")
        self.__label_obj = visual.label(frame=self.__frame_obj,text=self.__label,visible=visible_label,
                pos=(0,0,0),xoffset=5*scale,yoffset=1*scale,space=5*scale,line=0,height=16*scale,border=0,font='sans',color=color,box=False,opacity=0)
        self.axis = axes(frame_obj=self.__frame_obj,visible=visible_frame,visible_label=visible_frame_label,scale=scale)
Exemple #2
0
def bevel_gears(rad1=5.0,
                n_1=15,
                t_1=2.0,
                gratio=2.0,
                hole1=False,
                hole2=False,
                twist=0.0):
    """ Beveled Gears """
    # Gear 2 radius and teeth numbers
    r_2 = gratio * rad1
    n_2 = int(gratio * n_1)

    # Calculate the thickness of gear 2, and the scaling factor
    r_2 = r_2 - t_1  # final radius of gear 2
    rad1 = (rad1 / r_2) * r_2  # final radius of gear 1
    t_2 = rad1 - rad1  # thickness of gear 2
    scaling = rad1 / rad1  # both extrusions are scaled by this factor

    g_1 = vp.shapes.gear(n=n_1, radius=rad1)
    if hole1:
        g_1 -= vp.shapes.circle(radius=rad1 / 2.)
    g_2 = vp.shapes.gear(n=n_2, radius=r_2)
    if hole2:
        g_2 -= vp.shapes.circle(radius=r_2 / 2.)

    lnp = 2
    if twist:
        lnp = 8
    cfrm = vp.frame()
    frm1 = vp.frame()
    eg1 = vp.extrusion(shape=g_1,
                       pos=vp.paths.line(start=(0, 0, 0),
                                         end=(0, 0, t_1),
                                         np=lnp),
                       scale=scaler(start=(1, 1),
                                    end=(scaling, scaling),
                                    no_p=lnp),
                       twist=-twist,
                       frame=frm1)

    frm2 = vp.frame(pos=(rad1, 0, r_2), axis=(0, 0, 1))
    eg2 = vp.extrusion(shape=g_2,
                       pos=vp.paths.line(start=(0, 0, 0),
                                         end=(0, 0, t_2),
                                         np=lnp),
                       scale=scaler(start=(1, 1),
                                    end=(scaling, scaling),
                                    no_p=lnp),
                       twist=twist / gratio,
                       frame=frm2,
                       color=vp.color.red)

    return rad1, n_1, r_2, n_2, eg1, eg2
 def __init__(self, **kwargs):
     self.container = visual.frame(**kwargs)
     self.box = visual.box(frame=self.container,
                           length=self.size[0],
                           width=self.size[1],
                           height=self.size[2],
                           color=(0, 0, 0.7))
     self.lidarframe = visual.frame(frame=self.container,
                                    pos=(self.size[0] / 2.0,
                                         self.size[1] / 2.0, self.size[2]))
     self.lidarpoints = visual.points(pos=[(0, 0, 0) for i in range(360)],
                                      frame=self.lidarframe,
                                      size=5,
                                      color=(0, 1, 0))
     print(repr(self.lidarpoints))
Exemple #4
0
    def Create3DModel(self, ShowInfo=True, opacity=0.9):  #False):#True):

        make_trail = True  #False#True
        self.Frame = frame(pos=self.pos,
                           make_trail=make_trail,
                           trail_type="points",
                           interval=1,
                           retain=300)  #100)

        for i in range(3):
            if i == 0: l = 15.0 / 2.
            else: l = 9.96 / 2.
            axis = np.identity(3)[i] * l  # self.CS.matrix[:,i]*l
            arrow(axis=axis,
                  color=np.identity(3)[i],
                  opacity=opacity,
                  frame=self.Frame)  #,make_trail=True)

        self.rps_vector = arrow(axis=[0, 0, -1 * 10**(-10)],
                                color=[1, 0, 0],
                                opacity=opacity,
                                frame=self.Frame)
        self.acc_vector = arrow(axis=[0, 0, -1 * 10**(-10)],
                                color=[1, 1, 0],
                                opacity=opacity,
                                frame=self.Frame)

        self.ShowInfo = ShowInfo
        if self.ShowInfo:
            self.InfoLabel = label(text="F16",
                                   frame=self.Frame,
                                   xoffset=int(1920 * 0.1),
                                   yoffset=int(1080 * 0.1))
    def cubic(self, latticeparameters=(1, 1, 1)):
        cube = visual.frame()

        visual.box(frame=cube,
                   pos=(0, 0, 0),
                   size=latticeparameters,
                   color=(1, 0.7, 0.2))

        visual.arrow(frame=cube,
                     pos=(latticeparameters[0] / 2, 0, 0),
                     axis=(1, 0, 0),
                     shaftwidth=0.1,
                     color=(1, 0, 0))

        visual.arrow(frame=cube,
                     pos=(0, latticeparameters[0] / 2, 0),
                     axis=(0, 1, 0),
                     shaftwidth=0.1,
                     color=(0, 1, 0))

        visual.arrow(frame=cube,
                     pos=(0, 0, latticeparameters[0] / 2),
                     axis=(0, 0, 1),
                     shaftwidth=0.1,
                     color=(0, 0, 1))

        return cube
def gettreecable(treepos=V(0, 0, 0)):
    """Returns a single arc of cable from vertical (exiting duct at centre of dipole) to
     horizontal (short distance from base, shading to the ground color).

     The cable is positioned for a Christmas Tree positioned at 'treepos', and the
     cable points towards the APIU at (0,0,0).

     Returned is a tuple (cable, olist) where cable is the frame containing the
     curve (we need a frame for a single curve object, because curve objects can't
     be rotated), and a list containing the single component object.
  """
    cframe = visual.frame()
    cstartpos = treepos + (0, 0, 0.4
                           )  # Where the cable leaves the xmas tree trunk
    theta = visual.atan2(treepos.y, treepos.x)  # Angle to the APIU at (0,0,0)

    carc = visual.paths.arc(radius=0.37,
                            angle1=-visual.pi / 2,
                            angle2=0,
                            up=(0, -1, 0))
    carc.pos = [p + treepos + V(0.37, 0, 0.4) for p in carc.pos[::-1]]

    c1 = visual.curve(frame=cframe,
                      pos=carc,
                      radius=0.0129 / 2,
                      color=color.blue)
    c1.append(pos=treepos + V(1.5, 0, -0.065), color=GCOLOR)
    cframe.rotate(angle=theta + visual.pi, axis=(0, 0, 1), origin=cstartpos)

    return cframe, [c1]
Exemple #7
0
    def cubic(self, latticeparameters=(1, 1, 1)):
        cube = visual.frame()

        visual.box(frame=cube
                   , pos=(0, 0, 0)
                   , size=latticeparameters
                   , color=(1, 0.7, 0.2))

        visual.arrow(frame=cube
                     , pos=(latticeparameters[0] / 2, 0, 0)
                     , axis=(1, 0, 0)
                     , shaftwidth=0.1
                     , color=(1, 0, 0))

        visual.arrow(frame=cube
                     , pos=(0, latticeparameters[0] / 2, 0)
                     , axis=(0, 1, 0)
                     , shaftwidth=0.1
                     , color=(0, 1, 0))

        visual.arrow(frame=cube
                     , pos=(0, 0, latticeparameters[0] / 2)
                     , axis=(0, 0, 1)
                     , shaftwidth=0.1
                     , color=(0, 0, 1))

        return cube
    def unfix(self) :
        tmp = self.where()
        self.parent = None
#        self.vframe.frame = None
        self.vframe.frame = visual.frame()
        self.rel = None
        self.set_trans(tmp)
Exemple #9
0
 def __init__(self, faces=None):
     if faces == None:
         self.faces = [Face()]
     else:
         self.faces = faces
     self.frame = frame()
     self.drawn = False
Exemple #10
0
    def addcar(self, pos, color=v.color.green, name="v"):
        # Creating car 
        car = v.frame()
        car.start = pos
        car.pos = car.start
        car.vector = v.vector(0.05, 0, 0) 
        car.color = color
        car.colorori = car.color

        body = v.box(frame = car, pos = (0,0,0), size = (2.4*self.thk, 0.6*self.thk, 1.4*self.thk), color = car.colorori) 
        wheel1 = v.cylinder(frame=car, pos=(0.8*self.thk,-0.2*self.thk,0.8*self.thk), axis=(0,0,-1.6*self.thk), radius=0.25*self.thk, color=(0.6,0.6,0.6)) 
        wheel2 = v.cylinder(frame=car, pos=(-0.8*self.thk,-0.2*self.thk,0.8*self.thk), axis=(0,0,-1.6*self.thk), radius=0.25*self.thk, color=(0.6,0.6,0.6)) 
        head = v.convex(frame=car, color=car.colorori)
        head.append(pos=v.vector(0.6, 0.3, -0.7)*self.thk)
        head.append(pos=v.vector(0.6, 0.3, 0.7)*self.thk)
        head.append(pos=v.vector(-1.2, 0.3, -0.7)*self.thk)
        head.append(pos=v.vector(-1.2, 0.3, 0.7)*self.thk)
        head.append(pos=v.vector(0.4, 0.7, -0.6)*self.thk)
        head.append(pos=v.vector(0.4, 0.7, 0.6)*self.thk)
        head.append(pos=v.vector(-0.8, 0.7, -0.6)*self.thk)
        head.append(pos=v.vector(-0.8, 0.7, 0.6)*self.thk)

        # Creating Label
        car.vlabel = v.label(justify='center', pos=car.pos, xoffset=3*self.thk, yoffset=39*self.thk, space=3*self.thk, text=name,height=15, line=0,border=3)

        self.cars[name] = car
        self.labels[name] = car.vlabel
Exemple #11
0
def drawCameraFrame():  # create frame and draw its contents
    global  cam_box, cent_plane,  cam_lab, cam_tri, range_lab, linelen, fwd_line
    global fwd_arrow, mouse_line, mouse_arrow, mouse_lab, fov, range_x, cam_dist, cam_frame
    global ray
    cam_frame = vs.frame( pos = vs.vector(0,2,2,),  axis = (0,0,1))
               # NB: contents are rel to this frame.  start with camera looking "forward"
               # origin is at simulated scene.center
    fov = vs.pi/3.0  # 60 deg 
    range_x = 6  # simulates scene.range.x  
    cam_dist = range_x / vs.tan(fov/2.0)  # distance between camera and center. 
    ray = vs.vector(-20.0, 2.5, 3.0).norm()  # (unit) direction of ray vector (arbitrary)
                                         #  REL TO CAMERA FRAME
    cam_box = vs.box(frame=cam_frame, length=1.5, height=1, width=1.0, color=clr.blue,
                                                   pos=(cam_dist,0,0)) # camera-box
    cent_plane = vs.box(frame=cam_frame, length=0.01, height=range_x*1.3, width=range_x*2,
                                                    pos=(0,0,0), opacity=0.5 )  # central plane
    cam_lab = vs.label(frame=cam_frame, text= 'U', pos= (cam_dist,0,0), height= 9, xoffset= 6)
    cam_tri = vs.faces( frame=cam_frame, pos=[(0,0,0), (0,0,-range_x), (cam_dist,0,0)])
    cam_tri.make_normals()
    cam_tri.make_twosided()
    range_lab = vs.label(frame=cam_frame, text= 'R', pos= (0, 0, -range_x), height= 9, xoffset= 6)
    linelen = scene_size + vs.mag( cam_frame.axis.norm()*cam_dist + cam_frame.pos)
                                                                   # len of lines from camera
    fwd_line = drawLine( vs.vector(cam_dist,0,0), linelen, vs.vector(-1,0,0))
    fwd_arrow = vs.arrow(frame=cam_frame, axis=(-2,0,0), pos=(cam_dist, 0, 0), shaftwidth=0.08,
                                                                            color=clr.yellow)
    vs.label(frame=cam_frame, text='C', pos=(0,0,0), height=9, xoffset=6, color=clr.yellow)
    mouse_line = drawLine ( vs.vector(cam_dist,0,0), linelen, ray ) 
    mouse_arrow = vs.arrow(frame=cam_frame, axis=ray*2, pos=(cam_dist,0,0), shaftwidth=0.08,
                                                                                   color=clr.red)
    mouse_lab = vs.label(frame=cam_frame, text= 'M', height= 9, xoffset= 10, color=clr.red, 
                                pos=  -ray*(cam_dist/vs.dot(ray,(1,0,0))) + (cam_dist,0,0))
Exemple #12
0
 def __init__(self, verts, edges):
     self.frame = visual.frame()
     self.susceptible = (0,1,0)
     self.infected = (1,0,0)
     self.recovered = (1,1,0)
     self.purple = (1,0,1)
     self.colors=[(0,1,0),(1,0,0),(1,1,0),(1,0,1)]
     self.v_verts, self.v_edges = self.gen_graph(verts, edges)
Exemple #13
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)
 def __init__(self, size=100, small_interval=5, big_interval=50):
     self.frame = visual.frame(pos=(0,0,0))
     for i in range(-size, size+small_interval, small_interval):
         if i % big_interval == 0:
             c = visual.color.gray(0.65)
         else:
             c = visual.color.gray(0.25)
         visual.curve(frame=self.frame, pos=[(i,0,size),(i,0,-size)], color=c)
         visual.curve(frame=self.frame, pos=[(size,0,i),(-size,0,i)], color=c)
Exemple #15
0
 def __init__(self):
     self.frame = vis.frame()
     'Builds board and places pieces'
     self.squares = []
     for i in range(64):
         self.squares.append(None)
     self.makeBoard()
     self.placePieces()
     vis.scene.center=(3.5,0,3.5)
Exemple #16
0
 def __init__(self, index, name, colors, mRNA, protein, P0, P1, P2):
     self.index = index
     self.name = name
     self.pos = (index, 0, 0)
     self.color = colors[index]
     self.mRNA_amt = mRNA
     self.protein_amt = protein
     self.P0_amt = P0
     self.P1_amt = P1
     self.P2_amt = P2
     self.f = v.frame()
     j = (index + 1) % 3
     self.P0 = v.cylinder(display=v.scene,
                          frame=self.f,
                          pos=(-0.1, -1, 0),
                          axis=(0, 0, 1),
                          radius=SCALE * math.sqrt(PROMOTER_FACTOR),
                          length=self.P0_amt * math.sqrt(PROMOTER_FACTOR),
                          color=colors[j])
     self.P1 = v.cylinder(display=v.scene,
                          frame=self.f,
                          pos=(0.0, -1, 0),
                          axis=(0, 0, 1),
                          radius=SCALE * math.sqrt(PROMOTER_FACTOR),
                          length=self.P1_amt * math.sqrt(PROMOTER_FACTOR),
                          color=colors[j])
     self.P2 = v.cylinder(display=v.scene,
                          frame=self.f,
                          pos=(0.1, -1, 0),
                          axis=(0, 0, 1),
                          radius=SCALE * math.sqrt(PROMOTER_FACTOR),
                          length=self.P2_amt * math.sqrt(PROMOTER_FACTOR),
                          color=colors[j])
     self.m = v.cylinder(display=v.scene,
                         frame=self.f,
                         pos=(0, 0, 0),
                         axis=(0, 0, 1),
                         radius=SCALE * math.sqrt(RNA_FACTOR),
                         length=self.mRNA_amt / RNA_FACTOR,
                         color=self.color)
     self.p = v.cylinder(display=v.scene,
                         frame=self.f,
                         pos=(0, 1, 0),
                         axis=(0, 0, 1),
                         radius=SCALE * math.sqrt(PROTEIN_FACTOR),
                         length=self.protein_amt / PROTEIN_FACTOR,
                         color=self.color)
     self.lab = v.label(frame=self.f,
                        text=self.name,
                        pos=(0, -1.5, 0),
                        height=100,
                        color=self.color,
                        box=0,
                        font='helvetica')
     self.f.pos = self.pos
     self.f.axis = (1, 0, 0)
Exemple #17
0
    def plate(self):
        if (self.container):
            for obj in self.container.objects:
                obj.visible = 0
        self.container = visual.frame()
        field_length =  self.length() + 2*self.config['display']['radius']
        field_width = 3*self.config['display']['radius']*self.count + 10
        if (self.ordered):
            init = self.conns[0].obj[self.orderby]
            pborder = 0
            t = -1
            i = 0
            for conn in self.conns:
                if (init != conn.obj[self.orderby]):
                    if ((i % 2) == 1):
                        bcolor = self.config['colors']['box_light']
                    else:
                        bcolor = self.config['colors']['box']

                    if type(init) == (type(1)):
                        labeltext = self.orderby + "\n%d" % (init)
                    elif type(init) == (type('str')):
                        labeltext = self.orderby + "\n'%s'" % (init)
                    visual.box(frame=self.container, pos=(field_length/2 - self.level, -(self.config['display']['radius']+1), 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2), \
                             width = (3*self.config['display']['radius']*t - pborder), length = field_length, height = 1, color = bcolor)
                    visual.label(frame=self.container, pos = (self.config['display']['radius'] -self.level, 0,  3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2),\
                        yoffset = 4*self.config['display']['radius'], xoffset = -4* self.config['display']['radius'],text = labeltext)
                    pborder = 3*self.config['display']['radius']*t+self.config['display']['radius']
                    init = conn.obj[self.orderby]
                    i += 1
                t += 1

            if type(init) == (type(1)):
                labeltext = self.orderby + "\n%d" % (init)
            elif type(init) == (type('str')):
                labeltext = self.orderby + "\n'%s'" % (init)
            if ((i % 2) == 1):
                bcolor = self.config['colors']['box_light']
            else:
                bcolor = self.config['colors']['box']
            visual.box(frame=self.container, pos=(field_length/2 - self.level, -(self.config['display']['radius']+1), 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2), \
                     width = (3*self.config['display']['radius']*t - pborder), length = field_length, height = 1, color = bcolor)
            visual.label(frame=self.container, pos = (self.config['display']['radius'] - self.level, 0, 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2),\
                yoffset = 4*self.config['display']['radius'], xoffset = -4* self.config['display']['radius'], text = labeltext)
        else:
             visual.box(frame=self.container, pos = (field_length/2 - self.level, -(self.config['display']['radius']+1),field_width/2), width = field_width, length = field_length, height = 1, color = self.config['colors']['box'])

        desctext = 'From %s to %s\n' % (time.strftime("%F %H:%M:%S", time.localtime(self.starttime)), \
            time.strftime("%F %H:%M:%S", time.localtime(self.endtime)))
        desctext += self.build_str_filter(" and ", "Filtering on ")
        visual.label(frame=self.container, pos = (field_length/2 - self.level, self.config['display']['radius']+0.5,0), yoffset = 4*self.config['display']['radius'], text = desctext)
        for i in range(self.config['display']['graduation']):
            visual.curve(frame=self.container, pos=[(field_length/self.config['display']['graduation']*i - self.level, -(self.config['display']['radius']+1)+1,0), (field_length/self.config['display']['graduation']*i - self.level,-(self.config['display']['radius']+1)+1,field_width)])
        for i in range(self.config['display']['graduation']/self.config['display']['tick']+1):
            ctime = time.strftime("%H:%M:%S", time.localtime(self.mintime + field_length/self.config['display']['graduation']*self.config['display']['tick']*i))
            visual.label(frame=self.container, pos=(field_length/self.config['display']['graduation']*self.config['display']['tick']*i - self.level, -(self.config['display']['radius']+1)+1,0), text = '%s' % (ctime), border = 5, yoffset = 1.5*self.config['display']['radius'])
Exemple #18
0
    def __init__(self):
        self._value = random() * 2 * pi
        self._model = v.frame()

        W = 0.1
        v.box(frame=self._model, pos=(+W / 2, 0, 0), size=(W, W, W), color=v.color.red)
        v.box(frame=self._model, pos=(-W / 2, 0, 0), size=(W, W, W),
            color=v.color.white)

        self._model.rotate(angle=self._value, axis=(0, 0, 1))
Exemple #19
0
def getxmas():
    """Creates a complete Christmas Tree dipole assembly (minus base) at (0,0,0)

     Returned value is a tuple of (xmas, olist), where xmas is the frame containing the
     complete Christmas Tree dipoles, and olist is a list of all of the component objects."""
    xmas = visual.frame()
    olist = []
    for direction in ['E', 'W', 'N', 'S']:  # Create the four dipole arms
        ef, elist = getelement(frame=xmas, which=direction)
        olist.append(ef)
        olist.append(elist)

    # These objects (s1-s3) are the white plastic space assembly
    s1 = visual.curve(pos=[
        V(-0.233, -0.233, 0.59),
        V(0.233, -0.233, 0.59),
        V(0.233, 0.233, 0.59),
        V(-0.233, 0.233, 0.59),
        V(-0.233, -0.233, 0.59)
    ],
                      frame=xmas,
                      radius=0.02,
                      material=SPACERMAT,
                      color=color.white)
    s2 = visual.curve(pos=[V(-0.233, 0, 0.59),
                           V(0.233, 0, 0.59)],
                      frame=xmas,
                      radius=0.02,
                      material=SPACERMAT,
                      color=color.white)
    s3 = visual.curve(pos=[V(0, -0.233, 0.59),
                           V(0, 0.233, 0.59)],
                      frame=xmas,
                      radius=0.02,
                      material=SPACERMAT,
                      color=color.white)

    # This is an approximation to the LNA and feedhorn at the top of the tree
    lna = visual.box(pos=V(0, 0, 1.63),
                     frame=xmas,
                     height=0.03,
                     length=0.03,
                     width=0.08,
                     material=SPACERMAT,
                     color=color.white)

    # This is the cable duct going vertically down the centre of the tree from the LNA
    pole = visual.curve(pos=[V(0, 0, 0.38), V(0, 0, 1.73)],
                        frame=xmas,
                        radius=POLER,
                        material=POLEMAT,
                        color=color.white)

    olist.append([s1, s2, s3, lna, pole])
    return xmas, olist
    def hexagonal(self, CAratio=1.6):
        hexagonal = visual.frame()

        base1 = visual.box(frame=hexagonal,
                           pos=(0, -CAratio / 2.0, 0),
                           size=(math.sqrt(3), 0.01, 1),
                           color=(1, 0.7, 0.2))
        base1 = base1.__copy__()
        base1.rotate(angle=math.pi * 60 / 180,
                     axis=(0, 1, 0),
                     origin=(0, 0, 0))
        base1 = base1.__copy__()
        base1.rotate(angle=math.pi * 60 / 180,
                     axis=(0, 1, 0),
                     origin=(0, 0, 0))

        base2 = visual.box(frame=hexagonal,
                           pos=(0, CAratio / 2.0, 0),
                           size=(math.sqrt(3), 0.01, 1),
                           color=(1, 0.7, 0.2))
        base2 = base2.__copy__()
        base2.rotate(angle=math.pi * 60 / 180,
                     axis=(0, 1, 0),
                     origin=(0, 0, 0))
        base2 = base2.__copy__()
        base2.rotate(angle=math.pi * 60 / 180,
                     axis=(0, 1, 0),
                     origin=(0, 0, 0))

        face = visual.box(frame=hexagonal,
                          pos=(math.sqrt(3) / 2.0, 0, 0),
                          size=(0.01, CAratio, 1),
                          color=(1, 0.7, 0.2))
        for _i in range(6):
            face = face.__copy__()
            face.rotate(angle=math.pi * 60 / 180,
                        axis=(0, 1, 0),
                        origin=(0, 0, 0))

        visual.arrow(frame=hexagonal,
                     pos=(0, CAratio / 2, 0),
                     axis=(0, 0.5, 0),
                     shaftwidth=0.1,
                     color=(1, 0, 0))

        visual.arrow(frame=hexagonal,
                     pos=(CAratio / 2, 0, 0),
                     axis=(0.5, 0, 0),
                     shaftwidth=0.1,
                     color=(0, 1, 0))

        return hexagonal
Exemple #21
0
    def __init__(self,frame_obj,visible=True,visible_label=True,scale=1.0):
        x_red   = visual.color.darkerred #(1,0.2,0.2)
        y_green = visual.color.darkergreen #(0.2,1,0.2)
        z_blue  = visual.color.darkerblue #(0.2,0.2,1)
        label_color = visual.color.fainttext #(0.7,0.7,0.7)

        self.__scale = scale
        al = self.__scale      # arrow length
        sw = self.__scale*0.01 # shaftwidth
        hw = self.__scale*0.03 # headwidth
        hl = self.__scale*0.05 # headlength

        self.__frame_obj = frame_obj
        self.__frame_axis_obj = visual.frame(frame=self.__frame_obj,pos=(0,0,0),visible=visible)        
        self.__frame_axis_label_obj = visual.frame(frame=self.__frame_axis_obj,pos=(0,0,0),visible=visible_label)
        self.__x_axis_obj = visual.arrow(frame=self.__frame_axis_obj,pos=(0,0,0),axis=(al,0,0),shaftwidth=sw,headwidth=hw,headlength=hl,color=x_red)
        self.__x_axis_label_obj = visual.label(frame=self.__frame_axis_label_obj,pos=(al,0,0),xoffset=1,font='sans',text="x",box=False,opacity=0,border=0,line=0,height=10*scale,color=label_color)
        self.__y_axis_obj = visual.arrow(frame=self.__frame_axis_obj,pos=(0,0,0), axis=(0,al,0),shaftwidth=sw,headwidth=hw,headlength=hl,color=y_green)
        self.__y_axis_label_obj = visual.label(frame=self.__frame_axis_label_obj,pos=(0,al,0),xoffset=1,font='sans',text="y",box=False,opacity=0,border=0,line=0,height=10*scale,color=label_color)
        self.__z_axis_obj = visual.arrow(frame=self.__frame_axis_obj,pos=(0,0,0), axis=(0,0,al),
                shaftwidth=sw,headwidth=hw,headlength=hl,color=z_blue)
        self.__z_axis_label_obj = visual.label(frame=self.__frame_axis_label_obj,pos=(0,0,al),xoffset=1,font='sans',text="z",box=False,opacity=0,border=0,line=0,height=10*scale,color=label_color)
def bevel_gears(rad1=5.0, n_1=15, t_1=2.0, gratio=2.0, hole1=False, hole2=False,
                twist=0.0):
    """ Beveled Gears """
    # Gear 2 radius and teeth numbers
    r_2 = gratio*rad1
    n_2 = int(gratio*n_1)

    # Calculate the thickness of gear 2, and the scaling factor
    r_2 = r_2-t_1      # final radius of gear 2
    rad1 = (rad1/r_2)*r_2 # final radius of gear 1
    t_2 = rad1-rad1      # thickness of gear 2
    scaling = rad1/rad1 # both extrusions are scaled by this factor

    g_1 = vp.shapes.gear(n=n_1, radius=rad1)
    if hole1:
        g_1 -= vp.shapes.circle(radius=rad1/2.)
    g_2 = vp.shapes.gear(n=n_2, radius=r_2)
    if hole2:
        g_2 -= vp.shapes.circle(radius=r_2/2.)

    lnp = 2
    if twist:
        lnp = 8
    cfrm = vp.frame()
    frm1 = vp.frame()
    eg1 = vp.extrusion(
        shape=g_1, pos=vp.paths.line(
            start=(0, 0, 0),
            end=(0, 0, t_1), np=lnp),
        scale=scaler(start=(1, 1), end=(scaling, scaling), no_p=lnp),
        twist=-twist, frame=frm1)

    frm2 = vp.frame(pos=(rad1, 0, r_2), axis=(0, 0, 1))
    eg2 = vp.extrusion(shape=g_2, pos=vp.paths.line(start=(0, 0, 0), end=(0, 0, t_2), np=lnp),
                    scale=scaler(start=(1, 1), end=(scaling, scaling), no_p=lnp),
                    twist=twist/gratio, frame=frm2, color=vp.color.red)

    return rad1, n_1, r_2, n_2, eg1, eg2
Exemple #23
0
    def __init__(self,dis=np.zeros((3,1)),rot=np.eye(3),label="",frame_rel=None,color=visual.color.text,
                 visible=True,visible_frame=True,visible_label=True,visible_frame_label=True,scale=1.0):

       self.__dis = np.array(dis).reshape(3,1)
       self.__rot = np.array(rot).reshape(3,3)
       self.__hom = np.vstack((np.hstack((self.__rot,self.__dis)),np.array([0,0,0,1])))
       self.__hom_inv = np.vstack((np.hstack((self.__rot.T,-np.dot(self.__rot.T,self.__dis))),np.array([0,0,0,1]))) 
       self.__label = label
       self.__color = color

       if frame_rel == None:
           self.__frame_rel = None
           self.__frame_obj = visual.frame(pos=self.__dis,visible=visible)
       else:
           self.__frame_rel = frame_rel
           self.__frame_obj = visual.frame(frame=self.__frame_rel.__frame_obj,pos=self.__dis,visible=visible)

       self.__frame_obj.axis = self.__rot[:,0]
       self.__frame_obj.up = self.__rot[:,1]
       self.__point_obj = visual.points(frame=self.__frame_obj,pos=(0,0,0),color=color,size=4,size_units="pixels",shape="round")
       self.__label_obj = visual.label(frame=self.__frame_obj,text=self.__label,visible=visible_label,
               pos=(0,0,0),xoffset=5*scale,yoffset=1*scale,space=5*scale,line=0,height=16*scale,border=0,font='sans',color=color,box=False,opacity=0)
       self.axis = axes(frame_obj=self.__frame_obj,visible=visible_frame,visible_label=visible_frame_label,scale=scale)
Exemple #24
0
    def __init__(self, World):
        # Initialize the Body class
        odelib.BaseBody.__init__(self, World)

        self._elementDict = {}
        #self._mySpace = ode.Space()

        # Add the space to the world's space
        #_bigSpace.add(self._MySpace)

        # Create a visual frame to hold display objects
        self._myFrame = visual.frame()

        # Mass not defined yet
        self._myNetMass = None
Exemple #25
0
    def __init__(self, World):
        # Initialize the Body class
        odelib.BaseBody.__init__(self, World)

        self._elementDict = {}
        #self._mySpace = ode.Space()

        # Add the space to the world's space
        #_bigSpace.add(self._MySpace)

        # Create a visual frame to hold display objects
        self._myFrame = visual.frame()

        # Mass not defined yet
        self._myNetMass = None
Exemple #26
0
    def __init__(self, numleds, zmqstream, spacing=33, ledradius=15):
        self.numleds = numleds
        self.stream = zmqstream
        self.stream.on_recv_stream(self.frame_recv)

        visual.scene.width = 1500
        visual.scene.height = 80
        visual.scene.autoscale = True
        visual.scene.title = "Simulating %d LEDs" % self.numleds
        self.strip = visual.frame(pos=(self.numleds / 2 * spacing * -1, 0, 0))
        self.leds = []
        for x in xrange(self.numleds):
            self.leds.append(
                led(ledradius, frame=self.strip, pos=(x * spacing, 0, 0))
            )
Exemple #27
0
    def __init__(self, num_objs, ids):
        threading.Thread.__init__(self)

        visual.scene.autoscale = False
        visual.scene.center = (2 * 5 - 1.5, -3, 0)
        vt.scene.title = "Motion Visualizer"

        f = visual.frame()

        self.text = []
        self.objs = []
        self.graphs = []
        self.data = []
        self.index = []
        self.stop = False
        for i in range(num_objs):

            self.text.append(None)
            self.objs.append(VisObj((i * 5, 1, 0), f))
            self.data.append([])
            self.index.append(0)
            self.graphs.append([])
            self.data[-1] = [[], [], []]

            for n in range(100):
                self.data[-1][0].append([(i * 5 - 1.5) + (3.0 / 100) * n, -5,
                                         0])
            for n in range(100):
                self.data[-1][1].append([(i * 5 - 1.5) + (3.0 / 100) * n, -4,
                                         0])
            for n in range(100):
                self.data[-1][2].append([(i * 5 - 1.5) + (3.0 / 100) * n, -3,
                                         0])

            self.graphs[-1].append(
                visual.curve(pos=self.data[-1][0],
                             radius=0.05,
                             color=visual.color.red))

            self.graphs[-1].append(
                visual.curve(pos=self.data[-1][1],
                             radius=0.05,
                             color=visual.color.blue))
            self.graphs[-1].append(
                visual.curve(pos=self.data[-1][2],
                             radius=0.05,
                             color=visual.color.yellow))
Exemple #28
0
def vs_loop():

    #pan_inc = 0.25
    #zoom_inc = array((0.25,0.25,0.25))
    pan_inc = 0.25
    zoom_inc = array((0.05, 0.05, 0.05))

    # for scene rotation with invariant light direction
    light_frame = vs.frame()
    for obj in vs.scene.lights:
        if isinstance(obj, vs.distant_light):
            obj.frame = light_frame  # put distant lights in a frame
    prev_scene_forward = vs.vector(
        vs.scene.forward)  # keep a copy of the old forward

    while True:

        if vs.scene.kb.keys:
            key = vs.scene.kb.getkey()

            if key == 'up':
                vs.scene.center = array(vs.scene.center) + array(
                    (0, pan_inc, 0))
            elif key == 'down':
                vs.scene.center = array(vs.scene.center) + array(
                    (0, -pan_inc, 0))
            elif key == 'left':
                vs.scene.center = array(vs.scene.center) + array(
                    (-pan_inc, 0, 0))
            elif key == 'right':
                vs.scene.center = array(vs.scene.center) + array(
                    (pan_inc, 0, 0))

            elif key == 'shift+up':
                vs.scene.range -= zoom_inc
            elif key == 'shift+down':
                vs.scene.range += zoom_inc

        if vs.scene.forward != prev_scene_forward:
            new = vs.scene.forward
            axis = vs.cross(prev_scene_forward, new)
            angle = new.diff_angle(prev_scene_forward)
            light_frame.rotate(axis=axis, angle=angle)
            prev_scene_forward = vs.vector(new)
Exemple #29
0
def update_grid():
    delete_current_grid()

    if not showSpan:
        return 

    global span_frame

    span_frame = visual.frame() 

    vecs = map(lambda i: visual.vector(vectors[i].axis)*span_fact,selected)
    for v in vecs:
        rest = vecs[0:len(vecs)] # deep copy  
        rest.remove(v)
        all_sums = all_sums_comb(rest)
        for aSum in all_sums:
            visual.curve(frame = span_frame, pos = [aSum,aSum+v], color = span_color)
            if not is_span_positive:
                visual.curve(frame = span_frame, pos = [aSum,aSum-v], color = span_color)
Exemple #30
0
 def setup_body(self):
     frame = visual.frame()
     self.parts = Bunch()
     self.parts.body = visual.cone(
         color=visual.color.white, length=.8, radius=.2,
         pos=(-.4, 0, 0), frame=frame)
     self.parts.l_ear = visual.cone(
         color=visual.color.white, length=.1, radius=.02,
         pos=(.05, .04, .06), axis=self.zaxis, frame=frame)
     self.parts.r_ear = visual.cone(
         color=visual.color.white, length=.1, radius=.02,
         pos=(.05, -.04, .06), axis=self.zaxis, frame=frame)
     self.parts.l_eye = visual.sphere(
         color=visual.color.red, radius=.03,
         pos=(.1, .04, .06), frame=frame)
     self.parts.r_eye = visual.sphere(
         color=visual.color.red, radius=.03,
         pos=(.1, -.04, .06), frame=frame)
     self.rat = frame
Exemple #31
0
def getbundle(
        spos=None,
        bframe=None):  # spos is  position that cable centre exits the box
    """Returns a single bundle of 64 dipole cables as they exit the APIU. The parameter 'spos'
     is the point at which they exit the SPIU box.

     If the 'bframe' parameter is given, all objects are created inside this frame.

     Note that the cable bundle returned always faces East - it most be rotated around
     'spos' after it's created for bundles exiting the West side of the APIU.

     Returned is a tuple of (cframe, blist) where cframe is the frame containing the cable
     bundle, and blist is the list of component objects."""
    cframe = visual.frame(frame=bframe)
    startz = spos.z  # Height above ground that cable centre exits the APIU box

    # Arc from the entry point (horizontal) to halfway to the ground (vertical)
    carc1 = visual.paths.arc(radius=startz / 2,
                             angle1=visual.pi,
                             angle2=visual.pi / 2,
                             up=(0, -1, 0))
    carc1.pos = [p + spos + V(0, 0, -startz / 2) for p in carc1.pos]
    c1 = visual.curve(frame=cframe,
                      pos=carc1,
                      radius=0.08 / 2,
                      color=color.blue)

    # Arc from halfway to the ground (vertical) to the ground (horizontal)
    carc2 = visual.paths.arc(radius=startz / 2,
                             angle1=visual.pi,
                             angle2=visual.pi / 2,
                             up=(0, 1, 0))
    carc2.pos = [p + spos + V(startz, 0, -startz / 2) for p in carc2.pos]
    c2 = visual.curve(frame=cframe,
                      pos=carc2,
                      radius=0.08 / 2,
                      color=color.blue)

    # Append a point to the curve 1.5m out in the desert, fading from blue to the ground color
    c2.append(pos=spos + V(1.5, 0, -startz), color=GCOLOR)

    blist = [c1, c2]
    return cframe, blist
Exemple #32
0
    def hexagonal(self, CAratio=1.6):
        hexagonal = visual.frame()

        base1 = visual.box(frame=hexagonal
                           , pos=(0, -CAratio / 2.0, 0)
                           , size=(math.sqrt(3), 0.01, 1)
                           , color=(1, 0.7, 0.2))
        base1 = base1.__copy__()
        base1.rotate(angle=math.pi * 60 / 180, axis=(0, 1, 0), origin=(0, 0, 0))
        base1 = base1.__copy__()
        base1.rotate(angle=math.pi * 60 / 180, axis=(0, 1, 0), origin=(0, 0, 0))

        base2 = visual.box(frame=hexagonal
                           , pos=(0, CAratio / 2.0, 0)
                           , size=(math.sqrt(3), 0.01, 1)
                           , color=(1, 0.7, 0.2))
        base2 = base2.__copy__()
        base2.rotate(angle=math.pi * 60 / 180, axis=(0, 1, 0), origin=(0, 0, 0))
        base2 = base2.__copy__()
        base2.rotate(angle=math.pi * 60 / 180, axis=(0, 1, 0), origin=(0, 0, 0))

        face = visual.box(frame=hexagonal
                          , pos=(math.sqrt(3) / 2.0, 0, 0)
                          , size=(0.01, CAratio, 1)
                          , color=(1, 0.7, 0.2))
        for _i in range(6):
            face = face.__copy__()
            face.rotate(angle=math.pi * 60 / 180, axis=(0, 1, 0), origin=(0, 0, 0))

        visual.arrow(frame=hexagonal
                     , pos=(0, CAratio / 2, 0)
                     , axis=(0, 0.5, 0)
                     , shaftwidth=0.1
                     , color=(1, 0, 0))

        visual.arrow(frame=hexagonal
                     , pos=(CAratio / 2, 0, 0)
                     , axis=(0.5, 0, 0)
                     , shaftwidth=0.1
                     , color=(0, 1, 0))

        return hexagonal
Exemple #33
0
 def draw(self):
     import visual
     frame = visual.frame()
     outline = visual.curve(frame=frame,
                            pos=[(0.0,0.0,0.0),(1.0,0.0,0.0),
                                 (1.0,1.0,0.0),(0.0,1.0,0.0),
                                 (0.0,0.0,0.0)],color=visual.color.red)
     for e in self.elements:
         outline = []
         for n in e.nodes:
             for d in n.dofs:
                 if d.name=="Displacement":
                     outline.append( (n.position.x + d.value[0],
                                      n.position.y + d.value[1],
                                      0.0) )
                     break
             else:
                 outline.append( (n.position.x, n.position.y,0.0) )
         outline.append(outline[0])
         visual.curve(frame=frame,pos=outline)
     return frame
Exemple #34
0
 def draw(self):
     import visual
     frame = visual.frame()
     outline = visual.curve(frame=frame,
                            pos=[(0.0,0.0,0.0),(1.0,0.0,0.0),
                                 (1.0,1.0,0.0),(0.0,1.0,0.0),
                                 (0.0,0.0,0.0)],color=visual.color.red)
     for e in self.elements:
         outline = []
         for n in e.nodes:
             for d in n.dofs:
                 if d.name=="Displacement":
                     outline.append( (n.position.x + d.value[0],
                                      n.position.y + d.value[1],
                                      0.0) )
                     break
             else:
                 outline.append( (n.position.x, n.position.y,0.0) )
         outline.append(outline[0])
         visual.curve(frame=frame,pos=outline)
     return frame
Exemple #35
0
def draw_camera_frame():
    """Create frame and draw its contents."""
    global  CAM_BOX, CENT_PLANE, CAM_LAB, CAN_TRI, RANGE_LAB, LINELEN, FWD_LINE
    global FWR_ARROW, MOUSE_LINE, MOUSE_ARROW, MOUSE_LAB, FOV, RANGE_X, CAM_DIST, CAM_FRAME
    global RAY
    CAM_FRAME = vs.frame(pos=vs.vector(0, 2, 2, ), axis=(0, 0, 1))
               # NB: contents are rel to this frame.  start with camera looking "forward"
               # origin is at simulated scene.center
    FOV = vs.pi/3.0  # 60 deg
    RANGE_X = 6  # simulates scene.range.x
    CAM_DIST = RANGE_X / vs.tan(FOV/2.0)  # distance between camera and center.
    RAY = vs.vector(-20.0, 2.5, 3.0).norm()  # (unit) direction of ray vector (arbitrary)
                                         #  REL TO CAMERA FRAME
    CAM_BOX = vs.box(frame=CAM_FRAME, length=1.5, height=1, width=1.0,
                     color=CLR.blue, pos=(CAM_DIST, 0, 0)) # camera-box
    CENT_PLANE = vs.box(frame=CAM_FRAME, length=0.01, height=RANGE_X*1.3,
                        width=RANGE_X*2, pos=(0, 0, 0), opacity=0.5)  # central plane
    CAM_LAB = vs.label(frame=CAM_FRAME, text='U', pos=(CAM_DIST, 0, 0),
                       height=9, xoffset=6)
    CAN_TRI = vs.faces(frame=CAM_FRAME, pos=[
        (0, 0, 0), (0, 0, -RANGE_X), (CAM_DIST, 0, 0)])
    CAN_TRI.make_normals()
    CAN_TRI.make_twosided()
    RANGE_LAB = vs.label(frame=CAM_FRAME, text='R', pos=(0, 0, -RANGE_X),
                         height=9, xoffset=6)
    LINELEN = SCENE_SIZE + vs.mag(
        CAM_FRAME.axis.norm()*CAM_DIST + CAM_FRAME.pos)  # len of lines from camera

    FWD_LINE = draw_line(vs.vector(CAM_DIST, 0, 0), LINELEN, vs.vector(-1, 0, 0))
    FWR_ARROW = vs.arrow(frame=CAM_FRAME, axis=(-2, 0, 0), pos=(CAM_DIST, 0, 0),
                         shaftwidth=0.08, color=CLR.yellow)
    vs.label(frame=CAM_FRAME, text='C', pos=(0, 0, 0), height=9, xoffset=6,
             color=CLR.yellow)
    MOUSE_LINE = draw_line(vs.vector(CAM_DIST, 0, 0), LINELEN, RAY)
    MOUSE_ARROW = vs.arrow(frame=CAM_FRAME, axis=RAY*2, pos=(CAM_DIST, 0, 0),
                           shaftwidth=0.08, color=CLR.red)
    MOUSE_LAB = vs.label(
        frame=CAM_FRAME, text='M', height=9, xoffset=10,
        color=CLR.red,
        pos=-RAY*(CAM_DIST/vs.dot(RAY, (1, 0, 0))) + (CAM_DIST, 0, 0))
Exemple #36
0
def vs_loop():

    #pan_inc = 0.25
    #zoom_inc = array((0.25,0.25,0.25))
    pan_inc = 0.25
    zoom_inc = array((0.05,0.05,0.05))

    # for scene rotation with invariant light direction
    light_frame = vs.frame()
    for obj in vs.scene.lights:
        if isinstance(obj, vs.distant_light):
            obj.frame = light_frame # put distant lights in a frame
    prev_scene_forward = vs.vector(vs.scene.forward) # keep a copy of the old forward

    while True:

        if vs.scene.kb.keys:
            key = vs.scene.kb.getkey()

            if key == 'up':
                vs.scene.center = array(vs.scene.center) + array((0,pan_inc,0))
            elif key == 'down':
                vs.scene.center = array(vs.scene.center) + array((0,-pan_inc,0))
            elif key == 'left':
                vs.scene.center = array(vs.scene.center) + array((-pan_inc,0,0))
            elif key == 'right':
                vs.scene.center = array(vs.scene.center) + array((pan_inc,0,0))

            elif key == 'shift+up':
                vs.scene.range -= zoom_inc
            elif key == 'shift+down':
                vs.scene.range += zoom_inc

        if vs.scene.forward != prev_scene_forward:
            new = vs.scene.forward
            axis = vs.cross(prev_scene_forward, new)
            angle = new.diff_angle(prev_scene_forward)
            light_frame.rotate(axis=axis, angle=angle)
            prev_scene_forward = vs.vector(new)
Exemple #37
0
def update_grid():
    delete_current_grid()

    if not showSpan:
        return

    global span_frame

    span_frame = visual.frame()

    vecs = map(lambda i: visual.vector(vectors[i].axis) * span_fact, selected)
    for v in vecs:
        rest = vecs[0:len(vecs)]  # deep copy
        rest.remove(v)
        all_sums = all_sums_comb(rest)
        for aSum in all_sums:
            visual.curve(frame=span_frame,
                         pos=[aSum, aSum + v],
                         color=span_color)
            if not is_span_positive:
                visual.curve(frame=span_frame,
                             pos=[aSum, aSum - v],
                             color=span_color)
Exemple #38
0
    def __init__(self, avgDistance, mapping=None):
        self.avgDistance = avgDistance
        self.pointNum = FibGrid.getPointNum(avgDistance)
        self.totalPointNum = 2 * self.pointNum + 1
        self.zIncrement = 2.0 / self.totalPointNum

        self.coverage = [None for i in xrange(0, self.totalPointNum)]

        self.resolution = 5
        if not mapping:
            mapping = CartesianArray(
                SEMICIRCLE / avgDistance * self.resolution,
                CIRCLE / avgDistance * self.resolution)
            for i, j in mapping.getIds():
                lat, lon = mapping.idToPos((i, j))
                mapping.array[i, j] = self._getIndex((lat, lon))
        self.mapping = mapping

        self.frame = frame(visible=False)

        self.points = [None for i in xrange(0, self.totalPointNum)]
        for i in self.getIndices():
            self.points[i] = toCartesian(self._getSpherical(i))
Exemple #39
0
 def render(self):
     self.frame = frame = visual.frame()
     color = (1., 1., .6)
     visual.box(length=self.width+.099, height=self.height+.099, width=.1,
                pos=(0, 0, -.55), color=(.8, .8, 1.), frame=frame)
     for y in range(self.height):
         for x in range(self.width):
             cell = self.cells[x][y]
             if cell.wall[2]:
                 visual.rate(self.wall_rate)
                 visual.box(length=.1, height=1.1, width=1.1,
                            pos=(x - self.width / 2.,
                                 y - (self.width - 1) / 2.,
                                 0), color=color, frame=frame)
             if cell.wall[3]:
                 visual.rate(self.wall_rate)
                 visual.box(height=.1, length=1.1, width=1.1,
                            pos=(x - (self.width - 1) / 2.,
                                 y - self.width / 2.,
                                 0), color=color, frame=frame)
     visual.box(length=self.width + .1, height=.1, width=1.1,
                pos=(0, self.height / 2., 0), color=color, frame=frame)
     visual.box(length=.1, height=self.height + .1, width=1.1,
                pos=(self.width / 2., 0, 0), color=color, frame=frame)
Exemple #40
0
 def drawaxis(self):
    scale=int(self.scale_factor)
    marker=10/(scale*1.5)
    axis=visual.frame()
    self.y_axis=visual.curve(frame=axis,pos=[(0.0,scale,0.0),
                     (0.0,-scale,0.0)],color=RED)
    self.y_markers=[]
    for i in range(-scale,scale+1):
       self.y_markers.append(visual.curve(frame=axis,pos=[(-marker,i,0),
                            (marker,i,0)],color=RED))
    self.x_axis=visual.curve(frame=axis,pos=[(scale,0.0,0.0),
                     (-scale,0.0,0.0)],color=BLUE)
    self.x_markers=[]
    for i in range(-scale,scale+1):
       self.x_markers.append(visual.curve(frame=axis,pos=[(i,-marker,0),
                            (i,marker,0)],color=BLUE))
    if not self.axis_2d:
       self.z_axis=visual.curve(frame=axis,pos=[(0.0,0.0,scale),
                     (0.0,0.0,-scale)],color=GREEN)
       self.z_markers=[]
       for i in range(-scale,scale+1):
          self.z_markers.append(visual.curve(frame=axis,pos=[(0,-marker,i),
                            (0,marker,i)],color=GREEN))
       self.axis_on=True
Exemple #41
0
    def plate(self):
        if (self.container):
            for obj in self.container.objects:
                obj.visible = 0
        self.container = visual.frame()
        field_length = self.length() + 2 * self.config['display']['radius']
        field_width = 3 * self.config['display']['radius'] * self.count + 10
        if (self.ordered):
            init = self.conns[0].obj[self.orderby]
            pborder = 0
            t = -1
            i = 0
            for conn in self.conns:
                if (init != conn.obj[self.orderby]):
                    if ((i % 2) == 1):
                        bcolor = self.config['colors']['box_light']
                    else:
                        bcolor = self.config['colors']['box']

                    if type(init) == (type(1)):
                        labeltext = self.orderby + "\n%d" % (init)
                    elif type(init) == (type('str')):
                        labeltext = self.orderby + "\n'%s'" % (init)
                    visual.box(frame=self.container, pos=(field_length/2 - self.level, -(self.config['display']['radius']+1), 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2), \
                             width = (3*self.config['display']['radius']*t - pborder), length = field_length, height = 1, color = bcolor)
                    visual.label(frame=self.container, pos = (self.config['display']['radius'] -self.level, 0,  3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2),\
                        yoffset = 4*self.config['display']['radius'], xoffset = -4* self.config['display']['radius'],text = labeltext)
                    pborder = 3 * self.config['display'][
                        'radius'] * t + self.config['display']['radius']
                    init = conn.obj[self.orderby]
                    i += 1
                t += 1

            if type(init) == (type(1)):
                labeltext = self.orderby + "\n%d" % (init)
            elif type(init) == (type('str')):
                labeltext = self.orderby + "\n'%s'" % (init)
            if ((i % 2) == 1):
                bcolor = self.config['colors']['box_light']
            else:
                bcolor = self.config['colors']['box']
            visual.box(frame=self.container, pos=(field_length/2 - self.level, -(self.config['display']['radius']+1), 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2), \
                     width = (3*self.config['display']['radius']*t - pborder), length = field_length, height = 1, color = bcolor)
            visual.label(frame=self.container, pos = (self.config['display']['radius'] - self.level, 0, 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2),\
                yoffset = 4*self.config['display']['radius'], xoffset = -4* self.config['display']['radius'], text = labeltext)
        else:
            visual.box(frame=self.container,
                       pos=(field_length / 2 - self.level,
                            -(self.config['display']['radius'] + 1),
                            field_width / 2),
                       width=field_width,
                       length=field_length,
                       height=1,
                       color=self.config['colors']['box'])

        desctext = 'From %s to %s\n' % (time.strftime("%F %H:%M:%S", time.localtime(self.starttime)), \
            time.strftime("%F %H:%M:%S", time.localtime(self.endtime)))
        desctext += self.build_str_filter(" and ", "Filtering on ")
        visual.label(frame=self.container,
                     pos=(field_length / 2 - self.level,
                          self.config['display']['radius'] + 0.5, 0),
                     yoffset=4 * self.config['display']['radius'],
                     text=desctext)
        for i in range(self.config['display']['graduation']):
            visual.curve(
                frame=self.container,
                pos=[(field_length / self.config['display']['graduation'] * i -
                      self.level, -(self.config['display']['radius'] + 1) + 1,
                      0),
                     (field_length / self.config['display']['graduation'] * i -
                      self.level, -(self.config['display']['radius'] + 1) + 1,
                      field_width)])
        for i in range(self.config['display']['graduation'] /
                       self.config['display']['tick'] + 1):
            ctime = time.strftime(
                "%H:%M:%S",
                time.localtime(self.mintime + field_length /
                               self.config['display']['graduation'] *
                               self.config['display']['tick'] * i))
            visual.label(
                frame=self.container,
                pos=(field_length / self.config['display']['graduation'] *
                     self.config['display']['tick'] * i - self.level,
                     -(self.config['display']['radius'] + 1) + 1, 0),
                text='%s' % (ctime),
                border=5,
                yoffset=1.5 * self.config['display']['radius'])
Exemple #42
0
def point_source_strength(time_hours):
    if time_factory_start < time_hours < time_factory_end :
        Q= df1.Values[1]/(delta_x*delta_y*delta_z) *10**-3 #microgram/m**3-s
    else:
        Q=0
    return Q

#generating the array of boxes
scale_factor= 14 #defining a scale factor to enlarge the frame
scene2 = display(title='Plume Dispersion',
     x=0, y=0, width=2500, height=400,
     center=(1,1,1), background=(0,0,0), userzoom= True)
     

#creating the frame
f= frame()    
list_of_boxes=[]
for i in range(n_x+2):
    for j in range(n_y+2):
        for k in range(n_z+2):
            boxes= box(frame=f,pos= vector(i*delta_x*scale_factor,j*delta_y* scale_factor,k*delta_z*scale_factor),length= delta_x*scale_factor , width= delta_z *scale_factor  , height= delta_y *scale_factor, opacity=0)
            list_of_boxes+= [boxes]
            
array_of_boxes= np.reshape(list_of_boxes,(n_x+2,n_y+2,n_z+2))
cylinder(frame=f, pos= vector(loc_point_source[0]*delta_x*scale_factor,loc_point_source[1]*delta_y* scale_factor,0) , axis= (0,0,1), radius= .5, height= H/1000, color= color.white, material= materials.rough, opacity=1 )

l= label(frame=f, pos= (0,4,l_z+2), text= "Time:")
factory_label= label(frame=f, pos= vector(loc_point_source[0]*delta_x*scale_factor,loc_point_source[1]*delta_y* scale_factor,0),xoffset= 0, zoffset=-2, yoffset=-1, text="Factory"  )
highway_label= label(frame=f, pos =vector(13,-1,-1), text= "Highway",zoffset=-1)
location_label= label(frame=f,pos= array_of_boxes[location_for_plot].pos, xoffset=1, yoffset=-1,zoffset=-1,text="My Home")
Exemple #43
0
 def __init__(self,spos,sColor, fr):
     self.base = vis.frame(pos=spos, frame=fr)
     vis.cylinder(frame=self.base,pos=(0,0,0),radius=0.4,length=1.0,axis=(0,1,0),color=sColor)
     vis.sphere(frame=self.base,radius=0.4,pos=(0,1.4,0),color=sColor)
Exemple #44
0
vp.scene.height = vp.scene.width = 800
vp.scene.center = (0.3, -2.4, 0)

def spiral(nloop=1, tightness=1.0, dirctn=1.0, scale=1.0):
    """ Draw a spiral."""
    spr = []
    scale = []
    clrs = []
    #zd = 0.01
    for turn in range(1, 1024*nloop, 16):
        turn *= 0.01
        x_val = tightness/10.0 * turn * math.cos(turn)*dirctn
        y_val = tightness/10.0 * turn * math.sin(turn)
        sc_val = math.sqrt(x_val*x_val+y_val*y_val)
        z_val = turn/7.0
        spr.append((x_val, y_val, z_val))
        clr = vp.vector((z_val*math.cos(turn), abs(math.sin(turn)),
                         abs(math.cos(turn*2)))).norm()
        clrs.append(clr)
        scale.append((sc_val, sc_val))
    return spr, scale, clrs

PATH, SCALE, CLRS = spiral(nloop=2, tightness=0.8)
ELPS = vp.shapes.circle(radius=0.69, thickness=0.01)

EE = vp.extrusion(frame=vp.frame(), shape=ELPS, pos=PATH, scale=SCALE, color=CLRS,
                  material=vp.materials.marble)
EE.frame.rotate(angle=math.pi/2)

Exemple #45
0
        rate (100)
        for name, card in cards.iteritems():
            card()

if __name__ == "__main__":

    # Initialize the web interface.
    (host, port, backlog, size) = ('', 50000, 5, 1024)
    s = socket(AF_INET, SOCK_STREAM) 
    s.bind((host, port)) 
    s.listen(backlog) 

    # Initialize the visual python scene.
    scene.exit = True
    scene.title = 'card3d: prototype'
    f = frame()

    # Initialize the card contents from the configuration file.
    (config, cards) = getCards(f, 'card3d.cfg')

    # Define the spinning functions
    def spinLeft(f):
        f.rotate(angle = +0.1, axis = (1, 0, 0))

    def spinRight(f):
        f.rotate(angle = -0.1, axis = (1, 0, 0))

    def spinForward(f):
        f.rotate(angle = +0.1, axis = (0, 1, 0))

    def spinBackward(f):
Exemple #46
0
 def draw(self):
     self.f = visual.frame()
     self.vis = visual.box(frame=self.f)
     Primitive.draw(self)
Exemple #47
0
 def draw(self):
     self.f = visual.frame()
     self.vis = visual.label(frame=self.f, box=False)
     Primitive.draw(self)
Exemple #48
0
 def draw(self):
     self.f = visual.frame()
     self.vis = visual.cylinder(frame=self.f)
     Primitive.draw(self)
Exemple #49
0
 def draw(self):
     self.f = visual.frame()
     self.vis = visual.curve(frame=self.f, x=[0, 1, 2])
     Primitive.draw(self)
Exemple #50
0

def find_index(obj, objs):
    i = 0
    for o in objs:
        if o == obj:
            return i
        i += 1
    return None


is_span_positive = True

current_span = visual.curve()

span_frame = visual.frame()

span_color = visual.color.yellow
span_fact = 1.2


def update_convex():
    if not showSpan:
        return
    global current_span
    current_span.visible = 0

    poss = [orig]
    sum = visual.vector(orig)

    vecs = map(lambda i: vectors[i].axis * span_fact, selected)
Exemple #51
0
x=xx
y=yy
z=zz
#roundnum=14
#def roundarray(l,roundnum):
#  return (np.array(l)*10**roundnum).round()/10**roundnum
#x=roundarray(x,roundnum)
#y=roundarray(y,roundnum)
#z=roundarray(z,roundnum)
#x=xx
#y=yy
#z=zz

r1data=[(0,(0,0,1)),(np.pi/2,(0,0,1)),(np.pi/2,(0,0,1))]
r2data=[(0,(0,0,1)),(np.pi/2,(1,0,0)),(np.pi/2,(0,1,0))]
lframe = vs.frame()
for obj in vs.scene.lights:
    if isinstance(obj, vs.distant_light):
        obj.frame = lframe # put distant lights in a frame
old = vs.vector(vs.scene.forward) # keep a copy of the old forward

for k in range(len(r1data)):
  for i in range(len(x)):
    hexagon = vs.convex(color=(0.7,0.7,0.7))
    L = []
    r=0.264*(2*3**0.5+1)
    rr=r/3**0.5*2
    h=0.254+0.2
    rru=rr/R*(R-h)
    theta=thetaList[i]
    phi=phiList[i]
Exemple #52
0
showSpan = True 

def find_index(obj,objs):
    i = 0 
    for o in objs:
        if o == obj:
            return i
        i +=1
    return None  


is_span_positive = True

current_span = visual.curve()

span_frame = visual.frame() 

span_color = visual.color.yellow
span_fact = 1.2


def update_convex():
    if not showSpan:
        return 
    global current_span
    current_span.visible = 0 

    poss = [orig] 
    sum = visual.vector(orig)

    vecs = map(lambda i:vectors[i].axis * span_fact, selected)
Exemple #53
0
 def __init__(self,spos,sColor, fr):
     self.base = vis.frame(pos=spos, frame=fr)
     vis.cylinder(frame=self.base,pos=(0,0,0),radius=0.4,length=1.2,axis=(0,1,0),color=sColor)
     vis.box(frame=self.base,height=0.6,width=0.6,length=0.6,pos=(0,1.5,0),color=sColor)
Exemple #54
0
 def draw(self):
     self.f = visual.frame()
     self.vis = visual.arrow(frame=self.f, axis=(0, 0, 1))
     Primitive.draw(self)