How to determine if a 3D line segment intersects a side of a 3D rectangular prism?

조회 수: 13 (최근 30일)
Hello,
I am trying to find a way to determine if a line segment drawn between two points in 3D space will intersect another 3D body (retangular prism) that is defined by regions using (x, y, z) vertices.
Is there a way to do this in Matlab?

채택된 답변

Matt J
Matt J 2022년 9월 28일
편집: Matt J 2022년 9월 28일
  댓글 수: 2
MS
MS 2022년 9월 28일
Hi Matt,
Thanks for your suggestion. So in this case, V holds the vertices of the rectangular prism and Aeq holds the (x,y,z) values for the two endpoints of the line segment? What is the role of beq? I noticed in the 'lcon2vert' function, beq is referred to as equality data.
Matt J
Matt J 2022년 9월 28일
편집: Matt J 2022년 9월 28일
No, you can specify both the line segment and the prism in terms of vertices if you wish, for example,
Vprism=dec2bin(0:2^3-1,2)-'0'+1 %vertices of prism
Vline=[0,0,0;3 3 3]; %vertices of line segment
I=intersectionHull('vert',Vprism,'vert',Vline); %compute intersection
>> I.vert
ans =
1.0000 1.0000 1.0000
2.0000 2.0000 2.0000

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2022년 9월 29일
You can also use Siddon's algorithm
which will compute the intersection between a ray and many prisms.

카테고리

Help CenterFile Exchange에서 Delaunay Triangulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by