タイトルの通り、vtk(python)で均等に分散した球体を作りたい
最初に、均等に分散された球を作成する方法であるこのリンク「球上に n 点を均等に分散する」を見ました。そのリンクを介して、均等に分散された球の x、y、z 座標を取得しました。
第二に、それは実際には私が解決しなければならない問題ではありません。問題は、均等に分散された球の x、y、z 座標を持っているにもかかわらず、vtk(python) で polydata を作成できないことです。
import numpy as np
import mpl_toolkits.mplot3d
import matplotlib.pyplot as plt
import vtk
from scipy.spatial import Delaunay
num_pts = 1000
indices = np.arange(0, num_pts, dtype=float) + 0.5
phi = np.arccos(1 - 2*indices/num_pts)
theta = np.pi * (1 + 5**0.5) * indices
x, y, z = np.cos(theta) * np.sin(phi), np.sin(theta) * np.sin(phi), np.cos(phi);
# x,y,z is coordination of evenly distributed shpere
# I will try to make poly data use this x,y,z
points = vtk.vtkPoints()
for i in range(len(x)):
array_point = np.array([x[i], y[i], z[i]] )
points.InsertNextPoint(x[i],y[i],z[i])
# tri = Delaunay(points) (Do I have to use this function??)
poly = vtk.vtkPolyData()
poly.SetPoints(points)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(poly)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
ren = vtk.vtkRenderer()
ren.AddActor(actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
renWin.Render()
iren.Start()
コードはエラーをスローしませんが、vtk ウィンドウに polydata が表示されませんでした。この問題を解決するにはどうすればよいですか?
-テヨン。