在pygame中制作平滑轨道 [英] Making smooth orbits in pygame

查看:139
本文介绍了在pygame中制作平滑轨道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用pygame以恒定的速度制作平滑的圆形轨道? 我将如何计算圆上的x,y?

How can i make a smooth circular orbit at a constant speed using pygame? How would i calculate x, y on a circle?

推荐答案

以给定的半径和速度绕2d点center旋转. 参数t是时间,以秒为单位.

Rotating about the 2d point center with the given radius and speed. The parameter t is the time in units of seconds.

def circular_orbit(center, radius, speed, t):
    theta = math.fmod(t * speed, math.PI * 2)
    c = math.cos(theta)
    s = math.sin(theta)
    return center[0] + radius * c, center[1] + radius * s

这篇关于在pygame中制作平滑轨道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