当前位置: 首页>>代码示例>>Python>>正文


Python visual.arrow函数代码示例

本文整理汇总了Python中visual.arrow函数的典型用法代码示例。如果您正苦于以下问题:Python arrow函数的具体用法?Python arrow怎么用?Python arrow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了arrow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_visual

    def init_visual(self, only_wiiobj=False):
        visual_pos = ((0, 0, 0), (7,7,0), (14,14,0))
        if not only_wiiobj:
            #vpython
            visual.scene.width=self.param["width"] * 3
            visual.scene.height=self.param["height"]
            visual.scene.title = "3D WiiMote Simulation"
            visual.scene.forward = visual.vector(1,0,0) # not to error ?
            visual.scene.up = visual.vector(0,0,1)
            visual.scene.forward = visual.vector(-1,1,-1)
            visual.scene.center = (7,7,0)
            visual.scene.scale = (0.07, 0.07, 0.07)
            visual.scene.autoscale = 0
            visual.scene.x = 0
            visual.scene.y = 30
            
            self.visual["axis"] = [(visual.arrow(pos=visual_pos[i], color=visual.color.red, axis=(3,0,0), headwidth=1, shaftwidth=0.5, fixedwidth=1),
                                    visual.arrow(pos=visual_pos[i], color=visual.color.green, axis=(0,3,0), headwidth=1, shaftwidth=0.5, fixedwidth=1),
                                    visual.arrow(pos=visual_pos[i], color=visual.color.blue, axis=(0,0,3), headwidth=1, shaftwidth=0.5, fixedwidth=1))
                                   for i in xrange(3)]
            self.visual["text"] = [visual.label(text="accel", pos=(1, -1, -4), color=visual.color.white),
                                   visual.label(text="gyro", pos=(8, 6, -4), color=visual.color.white),
                                   visual.label(text="accel + gyro", pos=(15, 13, -4), color=visual.color.white),]
        self.visual["wiiobj"] = [visual.box(pos=visual_pos[i], length=2, height=6, width=1, color=visual.color.white, axis=(1,0,0)) #x=length, y=height, z=width
                                 for i in xrange(3)]

        return
开发者ID:pheehs,项目名称:PyWiiRemote,代码行数:27,代码来源:WiiRemoteMain-acc.py

示例2: init_visual

    def init_visual(self, only_wiiobj=False):
        if not only_wiiobj:
            # vpython
            visual.scene.width = self.param["width"]
            visual.scene.height = self.param["height"]
            visual.scene.title = "3D WiiMote Simulation"
            visual.scene.forward = visual.vector(1, 0, 0)  # not to error ?
            visual.scene.up = visual.vector(0, 0, 1)
            visual.scene.forward = visual.vector(-1, 1, -1)
            visual.scene.autoscale = 0
            visual.scene.x = 0
            visual.scene.y = 30

            self.visual["axis"][0] = visual.arrow(
                color=visual.color.red, axis=(3, 0, 0), headwidth=1, shaftwidth=0.5, fixedwidth=1
            )
            self.visual["axis"][1] = visual.arrow(
                color=visual.color.green, axis=(0, 3, 0), headwidth=1, shaftwidth=0.5, fixedwidth=1
            )
            self.visual["axis"][2] = visual.arrow(
                color=visual.color.blue, axis=(0, 0, 3), headwidth=1, shaftwidth=0.5, fixedwidth=1
            )
        self.visual["wiiobj"] = visual.box(
            pos=(0, 0, 0), length=2, height=6, width=1, color=visual.color.white, axis=(2, 0, 0)
        )

        return
开发者ID:pheehs,项目名称:PyWiiRemote,代码行数:27,代码来源:WiiRemoteMain.old.py

示例3: drawCameraFrame

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))
开发者ID:BruceSherwood,项目名称:vpython-wx,代码行数:32,代码来源:camera.py

示例4: draw_efield

