python中怎样在模拟文件中添加更多的小球(小球在圆筒中),已有一个小球,如何添加更多的小球

radius是小球的半径radius_cylinder是圆筒的半径我想让小球沿着圆筒成螺线分布(3D)以下是我写的命令,但是为什么执行的时候还是只有一个小球呢r_min=radius*2.0r_max=radius_cylinder-radiusk=(r_max-r_min)/(2*radius)*2for i in range(nb_sphere): c=r_min+(r_max-r_min)*float(i)/float(nb_sphere) x=c*cos(k*pi * float(i)/float(nb_sphere)) y=c*sin(k*pi * float(i)/float(nb_sphere)) z=0.0 sphere.position = x, y, z
2026年09月16日 21:10
有1个网友回答
网友(1):

我觉得应该是这样吧,用加法,c表示圆心

x=c+cos(k*pi * float(i)/float(nb_sphere))
y=c+sin(k*pi * float(i)/float(nb_sphere))

那么c的变化,导致圆心的变化,半径不变,就能得到很多个半径相同的小球了。

x=c*cos(k*pi * float(i)/float(nb_sphere))
y=c*sin(k*pi * float(i)/float(nb_sphere))

用乘法,结果就是半径变化,圆心不变,得到的是一连串的同心圆。这样看起来还是只有一个球。