Stunti
Stunti

Reputation: 11

Trimesh: find an intersection between ray and mesh only on the length of the ray and not in its extension

I'm looking for a way to find the intersection between a path of vectors and a trimesh. I have built my code following these two posts: Python: Fastest ray to mesh intersection? Intersection between 2d image point and 3d mesh I did not have any speed problems. 3.5 million ray intersections are calculated within a few seconds.

In doing so, I ran into the following problem: As a result I get the intersection independent of the length of the direction vector. So the ray tracing kernel searches for intersections along the vector r * x. But it is important for me to know if the intersection really occurs only within the actual length of the vector ( r * 1 ).

One possibility would be to use the function ray.intersects_location() to search for the intersection and then check if the intersections location is really on my vector or just on an extension of it.

However, I consider this to be overkill. I don't want to know the intersection at all. Actually the information about intersection or no intersection is enough for me (using ray.intersection_any() for this).

Is there a way to implement this with trimesh (or a trimesh compatible library)? Or do I have to calculate the location and check if the intersection is on the vector itself?

Googled for the problem and read a whole while in the trimesh wiki. Found nothing relevant.

Upvotes: 1

Views: 1568

Answers (0)

Related Questions