0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Blenderで4次元データの可視化

Last updated at Posted at 2022-03-17

やること

4次元データのグラフをBlenderで作成してみましょう。
4軸目は、球のサイズにします。

やってみる

データはダミーで作ります。

import bpy
import numpy as np


def draw(data, scale=0.02):
    mn = data.min()
    mx = data.max()
    data[:, :3] = (data[:, :3] - mn) / (mx - mn) * 2
    for x, y, z, s in data:
        bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=3, radius=s * scale, location=(x, y, z))
    bpy.ops.object.select_all(action='SELECT')
    bpy.ops.object.shade_smooth()
    bpy.ops.mesh.primitive_cylinder_add(vertices=4, radius=0.02, location=(1, 0, 0), rotation=(0, 1.5708, 0))
    bpy.ops.mesh.primitive_cylinder_add(vertices=4, radius=0.02, location=(0, 1, 0), rotation=(1.5708, 0, 0))
    bpy.ops.mesh.primitive_cylinder_add(vertices=4, radius=0.02, location=(0, 0, 1))
    bpy.ops.object.select_all(action='DESELECT')

# 今回は乱数で生成するが、np.loadtxtでCSVから読んでもよい
data = np.random.default_rng(0).uniform(0, 100, (20, 4))
data[:, 3] = data[:, 3] // 10 + 1

draw(data)

実行結果

参考:BlenderでPythonを実行する方法

以上

0
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?