def draw_efield(V, scale):      # draw electric field
    Ex, Ey = np.gradient(-V)
    Emag = np.sqrt(Ex*Ex + Ey*Ey)
    for i in range(2, M-1, 2):
        for j in range(2, N-1, 2):
            vp.arrow(pos=(i,j), axis=(Ex[i,j], Ey[i,j]), 
                     length=Emag[i,j]*scale)
        vp.rate(100)
    return Ex, Ey
开发者ID:com-py,项目名称:compy,代码行数:9,代码来源:Program_7.2_laplace.py

示例5: plot3D

    def plot3D(self):
		axis_length = 10.0
		xaxis = vs.arrow(pos = (-5, -5, 0), axis = (axis_length, 0, 0), shaftwidth = 0.01)
		yaxis = vs.arrow(pos = (-5, -5, 0), axis = (0, axis_length, 0), shaftwidth = 0.01)
		balls = []
		for (i, j) in zip(self.x, self.T):
			balls.append(vs.sphere(pos = ((j / self.time) * axis_length * 0.9- 4.9, (i / self.v) * axis_length * 0.9 - 4.9, 0), radius = 0.2, color = vs.color.red))
		xlabel = vs.label(text = "Time/s", pos = (5, -5, 0))
		ylabel = vs.label(text = "Displacement/m", pos = (-5, 5, 0))
开发者ID:PatYoung,项目名称:computationalphysics_N2013301020016,代码行数:9,代码来源:01.py

示例6: plot3D

def plot3D():
    axis_length=10.0
    vs.xaxis=vs.arrow(pos=(-5,-5,0),axis=(axis_length,0,0),shaftwidth=0.05)
    vs.yaxis=vs.arrow(pos=(-5, -5, 0), axis=(0, axis_length, 0), shaftwidth=0.05)
    balls=[]
    for (i,j) in zip(N,t):
        balls.append(vs.sphere(pos=(((j/time)*axis_length*0.9-4.9,(i/N_O)*axis_length*0.9-4.9,0)),radius=0.2,color=vs.color.red))
    vs.xlabel = vs.label(text = "time", pos = (5, -5, 0))
    vs.ylabel = vs.label(text = "Number of people", pos = (-5,5,0))
开发者ID:PatYoung,项目名称:computationalphysics_N2013301020017,代码行数:9,代码来源:exercise1-6.py

示例7: __init__

    def __init__(self):
        # For converting
        self.rt_mx = np.matrix([[1, 0, 0],
                                [0, 0, 1],
                                [0, -1, 0]])

        self.x = visual.arrow(color=(1,0,0))
        self.y = visual.arrow(color=(0,1,0))
        self.z = visual.arrow(color=(0,0,1))
开发者ID:zhaostu,项目名称:gibbon,代码行数:9,代码来源:gibbon.py

示例8: plot3D

 def plot3D(self):
     axis_length = 10.0
     xaxis = vs.arrow(pos = (-5, -5, 0), axis = (axis_length, 0, 0), shaftwidth = 0.01)
     yaxis = vs.arrow(pos = (-5, -5, 0), axis = (0, axis_length, 0), shaftwidth = 0.01)
     balls = []
     for (i, j) in zip(self.n_uranium, self.T):
         balls.append(vs.sphere(pos = ((j / self.time) * axis_length * 0.9- 4.9, (i / self.N) * axis_length * 0.9 - 4.9, 0), radius = 0.2, color = vs.color.red))
     xlabel = vs.label(text = "time", pos = (5, -5, 0))
     ylabel = vs.label(text = "Number of Nuclei", pos = (-5, 5, 0))
     while 1:
         pass
开发者ID:1098605130,项目名称:computational_physics_whu,代码行数:11,代码来源:uranium_decay_3d.py

示例9: animate_motion

