我正试着从维基百科上做这个animation,但是,我很难弄清楚怎么做。基本上我需要做两件事:
这是我的代码,但是我有十个不同的帧
import numpy as np
import matplotlib.pyplot as plt
R=3 #Biggest circle radius =3
r=1 #smallest circle radius =1
t=np.linspace(0, 2*np.pi,100) # values from zero to 360 degrees
i=0
xc1=R*np.cos(t) #biggest circle
yc1=R*np.sin(t) #biggest circle
plt.plot(xc1,yc1)
while i<=2*np.pi:
x=(R-r)*np.cos(i)+r*np.cos((R-r)*i/r) #x values of the hypocycloid
y=(R-r)*np.sin(i)-r*np.sin((R-r)*i/r)#y value of the hypocycloid
plt.plot(x,y)
i+=2*np.pi/10
plt.show()
事先非常感谢。在
这里有一个完整的例子,使用OP链接的Wikipedia页面中给出的公式。由于有很多变量需要跟踪,所以我认为最好是在一个类中收集所有的变量。在
可以传递给
Hypocycloid
类的参数是ratio
(小圆相对于大圆的半径)、frames
(小圆绕大圆一次行程的帧数)和ncycles
(行程数)。ratio=3.25
、frames=40
和ncycles=4
的最终结果如下:相关问题 更多 >
编程相关推荐