Bestimmte Elemente aus einem ndarray abspeichern.
Verfasst: Dienstag 26. Januar 2021, 10:02
Hallo meine Lieben.
Zunächst der Code:
Die Strahlen treffen die Triangles, die in index_tri gespeichert werden. Ich habe des Weiteren alle Triangles unter mesh.triangles. Wie kann ich jetzt nur auf die Triangles in mesh.triangles zugreifen, die in index_tri abgespeichert wurden?
Vielen Dank schonmal für eure Hilfe.
Zunächst der Code:
Code: Alles auswählen
import trimesh
import numpy as np
mesh = trimesh.creation.icosphere()
ray_origins = np.array([[0, 0, -3],
[2, 2, -3]])
ray_directions = np.array([[0, 0, 1],
[0, 0, 1]])
print(mesh.ray.intersects_location.__doc__)
locations, index_ray, index_tri = mesh.ray.intersects_location(
ray_origins = ray_origins,
ray_directions = ray_directions)
print('Strahl trifft Kugel bei folgenden Koordinaten:\n', locations)
print('Folgende Strahlen: {} treffen die Oberflächen gespeichert in mesh.faces[{}]'.format(index_ray, index_tri))
ray_visualize = trimesh.load_path(np.hstack((ray_origins,
ray_origins + ray_directions*10.0)).reshape(-1, 2, 3))
mesh.unmerge_vertices()
mesh.visual.face_colors = [255,255,255,255]
mesh.visual.face_colors[index_tri] = [255, 0, 0, 255]
scene = trimesh.Scene([mesh,
ray_visualize])
scene.show()
Vielen Dank schonmal für eure Hilfe.