def animate_motion(x, k):
    # Animate using Visual-Python
    CO = zeros((n, 3))
    B2 = zeros((n, 3))
    C1 = zeros((n, 3))
    C3 = zeros((n, 3))
    CN = zeros((n, 3))

    for i, state in enumerate(x[:,:5]):
        CO[i], B2[i], C1[i], C3[i] = rd.anim(state, r)
        # Make the out of plane axis shorter since this is what control the height
        # of the cone
        B2[i] *= 0.001
        C1[i] *= r
        C3[i] *= r
        CN[i, 0] = state[3]
        CN[i, 1] = state[4]

    from visual import display, rate, arrow, curve, cone, box
    black = (0,0,0)
    red = (1, 0, 0)
    green = (0, 1, 0)
    blue = (0, 0, 1)
    white = (1, 1, 1)
    NO = (0,0,0)
    scene = display(title='Rolling disc @ %0.2f realtime'%k, width=800,
            height=800, up=(0,0,-1), uniform=1, background=white, forward=(1,0,0))
    # Inertial reference frame arrows
    N = [arrow(pos=NO,axis=(.001,0,0),color=red),
         arrow(pos=NO,axis=(0,.001,0),color=green),
         arrow(pos=NO,axis=(0,0,.001),color=blue)]
    # Two cones are used to look like a thin disc
    body1 = cone(pos=CO[0], axis=B2[0], radius=r, color=blue)
    body2 = cone(pos=CO[0], axis=-B2[0], radius=r, color=blue)
    # Body fixed coordinates in plane of disc, can't really be seen through cones
    c1 = arrow(pos=CO[0],axis=C1[0],length=r,color=red)
    c3 = arrow(pos=CO[0],axis=C3[0],length=r,color=green)
    trail = curve()
    trail.append(pos=CN[0], color=black)
    i = 1
    while i<n:
        rate(k/ts)
        body1.pos = CO[i]
        body1.axis = B2[i]
        body2.pos = CO[i]
        body2.axis = -B2[i]
        c1.pos = body1.pos
        c3.pos = body1.pos
        c1.axis = C1[i]
        c3.axis = C3[i]
        c1.up = C3[i]
        c3.up = C1[i]
        trail.append(pos=CN[i])
        i += 1
开发者ID:certik,项目名称:pydy,代码行数:54,代码来源:plot_rollingdisc.py

示例10: __init__

 def __init__(self, size=None):
     visual.frame.__init__(self)
     if not size:
         size = AxesXYZ.d_size
     self.x_axis = visual.arrow(axis=(size, 0.0, 0.0))
     self.x_axis.color = visual.color.red
     self.x_axis.frame = self
     self.y_axis = visual.arrow(axis=(0.0, size, 0.0))
     self.y_axis.color = visual.color.green
     self.y_axis.frame = self
     self.z_axis = visual.arrow(axis=(0.0, 0.0, size))
     self.z_axis.color = visual.color.blue
     self.z_axis.frame = self
     self.visible(AxesXYZ.d_visible)
     AxesXYZ.members.append(self)
开发者ID:hsnuhayato,项目名称:iv-plan-hironx,代码行数:15,代码来源:object_model_v.py

示例11: draw_crystal

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)
开发者ID:ajsteele,项目名称:mmcalc,代码行数:28,代码来源:didraw.py

示例12: vector_field

def vector_field(r,vec,vmin,vmax,colourtype,lengthtype,scale):
	field = []
	#work out limits of phi if not provided
	if(vmin==vmax==0):
		vmin,vmax = difn.vector_min_max(vec)
		#if they're the same because all passed field values are identical
		if(vmin==vmax):
			vmin = 0
	v_unit = difn.unit_vectors(vec)	
	for i in range(len(r)):
		modv = np.sqrt(np.dot(vec[i],vec[i]))
		val = (modv-vmin)/(vmax-vmin)
		if colourtype == 'fadetoblack':
			colour = (val,val,val)
		elif colourtype == 'rainbow':
			colour = col_rainbow(val)
			opacity = 1.0
		else:
			colour = (1,1,1) #default to white if nothing is specified
		if lengthtype.__class__.__name__ == 'float' or lengthtype.__class__.__name__ == 'int':
			length = np.float(lengthtype)
		elif lengthtype == 'proportional':
			length = modv/vmax #we never want the arrows to have zero length, so effectively set vmin=0 whatever happens
		else:
			length = 1
		if length != 0:
			scalefactor = 0.3
			field.append(v.arrow(pos=r[i]-0.5*length*scale*scalefactor*v_unit[i], axis=length*scale*scalefactor*v_unit[i], color=colour)) #length needs to be determined automatically
	return field
