本文整理汇总了Python中Point.Point.distance方法的典型用法代码示例。如果您正苦于以下问题:Python Point.distance方法的具体用法?Python Point.distance怎么用?Python Point.distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point.Point
的用法示例。
在下文中一共展示了Point.distance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: coords
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import distance [as 别名]
def coords(p):
return p.x,p.y
if __name__ == '__main__':
tank1 = Point(0,0)
tank2 = Point(500,0) # shooter
# Danger: [Circle C(424.255,742.446), R(628.000)]
b_power = 3
b_speed = 20-3*b_power
t_speed = 8
distance = tank1.distance(tank2)
t_min = int(math.ceil(distance / (t_speed + b_speed)))
t_max = int(math.ceil(distance / abs(b_speed - t_speed)))
d_min = tank2.distanceTowardPoint(tank1,t_min*t_speed)
d_max = tank2.distanceTowardPoint(tank1,-t_max*t_speed)
danger = Circle(d_min.midpoint(d_max),t_speed*(t_min+t_max)/2)
print("Danger: {0}".format(danger));
bad_loci = []
loci_param = []
for t in range(t_min,t_max+1):
try:
for isect in Circle(tank1,b_speed*t).intersect(Circle(tank2,t_speed*t)):
bad_loci.append(coords(isect))
loci_param.append([t,#/t_max,
示例2:
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import distance [as 别名]
from Point import Point
from Rectangle import Rectangle
pointa=Point(10.0,5.0)
pointb=Point(1.0,9.0)
print "the distance of the point "+str(pointa)+" and ther point "+str(pointb)+" is:"+str(pointa.distance(pointb))
rectangle=Rectangle(pointa,pointb)
print rectangle
示例3: print
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import distance [as 别名]
# turn, move
currp = start
turn = 0
while True:
path.append(currp);
print("{0:d},{1:.03f},{2:.03f},{3:.03f}".format(
turn, h, currp.x, currp.y ))
if turn % 2 == 0:
h += turnA
else:
h += turnB
h %= 360
turn += 1
currp = Point( currp.x + 8*math.cos(math.radians(90-h)),
currp.y + 8*math.sin(math.radians(90-h)) )
if currp == start:
break
print("{0:d},{1:.03f},{2:.03f},{3:.03f}".format(
turn, h, currp.x, currp.y ))
x = np.array([ p.x for p in path ])
y = np.array([ p.y for p in path ])
center = Point(np.mean(x),np.mean(y))
radius = np.mean([ center.distance(p) for p in path ])
print("C{0}, r({1:.02f})".format(center,radius))
示例4: main
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import distance [as 别名]
def main():
p1 = Point(1.3, 2.5)
p2 = Point(0.9, 2.8)
print(p1.distance(p2))
return 0