How to check line and plane are intersecting and if, how to find point of intersection?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Matt J
le 6 Oct 2017
Modifié(e) : Matt J
le 6 Oct 2017
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
le 29 Juil 2020
how can we check if the point intersecting the plane is inside the convexx hull A B C D1?
Réponses (2)
Matt J
le 6 Oct 2017
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 commentaires
Matt J
le 4 Oct 2017
Modifié(e) : Matt J
le 4 Oct 2017
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Computational Geometry dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!