本文整理汇总了Python中world.World.rotate方法的典型用法代码示例。如果您正苦于以下问题:Python World.rotate方法的具体用法?Python World.rotate怎么用?Python World.rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类world.World
的用法示例。
在下文中一共展示了World.rotate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import rotate [as 别名]
class MainWindow(window.Window):
def __init__(self, *args, **kwargs):
#Let all of the standard stuff pass through
window.Window.__init__(self, *args, **kwargs)
self.initGL()
self.bird = Bird()
self.world = World()
self.enemy = Enemy()
def initGL(self):
glClearColor(0.0, 0.0, 0.0, 0.0) # This Will Clear The Background Color To Black
glClearDepth(1.0) # Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS) # The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST) # Enables Depth Testing
glShadeModel(GL_SMOOTH) # Enables Smooth Color Shading
glEnable(GL_TEXTURE_2D) # Enable Texture Mapping
glShadeModel(GL_SMOOTH) # Enable Smooth Shading
glClearColor(0.0, 0.0, 0.0, 0.5) # Black Background
glClearDepth(1.0) # Depth Buffer Setup
glEnable(GL_DEPTH_TEST) # Enables Depth Testing
glDepthFunc(GL_LEQUAL) # The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) # Really Nice Perspective Calculations
glLightfv(GL_LIGHT1, GL_AMBIENT, vec(*LightAmbient))
glLightfv(GL_LIGHT1, GL_DIFFUSE, vec(*LightDiffuse))
glLightfv(GL_LIGHT1, GL_POSITION, vec(*LightPosition))
glEnable(GL_LIGHT1)
glColor4f(1.0,1.0,1.0,0.5)
glBlendFunc(GL_SRC_ALPHA,GL_ONE)
def rotate_world(self):
# know bird.roty is off of (1,0)
ref_angle = self.bird.roty
point1=0
if (ref_angle >= 0 and ref_angle<=90):
point1 = math.atan(ref_angle * math.pi/180.0)
elif (ref_angle >= 90 and ref_angle<=180):
point1 = math.atan((180-ref_angle) * math.pi/180.0)
elif (ref_angle >= 180 and ref_angle<=270):
point1 = -math.atan((ref_angle-180) * math.pi/180.0)
else:
point1 = math.atan((ref_angle) * math.pi/180.0)
point2=0
if (ref_angle >= 0 and ref_angle<=90):
point2 = math.atan((90-ref_angle) * math.pi/180.0)
elif (ref_angle >= 90 and ref_angle<=180):
point2 = math.atan((90.0-ref_angle) * math.pi/180.0)
elif (ref_angle >= 180 and ref_angle<=270):
point2 = math.atan((ref_angle-270) * math.pi/180.0)
else:
# between -90 and 0
point2 = math.atan((ref_angle+90) * math.pi/180.0)
self.world.rotate(1, point2, -point1)
def animate_bird(self, interval):
self.bird.flap()
self.rotate_world()
self.enemy.move(45)
def update(self):
pass
def draw(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glPushMatrix()
self.world.draw()
glPopMatrix()
glPushMatrix()
self.bird.draw()
glPopMatrix()
glPushMatrix()
self.enemy.draw()
glPopMatrix()
def main_loop(self):
clock.set_fps_limit(30)
clock.schedule_interval(self.animate_bird, 0.01)
while not self.has_exit:
self.dispatch_events()
self.clear()
self.update()
self.draw()
#Tick the clock
clock.tick()
self.flip()
#.........这里部分代码省略.........
示例2: World
# 需要导入模块: from world import World [as 别名]
# 或者: from world.World import rotate [as 别名]
fieldSizeX2 = 100 + fieldSizeX1
fieldSizeY1 = 0
fieldSizeY2 = 100 + fieldSizeY1
#shape to assemble
shapeX = np.array([0, 20, 20, 10, 10, 0, 0])
shapeY = np.array([0, 0, 10, 10, 20, 20, 0])
shapeOffsetX = 0
shapeOffsetY = 0
scaleX = 1
scaleY = 1
world = World(bitmap, swarmSize, shapeWidth, robotRadius, sensorRadius, velocity, ang_velocity, tick)
fasePos = world.rotate(0.75*robotRadius)
'''
for i in xrange(100):
world.updateWorld()
'''
startPos = list(zip(world.positions[0,:], world.positions[1,:]))
startPosFace = list(zip(world.positions[0,:] + fasePos[0,:], world.positions[1,:] + fasePos[1,:]))
fig = plt.figure(figsize=(8, 8))
ax = fig.add_axes([0, 0, 1, 1], frameon=False)
ax.set_xlim(fieldSizeX1, fieldSizeX2), ax.set_xticks([])
ax.set_ylim(fieldSizeY1, fieldSizeY2), ax.set_yticks([])
plt.gca().set_aspect('equal', adjustable='box')
grad_vals = map(lambda x: -1 if x== float('inf') else int(floor(x)), world.gradients)