本文整理汇总了Python中vector.Vector.distanceSqr方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.distanceSqr方法的具体用法?Python Vector.distanceSqr怎么用?Python Vector.distanceSqr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector.Vector
的用法示例。
在下文中一共展示了Vector.distanceSqr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: removeAt
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import distanceSqr [as 别名]
def removeAt(self, pos):
for blob in self.blobs:
dist = Vector.distanceSqr(blob.pos, pos)
print dist, blob.radius ** 2
if dist < blob.radius ** 2:
self.blobs.remove(blob)
self.blobDict.pop(blob.id, None)
break
示例2: findCloseBlobs
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import distanceSqr [as 别名]
def findCloseBlobs(self, blob, radius):
result = []
radiusSqr = radius * radius
for otherBlob in self.blobs:
if otherBlob.id == blob.id:
continue
if Vector.distanceSqr(blob.pos, otherBlob.pos) < radiusSqr:
result.append(otherBlob)
return result
示例3: validate
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import distanceSqr [as 别名]
def validate(self, blob, debug=False):
result = True
pos = blob.pos
if self.isSet(pos):
if debug:
print "isset fail"
result = False
else:
radius = blob.radius
sqrRadius = radius**2
for x in range(-radius, radius):
for y in range(-radius, radius):
if x*x + y*y <= sqrRadius:
cPos = pos + [x, y]
if self.isSet(cPos):
if debug:
print "wall collision fail"
result = False
break
if not result:
break
for otherBlob in self.blobs:
if otherBlob.id == blob.id:
continue
distance = Vector.distanceSqr(otherBlob.pos, blob.pos)
if distance < (otherBlob.radius + blob.radius) ** 2:
if debug:
print "blob collision fail"
result = False
break
return result