あなたがタイトルに見ることができるように、私はVTKで均等に分散球(のpython)を作りたい私はVTKで均等に分散球(のpython)を作りたい
まず、私は、このリンクである「Evenly distributing n points on a sphere」を見ましたメソッドを使用して、均等に分布した球を作成します。そのリンクを通して、私は、均等に分布した球のx、y、z座標を得ました。
第二に、それは私が解決しなければならない問題ではありません。問題は、私は、X、Y、均一に分布球のZ座標を有するにもかかわらず、私はVTK(パイソン)で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()
コードエラーをスローするが、polydataありません この問題を解決するにはどうすればよいですか?
-テーヤング。
PolyDataを書き込むコードを少なくとも提供できますか?それはあなたの任務です。あなたがどこにいるか教えてくれれば、私たちはあなたを助けることができます。しかし、私たちの完全な解決策を期待するのは公正ではありません。 –
申し訳ありませんが、質問をする私の初めての質問です、私の質問を編集する詳細を含めると、 –