teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

コードの修正

2019/11/07 00:21

投稿

Kapustin
Kapustin

スコア1188

answer CHANGED
@@ -18,7 +18,7 @@
18
18
  scene.create_sphere(None,(x2, y2, z2),0.6)
19
19
  ```
20
20
 
21
- blenderでも同じような機能として `bpy.ops.mesh.primitive_ico_sphere_add` があるので、これを利用して
21
+ blenderでも同じような機能として `bpy.ops.mesh.primitive_uv_sphere_add` があるので、これを利用して
22
22
  ```
23
23
  import bpy
24
24
  import math
@@ -33,6 +33,6 @@
33
33
  x2 = x1 + (rr) * math.sin(nn * math.pi/180) * math.cos(n * math.pi/180)
34
34
  y2 = y1 + (rr) * math.sin(nn * math.pi/180) * math.sin(n * math.pi/180)
35
35
  z2 = (rr) * math.cos(nn * math.pi/180)
36
- bpy.ops.mesh.primitive_ico_sphere_add(location=(x2, y2, z2), size=0.6)
36
+ bpy.ops.mesh.primitive_uv_sphere_add(location=(x2, y2, z2), size=0.6)
37
37
  ```
38
38
  上記のコードでおおよそ同じ結果が得られるかと思います。

1

回答の追記

2019/11/07 00:21

投稿

Kapustin
Kapustin

スコア1188

answer CHANGED
@@ -10,4 +10,29 @@
10
10
  もしそうであれば、最終的に「何を作りたいのか」がもう少しわかると良いです。
11
11
 
12
12
  ※前の質問にも記載しましたが、コードはマークダウン記法で書くと見やすくなります。
13
- ※質問文は編集できるので、削除せず修正してください。
13
+ ※質問文は編集できるので、削除せず修正してください。
14
+
15
+ 【追記】
16
+ 参考サイトでは、メビウスの輪の各サンプリング座標を計算し、最終的に x2, y2, z2 という座標を求めています。その座標に下記の関数で球体オブジェクトを次々に配置している形となります。
17
+ ```
18
+ scene.create_sphere(None,(x2, y2, z2),0.6)
19
+ ```
20
+
21
+ blenderでも同じような機能として `bpy.ops.mesh.primitive_ico_sphere_add` があるので、これを利用して
22
+ ```
23
+ import bpy
24
+ import math
25
+
26
+ r = 10
27
+
28
+ for n in range(0,360,3):
29
+ 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]:
30
+ nn = n / 2
31
+ x1 = (r) * math.cos(n * math.pi/180)
32
+ y1 = (r) * math.sin(n * math.pi/180)
33
+ x2 = x1 + (rr) * math.sin(nn * math.pi/180) * math.cos(n * math.pi/180)
34
+ y2 = y1 + (rr) * math.sin(nn * math.pi/180) * math.sin(n * math.pi/180)
35
+ z2 = (rr) * math.cos(nn * math.pi/180)
36
+ bpy.ops.mesh.primitive_ico_sphere_add(location=(x2, y2, z2), size=0.6)
37
+ ```
38
+ 上記のコードでおおよそ同じ結果が得られるかと思います。