LoginSignup
0
0

More than 5 years have passed since last update.

Shadeスクリプト(Python)で、メビウスの輪を作る

Last updated at Posted at 2019-02-12

Shadeスクリプト(Python)で、メビウスの輪を作る

script.py
import math
scene = xshade.scene()
scene.begin_creating()

r = 10

for n in range(0,360,3):

    for rr in [-1.5,-1.2, -0.9, -0.6, -0.3, 0.0, 0.3, 0.6, 0.9, 1.2,1.5]:
        nn = n / 2
        x1 = (r) * math.cos(n * math.pi/180)
        y1 = (r) * math.sin(n * math.pi/180)
        x2 = x1 + (rr) * math.sin(nn * math.pi/180) * math.cos(n * math.pi/180) 
        y2 = y1 + (rr) * math.sin(nn * math.pi/180) * math.sin(n * math.pi/180)
        z2 =      (rr) * math.cos(nn * math.pi/180)
        scene.create_sphere(None,(x2, y2, z2),0.6)

scene.end_creating()

スクリーンショット 2019-02-12 21.50.25.png

For文の中の

hineri.py
nn = n / 2

を修正すると、ひねり回数などが変わる

hineri.py
nn = n 


1.png

hineri.py
nn = n * 6


2.png

hineri.py
nn = n * 2


3.png

hineri.py
nn = n * 2.5


4.png

hineri.py
nn = n * math.cos(n * math.pi/180)


5.png

hineri.py
for n in range(0,360,1):
~~
nn = n * 17


a.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0