本文整理汇总了Python中Vector.get方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.get方法的具体用法?Python Vector.get怎么用?Python Vector.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Drone
# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import get [as 别名]
class Drone():
def __init__(self, dt):
self.dt = dt
self.rotorspeed = Vector(0.0, 0.0)
self.pos = Vector(0,0)
self.speed = Vector(0.0,0.0)
self.acc = Vector(0.0, 0.0)
self.posPrev = Vector(0.0, 0.0)
self.speedPrev = Vector(0.0, 0.0)
self.control = None
def setRotorSpeed(self, value):
if value.coords[0] < -30:
self.rotorspeed.coords[0] = -30
elif value.coords[0] > 30:
self.rotorspeed.coords[0] = 30
else:
self.rotorspeed.coords[0] = value.coords[0]
if value.coords[1] < 0:
self.rotorspeed.coords[1] = 0
elif value.coords[1] > 30:
self.rotorspeed.coords[1] = 30
else:
self.rotorspeed.coords[1] = value.coords[1]
def setControl(self, control):
self.control = control
def refreshPos(self):
newpos = self.calc()
self.posPrev = self.pos
self.pos = newpos
#not here
self.speedPrev = self.speed
self.speed = (self.pos - self.posPrev)/self.dt
self.acc = (self.speed - self.speedPrev) / self.dt
def calc(self):
if self.pos.get() == (0,0) and self.rotorspeed.get() == (0,0):
return self.pos
else:
m = 1.0
g = 10.0
dt = self.dt #???
"""
m*ddx = F
"""
Fall = self.rotorspeed + Vector(0, -m*g)
newpos = Fall * dt**2 / m + self.pos * 2 - self.posPrev
if newpos.coords[1] < 0:
self.speed.set(0,0)
return Vector(newpos.coords[0], 0)
elif newpos.coords[0] < 0:
self.speed.set(0,0)
return Vector(0, newpos.coords[1])
elif newpos.coords[1] > 500:
self.speed.set(0,0)
return Vector(newpos.coords[0], 500)
elif newpos.coords[0] > 1000:
self.speed.set(0,0)
return Vector(1000, newpos.coords[1])
else:
return newpos
示例2: Tk
# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import get [as 别名]
plotShift += 1
# GUI
root = Tk()
draw_button = Button(root, text="Plot!", command = main)
draw_button.grid(row=0, column=0)
# init figure
fig = plt.figure()
canvas = Tk.Canvas(fig, master=root)
canvas.get_tk_widget().grid(row=0,column=1)
root.mainloop()"""
from Vector import *
a = Vector(2,1,2)
b = Vector(3,2,3)
c = a + b
print a.get()
print "b"
print b.get()
print "c"
print c.get()