Mesh/Polyline Intersection

Hello!
I’m trying to get the intersection of a Polyline and a Mesh. Is there a function which is doing this? I looked for it in compas and also in compas_cgal but I didn’t find one. I just found the intersection_ray_mesh and the intersection_polyline_plane functions.
Is it alternatively possible to transfer the polyline into another type (for example a Mesh, …) which may be used to calculate the intersection?
Or is there a funtion to check whether a point (which is not necessarily a vertex of the mesh) lays on or closed to a mesh? If there would be such a is_point_on_mesh function, I could at least check which points are laying on the mesh.

Thanks a lot :slight_smile:
Jerome

hi,

thanks for posting!

there is indeed no such function. but a few solutions should be available with a minimum of additional coding. for example, with intersection_ray_mesh you could compute the intersections between the different “rays” of you polyline segments, and if there is one, check if that intersection lies on the actual segment, with is_point_on_segment.

is_point_on_mesh also doesn’t exist, but there is a function trimesh_pull_points_numpy that you can use to pull the points of the polyline onto the mesh and then compute the distance between the corresponding pairs of the original points and the pulled points to determine which points are on the mesh, up to a tolerance…

hope this helps.
otherwise submit a feature request :slight_smile:

When using compas.geometry.intersection_ray_mesh(ray, mesh) we will get:

compas.plugins.PluginNotInstalledError: Plugin not found for extension point URL: https:/plugins.compas.dev/intersections/intersection_ray_mesh

Do I need any extra installation for this function? We look forward to any guidance for using the plugin! :slight_smile:

yes, currently it uses compas_libigl for its implementation, but i will try to add a pure Python version as well…

1 Like

Thanks for the reply!

It would be great to add some resource info either in API reference or the code so we can know which extension we should add for using the plugin. :slight_smile: