Search code examples
trimesh

Generate mesh and ray intersection for trimesh


I am using trimesh to generate ray intersection from points.

ray_origins = np.array([[0, 0, 2], 
                        [1, 1, 3], 
                        [3, 2, 6]])
ray_directions = np.array([[0, 5, 8], 
                           [0, 0, 1], 
                           [0, 2, 2]])
locations, index_ray, index_tri = mesh.ray.intersects_location( ray_origins=ray_origins, 
                                                                ray_directions=ray_directions)

I want to know if there is anyway I can generate many rays from each point and cast them to the mesh?


Solution

  • You could try "sample_surface_sphere", which will randomly pick number (vector) from a sphere. 

    nPoints = 100000
    ray_directions = trimesh.sample.sample_surface_sphere(nPoints)