How to check line and plane are intersecting and if, how to find point of intersection?
10 次查看(过去 30 天)
显示 更早的评论
I have a plain with known four co-ordinates and a line with two known co-ordinates as given below. plane points A,B,C,D1 and line points P0,P1 are
A =[ -6.8756 39.9090 10.0000]
B =[ -6.0096 40.4090 10.0000]
C =[ -6.0096 40.4090 11.0000]
D1=[ -6.8756 39.9090 11.0] %edited by Matt J
P0 =[6.3315 -1.8031 2.5170]
P1 =[ -70.9372 91.9500 -22.4032]
I checked for plane line intersection using following code
AB = A-B
AD = A-D1
mod_AB = sqrt(dot(AB, AB))
mod_AD = sqrt(dot(AD, AD))
n = cross(AB, AD) / (mod_AB*mod_AD)
V0 = A
I=[0 0 0]
u = P1-P0
w = P0 - V0
D = dot(n,u)
N = -dot(n,w)
sI = N / D
I = P0+ sI.*u
if (sI < 0 || sI > 1)
check= 0
else
check=1
end
%[I,check]=plane_line_intersect(n,V0,P0,P1)
all_plain_pts = [A;B;C;D1]
fill3(all_plain_pts(:,1),all_plain_pts(:,2),all_plain_pts(:,3),'yellow')
alpha(0.2)
hold on
all_line = [P0;P1]
plot3(all_line(:,1),all_line(:,2),all_line(:,3),'blue')
plot3(I(:,1),I(:,2),I(:,3),'r*')
xlabel('X')
ylabel('Y')
zlabel('Z')
Even if this plane and line is not intersecting, it shows check=1 and intersection point I =[-21.2205 31.6268 6.3689]. Can you please explain what is the issue?
4 个评论
Matt J
2017-10-6
编辑:Matt J
2017-10-6
Well, they clearly do intersect. See my answer below.
But why is it necessary to test whether (sI < 0 || sI > 1)|? This enforces a condition that the line not only intersect the plane, but that the point of intersection must lie between P0 and P1. That should be unnecessary if you only care about the line intersecting the plane.
APS502
2020-7-29
how can we check if the point intersecting the plane is inside the convexx hull A B C D1?
回答(2 个)
Matt J
2017-10-6
Another way to do this is using intersectionHull in this FEX package. For example, the intersection of the line segment P0,P1 with the plane can be obtained as
>> Istruct=intersectionHull('vert',[P0;P1],'lcon',[],[],n,dot(n,V0));
>> I=Istruct.vert
I =
-21.2205 31.6268 -6.3689
and you can see that it finds the same intersection point as your code.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computational Geometry 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!