Ejemplo n.º 1
0
 def update(self, *args):
     if np.hypot(*self.ball.velocity) != 0:
         perpendicular_velocity = -np.cross(self.ball.velocity, [0, 0, 1])
         rotation_angle = -np.hypot(
             *(self.ball.velocity)) * 2 / (config.ball_radius * np.pi)
         transformation_matrix = physics.rotation_matrix(
             perpendicular_velocity, rotation_angle)
         self.label_offset = np.matmul(
             self.label_offset, transformation_matrix)
         if self.ball_type == BallType.Striped:
             self.ball_stripe.update_stripe(transformation_matrix)
         self.update_sprite()
         self.ball.update()
Ejemplo n.º 2
0
 def update(self, *args):
     if np.hypot(*self.ball.velocity) != 0:
         # updates label circle and number offset
         perpendicular_velocity = -np.cross(self.ball.velocity, [0, 0, 1])
         # angle formula is angle=((ballspeed*2)/(pi*r*2))*2
         rotation_angle = -np.hypot(*(self.ball.velocity)) / config.ball_radius
         transformation_matrix = physics.rotation_matrix(
             perpendicular_velocity, rotation_angle)
         self.label_offset = np.matmul(
             self.label_offset, transformation_matrix)
         if self.ball_type == BallType.Striped:
             self.ball_stripe.update_stripe(transformation_matrix)
         self.update_sprite()
         self.ball.update()