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.