开发者ID:ajsteele,项目名称:mmcalc,代码行数:29,代码来源:didraw.py

示例13: _displayDiff

 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
                              ))
开发者ID:rkdarst,项目名称:saiga12,代码行数:27,代码来源:viz.py

示例14: preliminary_scan

    def preliminary_scan(self):
        # During the first time-step we only collect all the positions:
        # we will create an arrow for every position encountered
        i = 0  # column number
        t_old = 0.0
        self.field_size = 0
        self.arrows = []
        field_sum = [0.0, 0.0, 0.0]
        max_x = 0.0
        max_y = 0.0
        max_z = 0.0

        while True:
            self.last_line = self.file.readline()
            col = self.read_line(self.last_line)
            t = float(col[0])
            if (i > 0) & (t != t_old):
                break

            i = i + 1
            t_old = t

            # Read the postition where the field is located
            p = self.adjust_pos([float(col[1]), float(col[2]), float(col[3])])

            if abs(p[0]) > max_x:
                max_x = abs(p[0])
            if abs(p[1]) > max_y:
                max_y = abs(p[1])
            if abs(p[2]) > max_z:
                max_z = abs(p[2])

            # Read the field
            field = self.adjust_vector([float(col[4]), float(col[5]), float(col[6])])
            field_sum[0] += field[0]
            field_sum[1] += field[1]
            field_sum[2] += field[2]

            if random.random() <= self.decimate:
                sph = visual.sphere(color=self.pnt_col, pos=p, radius=self.pnt_radius)
                arr = visual.arrow(color=self.arrow_col, pos=p, axis=field, shaftwidth=self.arrow_shaftwidth)
                on = True
            else:
                sph = None
                arr = None
                on = False

            self.arrows.append([on, p, arr, sph])
            self.field_size += 1

        self.max_abs_coords = [max_x, max_y, max_z]
        self.t_old = t

        # Now we calculate the mean magnetization
        self.field_mean[0] = field_sum[0] / self.field_size
        self.field_mean[1] = field_sum[1] / self.field_size
        self.field_mean[2] = field_sum[2] / self.field_size
        self.first_scan = True
开发者ID:fangohr,项目名称:nmag-src,代码行数:58,代码来源:vec3d.py

示例15: showArrow

 def showArrow():
     for key in self.net.neuron_to_neuron_weight:
         from_neuron=key[:key.find('_to_')]
         to_neuron=key[key.find('to_')+3:]
         if self.net.neuron_to_neuron_weight[key]!=None:
             delta_x=self.neuron_position[to_neuron][0]-self.neuron_position[from_neuron][0]
             delta_y=self.neuron_position[to_neuron][1]-self.neuron_position[from_neuron][1]                   
             delta_z=self.neuron_position[to_neuron][2]-self.neuron_position[from_neuron][2]                    
             pointer=visual.arrow(pos=self.neuron_position[from_neuron], axis=(delta_x,delta_y,delta_z), shaftwidth=0.1)
     
     for key in self.net.neuron_in_layer['in']:
         x=self.neuron_position[key][0]-3
         y=self.neuron_position[key][1]
         z=self.neuron_position[key][2]
         pointer=visual.arrow(pos=(x,y,z), axis=(3,0,0), shaftwidth=0.1)
         
     for key in self.net.neuron_in_layer['out']:
         pointer=visual.arrow(pos=self.neuron_position[key], axis=(3,0,0), shaftwidth=0.1)
开发者ID:shd101wyy,项目名称:PyNeuron,代码行数:18,代码来源:show_network_simulation_using_vpython.py


注:本文中的visual.arrow函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。