09/07/22 12:17:16
これはおもろいすなぁ。
URLリンク(up2.viploader.net)
こんなブキミな物体(Torus Knot)も簡単に書ける。描画部分を下のように変えます。
pointslist = []
A = 3.0
B = 8.0
drawcount = 1000
for i in range(drawcount):
theta = 2 * math.pi * i * A / drawcount
x = ( 2 + math.cos(B*theta/A))*math.cos(theta) * 20
y = ( 2 + math.cos(B*theta/A))*math.sin(theta) * 20
z = math.sin(B*theta/A) * 20
pointslist.append((x, y, z))
for i, p in enumerate(pointslist):
c_hsv=(i/float(drawcount),1,1)
sphere(pos=p, radius=6, color=color.hsv_to_rgb(c_hsv), opacity=0.7)