def start(self, route=[], v=10):
r = route
self.TopSpeed = v
self.Route = r
# Calculating position and velocity vector according to route points
if len(route) > 1:
self.CurrentRoute += 1
self.Position = Vector3(r[0]['X'], r[0]['Y'], self.Position.Z)
ddash = math.hypot(self.Position.X-r[1]['X'], self.Position.Y-r[1]['Y'])
self.Velocity = Vector3((v/ddash) * (r[1]['X']-self.Position.X), (v/ddash) * (r[1]['Y']-self.Position.Y), 0)
else:
self.Position = Vector3(0, 0, self.Position.Z)
self.Velocity = Vector3(0, 0, 0)
评论列表
文章目录