ball.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:pool 作者: max-kov 项目源码 文件源码
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)) * 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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号