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?
I followed this link
  4 个评论
Matt J
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.

请先登录,再进行评论。

回答(2 个)

Matt J
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.

Matt J
Matt J 2017-10-4
编辑:Matt J 2017-10-4
The issue is that the line does in fact intersect the plane, contrary to what you believe. The point I=[-21.2205 31.6268 -6.3689] clearly satisfies the plane equation
>> dot(n,I-V0)
ans =
-4.4409e-15
and by construction clearly also does lie on the line.

类别

Help CenterFile Exchange 中查找有关 Computational Geometry 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by