How to check if two planes intersect with each other?
Show older comments
Suppose I have two planes defined by four points (each) as follows. For ease of explanation, I will follow a graphical approach.
A = [-1140,14,16.125; -1140,14,0; -1140,10.5,-4; 1118,0,64.5];
B = [1500, 0, 0; 1500, 14, 0; -1500, 14, 0; -1500, 0, 0];
fill3(A(:,1), A(:,2), A(:,3), 'b', 'FaceAlpha',0.5); hold on
fill3(B(:,1), B(:,2), B(:,3), 'r', 'FaceAlpha',0.5)
As one can see, the two planes intersect. However, I have a cloud of different points (like A) that creates panels. How can I check which ones intersect with another plane (say, like B)? I think I should use cross, but I'm not sure how to use it. In the end, what I'm interested in is running the point cloud through a for loop, and separating the panels that intersect with one specific panel. I know an if command will do the trick, but I'm having trouble making the logic here. Any help is appreciated!
4 Comments
John D'Errico
on 1 Nov 2022
Two planes will ALWAYS cross each other, if they are not perfectly parallel. So just test to see if the planes are parallel and not co-incident. But it is not clear if your question is if the planes cross each other in some restricted domaim. That would be a very different problem to solve. BE CLEAR.
Andrea Somma
on 1 Nov 2022
try solving it simbolically https://it.mathworks.com/matlabcentral/answers/366108-intersection-of-two-planes, look here
Bruno Luong
on 1 Nov 2022
" two planes intersect"
I hope you know exactly the mathematical of the word "plane"when writing thos sentence and not confuse it with a patch (a 2D manifold that is bounded, such as polygonal defined by 4 vertices).
Jake
on 2 Nov 2022
Answers (2)
Planes intersect, if their normal vectors point to different directions:
A = [-1140,14,16.125; -1140,14,0; -1140,10.5,-4; 1118,0,64.5];
B = [1500, 0, 0; 1500, 14, 0; -1500, 14, 0; -1500, 0, 0];
nA = GetPlaneNormal(A);
nB = GetPlaneNormal(B);
doIntersect = dot(nA, nB) > 1000 * eps
function N = GetPlaneNormal(X)
m = mean(X, 1); % Center of points
[U, S, V] = svd(X - m, 0);
N = V(:, 3);
% A very coarse test, if data resemble a plane:
if S(1,1) < 100 * S(2,2) || S(2,2) < 100 * S(3,3)
warning('Jan:GetPlaneNormal:Noisy', 'Data not similar to a plane.');
end
end
Bruno Luong
on 2 Nov 2022
fastMesh2Mesh(A,B,[1 2 4; 2 3 4], [1 2 4; 2 3 4],100)
If the result is not empty the patch (splitted in 2 trangles, there are 2 ways, but we pick them arbitrary) then the patches intersect.
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!