planes(:,:,1) = [0 3 3; 0 0 3; 0 3 0; 0 0 0; 0 0 0]; planes(:,:,2) = [0 0 3; 3 0 3; 0 0 0; 3 0 0; 0 0 0]; planes(:,:,3) = [3 0 3; 3 3 3; 3 0 0; 3 3 0; 3 0 0]; planes(:,:,4) = [3 3 3; 0 3 3; 3 3 0; 0 3 0; 0 3 3]; planes(:,:,5) = [0 3 0; 3 3 0; 0 0 0; 3 0 0; 0 0 0]; planes(:,:,6) = [0 3 3; 3 3 3; 0 0 3; 3 0 3; 0 0 3];
6 different planes, represented by points in each plane. First, I'll verify that each set of 5 points you designated do indeed lie in a plane in R^3. (Hey you might have made a mistake.)
for i = 1:6 rank(planes(:,:,i) - planes(1,:,i)) end
ans = 2 ans = 2 ans = 2 ans = 2 ans = 2 ans = 2
Two planes are parallel if they have the same normal vector (Though you could multiply by -1.) So just compute the normal vectors to each plane.
Nullvecs = zeros(6,3); for i = 1:6 nullvecs(:,i) = null(planes(:,:,i) - planes(1,:,i)); end nullvecs
nullvecs = 3×6
1 0 1 0 0 0
0 -1 0 1 0 0
0 0 0 0 1 1
Now, look at those vectors. See that planes 1 and 3 have the same normal vectors, The signs of the normal vectors are the same. Planes 2 and 4 have a sign flip on the normal vectors. And planes 5 and 6 are also parallel. In the last case again, the normal vectors had the same signs. Could we identify those pairs automatically? Yes, of course. We can compute a corrrelation matrix, then look for elements of the correlation matrix that are exactly either 1 or -1. I'll put a small tolerance on that result.
C = abs(abs(corr(nullvecs) - eye(6)) - 1)<2*eps
C = 6×6 logical array 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0
Note that I subtracted the identity matrix so we don't identify each vector as the same as itself.
[I,J] = find(C); unique(sort([I,J],2),'rows')
ans = 3×2
1 3
2 4
5 6
So there were 3 pairs of parallel planes identified.
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Explore similar technical troubleshooting questions and verified MATLAB solutions: