# How can I find the intersection between a line and a 3D surface?

112 visualizzazioni (ultimi 30 giorni)
Leonardo Colavitti il 24 Ago 2017
Hi guys, I am facing a ray tracing problem and now I am a bit locked. My target is to find the point of intersection (Xp, Yp, Zp) between a straight line of which I know the equation and a surface in 3 dimensions that is not defined analytically but consists in a series of n points in the 3 dimensions. Does anyone have any suggestion? Thanks in advance for your help,
Leonardo
##### 2 CommentiMostra NessunoNascondi Nessuno
jabrie il 22 Lug 2018
Did you find an efficient solution to solve this problem? I am currently looking for a ray-triangle intersection solution. Unfortunately, my surface model consists of several million triangular meshes. Therefore, the intersection calculation of a ray with all available 3D triangles is not efficient enough. What is your starting point for this problem?
Leonardo Colavitti il 24 Lug 2018
Ciao Jabrie, sorry for the delay in the reply. Yes, at the end I remember that I was able to solve that problem... In my opinion the matlab function TriangleRayIntersection.m can strongly help you. The package is available at this link: https://ch.mathworks.com/matlabcentral/fileexchange/33073-triangle-ray-intersection. Best, Leonardo

Accedi per commentare.

### Risposta accettata

John D'Errico il 24 Ago 2017
The "surface" exists only in your mind. All you have are points. Isolated points. So until you find away to connect those points into a true surface in some form, you can do nothing.
Simple is to use a convex hull. That is great, if the volume described is truly convex, or even sufficiently close to being convex. Your next choice is to use an alpha shape.
In either of the above cases, the outer boundary is a triangulation. So now the problem reduces to solving for the intersection of a line with a triangulated surface. This part is pretty easy. You just need to solve for the intersection of a line with a triangle, and then repeat for each triangle. Better code will see how to eliminate some of those triangles from consideration, but in any case it is not that hard. Just computational geometry.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Più risposte (1)

Subhosit Ray il 30 Mag 2018
Just like the famous yoda said the matrix exists only in your mind ^_^
but another cool way to find the surface is using fit() function.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Surface and Mesh Plots in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by