本文整理汇总了Python中Point.Point.distanceTo方法的典型用法代码示例。如果您正苦于以下问题:Python Point.distanceTo方法的具体用法?Python Point.distanceTo怎么用?Python Point.distanceTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point.Point
的用法示例。
在下文中一共展示了Point.distanceTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testDistanceTo
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import distanceTo [as 别名]
def testDistanceTo(self):
p = Point(3,4)
q = Point(4,5)
self.assertEquals(p.distanceTo(q), q.distanceTo(p))
self.assertEquals(p.distanceTo(q), math.sqrt(2))
self.assertEquals(p.distanceTo(self.p0), 5.0)
示例2: getVelocity
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import distanceTo [as 别名]
def getVelocity(self, at):
#Get the location of the sphero
spheroPoint = Point(at.x, at.y)
#Get the vector towards the goal.
#path should be set by set by the pathfinder?
if spheroPoint.distanceTo(self.path[self.current]) < SIZE_OF_GRID:
if self.current >= len(self.path) - 1:
self.current = 0
else:
self.current += 1
dest = self.path[self.current]
x = y = 0
up = Point(dest.x, dest.y - 1)
left = Point(dest.x - 1, dest.y)
down = Point(dest.x, dest.y + 1)
right = Point(dest.x + 1, dest.y)
poly = [up, left, down, right]
wayPoint = AttractiveField(-1, 80, 1, poly)
tmpPoint = wayPoint.getVect(spheroPoint).getPoint()
x += tmpPoint.x
y += tmpPoint.y
#print "fields: " + str(self.fields)
for field in self.fields:
if type(field) is AttractiveField and field.inCircle(spheroPoint):
return Point(0, 0)
tmpPoint = field.getVect(spheroPoint).getPoint()
print "vector" + str(field.id) + "=" + str(tmpPoint)
x += tmpPoint.x
y += tmpPoint.y
point = Point(x, y)
#print "velocity= " + str(point)
return point