本文整理汇总了Python中Vector.Vector.average方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.average方法的具体用法?Python Vector.average怎么用?Python Vector.average使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector.Vector
的用法示例。
在下文中一共展示了Vector.average方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rule1
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import average [as 别名]
def rule1(self, this_boid, boids, flock):
for boid in boids:
if boid is not this_boid and (boid.pos - this_boid.pos).magnitude() < 70:
flock.append(boid)
if len(flock) > 0:
avg = Vector.average([boid.pos for boid in flock])
return (avg - this_boid.pos)*(50.0/100.0)
return Vector(0, 0)
示例2: rule1
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import average [as 别名]
def rule1(self, hoik, boids, flock):
for boid in boids:
if (boid.pos - hoik.pos).magnitude() < 200:
flock.append(boid)
if len(flock) == 0:
for boid in boids:
if (boid.pos - hoik.pos).magnitude() < 400:
flock.append(boid)
if len(flock) > 0:
avg = Vector.average([boid.pos for boid in flock])
return (avg - hoik.pos)*(50.0/100.0)
return Vector(0, 0)
示例3: rule3
# 需要导入模块: from Vector import Vector [as 别名]
# 或者: from Vector.Vector import average [as 别名]
def rule3(self, this_boid, flock):
avg = Vector.average([boid.dir for boid in flock])
return avg - this_boid.dir * (1.0/8.0)