how i find intersection point between 3d stl object and a line

i have a face uploaded as an stl file which is made up of faces and matrices i have a line passing through the surface i want to find the point where the line and surface intersects

4 Comments

Did you find an efficient approach to solve this problem? I am also working with stl files (triangle meshes). But testing millions of 3D triangles for intersection with a line would not be efficient enough.
Since R2018b, MATLAB has built-in STL tools. You don't need to download anything.
For legacy versions needing third-party tools, I'd strongly recommend these tools over other FEX tools. This explains why.
If you use #22409 or #29906 in a modern installation, you will shadow the inbuilt tools and likely cause problems for yourself unless you rename them. FEX #30923 has significant bugs. #51200 is good, but is superceded completely by #182013.

Sign in to comment.

Answers (1)

STL approximate the outer surface of the 3D model by a number of connected triangles, so you could take a look at the ray/triangle intersection algorithms, that may help you.
Following are some ray/triangle Intersection functions:

Asked:

on 26 Mar 2018

Edited:

DGM
on 7 Oct 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!