Guest User

mine-hack radius function

a guest
Aug 14th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. def calculate_radius(point1, point2):
  2.   # print "Calculating distance between points:"
  3.   # print point1
  4.   # print point2
  5.   if point1 is None:
  6.     return 10
  7.   p1 = np.array(point1["location"])
  8.   p2 = np.array(point2["location"])
  9.   dist = np.linalg.norm(p1 - p2)
  10.   time_delta = point2["time"] - point1["time"]
  11.   # print "dist: %f" % dist
  12.   # print "time delta: %i" % time_delta
  13.   blocks_per_second = (dist / time_delta) * 1000
  14.   # print "blocks per second: %f" % blocks_per_second
  15.   return int(round(blocks_per_second))
Add Comment
Please, Sign In to add comment