ich habe in "locations" die Koordinaten gespeichert, wo die Rays die erste Oberfläche treffen.
Der Richtungsvektor von locations[0] ist ray_directions[index_ray[0]]. (glaub ich)
Wie kann ich nun zu jeder Koordinate in locations eine zufällige Streuung IN RICHTUNG DES RICHTUNGSVEKTORS zwischen z.B. -5 und +5mm hinzufügen?
Vielen Dank vorab für eure Hilfe.
Hier der Code:
Code: Alles auswählen
import pywavefront
import trimesh
import numpy as np
scene = pywavefront.Wavefront('Modell_asbuilt.obj', collect_faces=True)
print(scene.vertices)
for mesh in scene.mesh_list:
print(mesh.faces)
mesh = trimesh.Trimesh(scene.vertices, mesh.faces)
ray_origins = np.tile(np.array([2.0,6.5,1.5]), (65000,1))
ray_directions = np.random.uniform(-1, 1, (65000,3))
print(mesh.ray.intersects_location.__doc__)
print(ray_directions)
locations, index_ray, index_tri = mesh.ray.intersects_location(
ray_origins = ray_origins, ray_directions = ray_directions, multiple_hits=False)
print('Strahl trifft Mesh bei folgender Koordinate:\n', locations)
ray_visualize = trimesh.load_path(np.hstack((ray_origins,
ray_origins + ray_directions*5.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()