本文整理汇总了Python中Point.Point.distanceTowardPoint方法的典型用法代码示例。如果您正苦于以下问题:Python Point.distanceTowardPoint方法的具体用法?Python Point.distanceTowardPoint怎么用?Python Point.distanceTowardPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point.Point
的用法示例。
在下文中一共展示了Point.distanceTowardPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Point
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import distanceTowardPoint [as 别名]
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,
(math.atan2(isect.y-danger.c.y,isect.x-danger.c.x)) -
0#(loci_param[-1][1] if len(loci_param)>0 else 0)
])
except: