本文整理汇总了Python中visual.display函数的典型用法代码示例。如果您正苦于以下问题:Python display函数的具体用法?Python display怎么用?Python display使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了display函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: __init__
def __init__(self, npts=100000, Rotate=False, title=''):
ptsize = 3
mapptsize = 1
self.scene_angle = 0
self.localscene = visual.display(title=title + ' Local Coordinate System')
self.globalscene = visual.display(title=title + ' Global Coordinate System')
#self.globalscene.background = (1, 1, 1)
#self.globalscene.up = (0, 0, 1)
#self.globalscene.forward = (0, 1, -0.4)
self.currentrow = 0
self.auto_colour = False
# Set up the global coordinate frame visualiser
self.globalscene.select()
self.globalscene.up =(0, 0, 1.0)
#self.visualrobot = visual.box(length=3, height=2, width=1.5)
w = 1
wid = 0.2
self.robotpts = np.array(( (0, -wid, 0, w), (0, wid, 0, w), (3*wid, 0, 0, w), (0, -wid, 0, w) ))
#self.visualrobot = visual.points(pos=self.robotpts[:, :3], size=4, shape='round', color=(0, 1, 1))
self.visualrobot = visual.curve(pos=self.robotpts[:, :3], color=(0, 1, 1))
X = np.array([(-1, -1), (-1, 1), (1, 1), (1, -1), (-1, -1)])
square = visual.curve(pos=50*X)
self.leftmappts = visual.points(size=ptsize, shape='square', color=(1, 0, 0))
self.rightmappts = visual.points(size=ptsize, shape='square', color=(0, 1, 0))
self.spinmappts = visual.points(size=ptsize, shape='square', color=(0, 0, 1))
X = np.zeros((npts, 3))
self.mappts = visual.points(pos=X, size=mapptsize, shape='square', color=(1, 1, 1))
self.trajpts_ind = 0
self.trajpts = visual.points(pos=np.zeros((10000, 3)), color=(0, 0, 1), size=2)
visual.scene.show_rendertime = True
if Rotate:
# Enable continuous rotation
RV = RotateVisual(self.globalscene)
RV.start()
else:
# Enable mouse panning
MT = dispxyz.EnableMouseThread(self.globalscene)
MT.start()
# Set up the local coordinate frame visualiser
if showlocal:
self.localscene.select()
self.leftpts = visual.points(color=(1, 0, 0), size=ptsize, shape='square')
self.rightpts = visual.points(color=(0, 1, 0), size=ptsize, shape='square')
self.spinpts = visual.points(color=(0, 0, 1), size=ptsize, shape='square')
visual.scene.show_rendertime = True
self.colourmin = -4
self.colourmax = 4
示例4: visualize
def visualize(flow_grid, input_grid):
"""
Visualize the flow in flow_grid on input_grid with VPython, using gray
squares for blocked spaces (input_grid[i][j] = 1) and blue squares for
spaces with flow (flow_grid[i][j] = '*').
All objects in the scene will be removed prior to drawing. The active
scene will be used.
>>> visualize([['*','*',1],['*',1,1],['*',1,1]], [[0,0,1],[0,1,1],[0,0,1]])
"""
from visual import box, display
blue = (0, 0, 1)
gray = (.5, .5, .5)
black = (0.3, 0.3, 0.3)
size = len(input_grid)
total_size = size * size
disp = display.get_selected() # gets the active display
if disp is None: # no display, so create one
display(title="Percolation", autocenter=True)
else: # display exists, empty it
disp.autocenter = True # autocenter for convenience
# We only need to delete these boxes if there is a mismatch in the
# number of boxes versus the number of grid cells. We assume that no
# other objects are on the scene.
if total_size != len(disp.objects):
for object in disp.objects:
object.visible = False # make all objects in display invisible
# redraw all of the grid, because of the size mismatch
if total_size != len(disp.objects):
for row in range(size):
for col in range(size):
# for blocked spaces, draw a gray box
if input_grid[row][col]==1:
box(pos=(col, -row, 0), color=gray)
# for spaces with flow, draw a blue box
elif flow_grid[row][col]!=-1:
box(pos=(col, -row, 0), color=blue)
else:
box(pos=(col, -row, 0), color=black)
# or just change the colors, based on the grids given
else:
for object in disp.objects:
x, y, _ = object.pos
x, y = int(x), int(y)
if flow_grid[-y][x] != -1:
object.color = blue
elif input_grid[-y][x] == 1:
object.color = gray
else:
object.color = black
示例5: __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
示例6: main
def main():
scene = visual.display(width=settings.SCENE_WIDTH, height=settings.SCENE_HEIGHT)
ground = visual.box(axis=(0, 1, 0), pos=(0, 0, 0), length=0.1, height=500, width=500, color=visual.color.gray(0.75), opacity=0.5)
def addGait(gaitClass, gaitName):
gait = gaitClass(gaitName, settings.GAIT_LEGS_GROUPS[gaitName], settings.GAIT_PARAMS[gaitName])
GaitManager().add(gait)
addGait(GaitTripod, "tripod")
addGait(GaitTetrapod, "tetrapod")
addGait(GaitRiple, "riple")
addGait(GaitWave, "metachronal")
addGait(GaitWave, "wave")
GaitManager().select("riple")
robot = Hexapod3D()
remote = Gamepad(robot)
GaitSequencer().start()
remote.start()
robot.setBodyPosition(z=30)
robot.mainLoop()
remote.stop()
remote.join()
GaitSequencer().stop()
GaitSequencer().join()
示例7: setup_scene
def setup_scene(fullscreen):
'''
Sets up the scene for the display output.
'''
# Set title and background color (white)
scene = visual.display(title="Robot Simulation",background=(1,1,1))
# Automatically center
scene.autocenter = True
# Removing autoscale
scene.autoscale = 0
# Set whether the windows will take up entire screen or not
scene.fullscreen = fullscreen
# Size of the windows seen is the size of one beam (to begin)
scene.range = (BEAM['length'],BEAM['length'],BEAM['length'])
# The center of the windows exists at the construction location
scene.center = helpers.scale(.5,helpers.sum_vectors(
CONSTRUCTION['corner'],scene.range))
# Vector from which the camera start
scene.forward = (1,0,0)
# Define up (used for lighting)
scene.up = (0,0,1)
# Defines whether or not we exit the program when we exit the screen
# visualization
scene.exit = False
return scene
示例8: PlotSpheres3
def PlotSpheres3(f):
data = json.loads(open(f, "r").read())
scene = vs.display(title='3D representation',
x=0, y=0, width=1920, height=1080,
autocenter=True,background=(0,0,0))
vs.box(pos=(
(data["SystemSize"][1][0]+data["SystemSize"][0][0])*0.5,
(data["SystemSize"][1][1]+data["SystemSize"][0][1])*0.5,
(data["SystemSize"][1][2]+data["SystemSize"][0][2])*0.5
),
length=data["SystemSize"][1][0]-data["SystemSize"][0][0],
height=data["SystemSize"][1][1]-data["SystemSize"][0][1],
width= data["SystemSize"][1][2]-data["SystemSize"][0][2],
opacity=0.2,
color=vs.color.red)
spheres = [vs.sphere(radius=data["SphereSize"],pos=(data["Data"][0][i], data["Data"][1][i], data["Data"][2][i])) for i in range(data["SpheresNumber"])]
vs.arrow(pos=data["SystemSize"][0], axis=(1,0,0), shaftwidth=0.1, color=vs.color.red)
vs.arrow(pos=data["SystemSize"][0], axis=(0,1,0), shaftwidth=0.1, color=vs.color.green)
vs.arrow(pos=data["SystemSize"][0], axis=(0,0,1), shaftwidth=0.1, color=vs.color.blue)
while True:
vs.rate(60)
示例9: PlotSphereEvolution3
def PlotSphereEvolution3(f):
data = json.loads(open(f, "r").read())
center = (
(data["SystemSize"][1][0]+data["SystemSize"][0][0])*0.5,
(data["SystemSize"][1][1]+data["SystemSize"][0][1])*0.5,
(data["SystemSize"][1][2]+data["SystemSize"][0][2])*0.5
)
scene = vs.display(title='3D representation',
x=0, y=0, width=1920, height=1080,
center=center,background=(0,0,0)
)
vs.box(pos=center,
length=data["SystemSize"][1][0]-data["SystemSize"][0][0],
height=data["SystemSize"][1][1]-data["SystemSize"][0][1],
width= data["SystemSize"][1][2]-data["SystemSize"][0][2],
opacity=0.2,
color=vs.color.red)
spheres = [vs.sphere(radius=data["SphereSize"],pos=(data["Data"][0][0][i], data["Data"][1][0][i], data["Data"][2][0][i])) for i in range(data["SpheresNumber"])]
nt = 0
while True:
vs.rate(60)
for i in range(data["SpheresNumber"]):
spheres[i].pos = (data["Data"][0][nt][i], data["Data"][1][nt][i], data["Data"][2][nt][i])
if nt + 1 >= data["SavedSteps"]:
nt = 0
else:
nt += 1
示例10: 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))
示例11: __init__
def __init__(self):
ode.World.__init__(self)
self._myScene = visual.display()
# A joint group for the contact joints that are generated whenever
# two bodies collide
self._contactGroup = ode.JointGroup()
示例12: __init__
def __init__(self, background=None, ambient=None, show_axis=True):
super(Visualiser, self).__init__()
if not VISUAL_INSTALLED:
return
if background is None:
background = (0.957, 0.957, 1)
if ambient is None:
ambient = 0.5
self.display = visual.display(title='PVTrace', x=0, y=0, width=800, height=600, background=background,
ambient=ambient)
self.display.bind('keydown', self.keyInput)
self.display.exit = False
self.display.center = (0.025, 0.015, 0)
self.display.forward = (0, 0.83205, -0.5547)
show_axis = False
if show_axis:
visual.curve(pos=[(0, 0, 0), (.08, 0, 0)], radius=0.0005, color=visual.color.red)
visual.curve(pos=[(0, 0, 0), (0, .07, 0)], radius=0.0005, color=visual.color.green)
visual.curve(pos=[(0, 0, 0), (0, 0, .08)], radius=0.0005, color=visual.color.blue)
visual.label(pos=(.09, 0, 0), text='X', background=visual.color.red, linecolor=visual.color.red)
visual.label(pos=(0, .08, 0), text='Y', background=visual.color.green, linecolor=visual.color.green)
visual.label(pos=(0, 0, .07), text='Z', background=visual.color.blue, linecolor=visual.color.blue)
示例13: __init__
def __init__(self, room_=1, beam_axis_=0, target_pos_=(0,0,0)):
self.labScene = visual.display(title="7Be(d,n)8B Experiment", width=800, height=600, background=GetRGBcode(153,204,255))
axisx = visual.box(pos=(0,0,0), axis=(10.0,0,0), width=0.05, height=0.05, color=visual.color.red)
axisy = visual.box(pos=(0,0,0), axis=(0,10.0,0), width=0.05, height=0.05, color=visual.color.blue)
axisz = visual.box(pos=(0,0,0), axis=(0,0,10.0), width=0.05, height=0.05, color=visual.color.green)
labelx = visual.label(pos=(5.0,0,0), text="Z-Axis")
labely = visual.label(pos=(0,5.0,0), text="Y-Axis")
labelz = visual.label(pos=(0,0,5.0), text="X-Axis")
self.labScene.center = target_pos_
self.labScene.autoscale = False
self.room = room_
self.beam_axis = beam_axis_
self.target_pos = target_pos_
self.Floors = []
self.Walls = []
self.Columns = []
self.Others = []
self.BuildRoom()
if(self.room == 1 or self.room == 2):
chamber_radius = 0.25
self.Beamline1 = visual.cylinder(pos=Translate(self.target_pos,GetCartesianCoords(chamber_radius, math.pi/2.0, DegToRad(180+self.beam_axis))), axis=ConvIM3(71.75,0,-71.75*math.tan(DegToRad(180-self.beam_axis))), radius=ConvIM(1.75), color=visual.color.blue) # East beamline
self.Beamline2 = visual.cylinder(pos=Translate(self.target_pos,GetCartesianCoords(chamber_radius, math.pi/2.0, DegToRad(self.beam_axis))), axis=ConvIM3(-217.5,0,217.5*math.tan(DegToRad(180-self.beam_axis))), radius=ConvIM(1.75), color=visual.color.blue) # West beamline
self.OneMeterChamber = visual.cylinder(pos=self.target_pos, axis=(0,chamber_radius*2,0), radius=chamber_radius, color=visual.color.blue)
self.OneMeterChamber.pos[1] = -0.5
示例14: __init__
def __init__( self, NCellsPerDimension, Length, E0 ):
self.n = NCellsPerDimension
self.L = Length
self.V = self.L**3
self.N = 4 * self.n**3
self.a = self.L / self.n
self.E0 = E0
self.E = E0
self.U = 0
self.dU = 0
self.ddU = 0
self.particles = []
self.index = 0
self.dt = 1e-2
self.dt_2 = self.dt * 0.5
self.dt2_2 = self.dt * self.dt_2
self.scene = visual.display( title = 'System',
x=800, y=0,
width=800, height=800,
center = visual.vector(0.5,0.5,0.5) * self.L,
autoscale = False,
range = 1.5 * self.L)
self.box = visual.box( pos = visual.vector(0.5,0.5,0.5) * self.L,
length = self.L,
height = self.L,
width = self.L,
color = visual.color.green,
opacity = 0.2 )
示例15: __init__
def __init__(self):
win = vs.window(width=1024, height=720, menus=False, title='SIMULATE VPYTHON GUI')# make a main window. Also sets w.panel to addr of wx window object.
scene = vs.display( window=win, width=800, height=720, forward=-vs.vector(1,1,2))# make a 3D panel
vss = scene
p = win.panel
sphere_button = wx.Button(p, label='Sphere', pos=(810,10), size=(190,100))
#sphere_button.Bind(wx.EVT_BUTTON, self.options())
cube_button = wx.Button(p, label='Cube', pos=(810,120), size=(190,100))