• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python visual.sphere函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: show_ladybug

    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 )
开发者ID:Ripley6811,项目名称:ladybug-pie,代码行数:29,代码来源:Ladybug_SfM.py


示例2: show_protective

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


示例3: set_scene

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
开发者ID:com-py,项目名称:compy,代码行数:8,代码来源:Program_4.7_r3body.py


示例4: sphere

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)
开发者ID:jsalva,项目名称:computational_physics,代码行数:8,代码来源:demos.py


示例5: draw_node_list

 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)
开发者ID:hageShogun,项目名称:TSP,代码行数:8,代码来源:TSPRouteViewer.py


示例6: main

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()
开发者ID:m4r35n357,项目名称:BlackHole4DPython,代码行数:58,代码来源:plotBH.py


示例7: set_scene

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
开发者ID:com-py,项目名称:compy,代码行数:9,代码来源:Program_4.5_3body.v1.py


示例8: marks

 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")
开发者ID:drewsday,项目名称:Old-Code,代码行数:9,代码来源:timer.py


示例9: __init__

    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)
开发者ID:fma38,项目名称:Py4bot,代码行数:9,代码来源:actuators3D.py


示例10: __init__

    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)
开发者ID:fma38,项目名称:Py4bot,代码行数:10,代码来源:hexapod.py


示例11: create_color_cube

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)
开发者ID:mescai,项目名称:ThinkPythonExcise,代码行数:11,代码来源:Excise178.py


示例12: create_cube

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)
开发者ID:mescai,项目名称:ThinkPythonExcise,代码行数:12,代码来源:Excise178.py


示例13: addSphere

 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)
开发者ID:jkudlerflam,项目名称:pvtrace,代码行数:12,代码来源:Visualise.py


示例14: PlotElevator

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
开发者ID:Milias,项目名称:ModellingSimulation,代码行数:53,代码来源:repr.py


示例15: set_scene

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
开发者ID:com-py,项目名称:compy,代码行数:12,代码来源:Program_4.3_mercury.py


示例16: generate_obstacles

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
开发者ID:LG95,项目名称:Path-planning-animation,代码行数:13,代码来源:obstacles.py


示例17: sodium_chloride

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)
开发者ID:jsalva,项目名称:computational_physics,代码行数:30,代码来源:demos.py


示例18: draw_spatial_center

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)
开发者ID:peter-juritz,项目名称:computational-chemistry,代码行数:15,代码来源:visualize_molecule.py


示例19: __init__

	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
开发者ID:lauyader,项目名称:proyectoPython,代码行数:7,代码来源:qt.py


示例20: _displayAtoms

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python visual.vector函数代码示例发布时间:2022-05-26
下一篇:
Python visual.rate函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap