How to define for which plane lies a given point with coordinates?

Hello!
Kindly ask about how to find in which plane lies point A(x, y, z), example A(1.5, 1.5, 3.0)
and I have planes
planes(:,:,1) = [0 3 3; 0 0 3; 0 3 0; 0 0 0];
planes(:,:,2) = [0 0 3; 3 0 3; 0 0 0; 3 0 0];
planes(:,:,3) = [3 0 3; 3 3 3; 3 0 0; 3 3 0];
planes(:,:,4) = [3 3 3; 0 3 3; 3 3 0; 0 3 0];
planes(:,:,5) = [0 3 0; 3 3 0; 0 0 0; 3 0 0];
planes(:,:,6) = [0 3 3; 3 3 3; 0 0 3; 3 0 3];
location_plane = 6;

 Accepted Answer

This is easiest to do with a vector-algebra approach. Something like this:
1, the plane can be described as all points such that , where is the normal to the plane and l is a scalar.
2, to use this, first use 3 of your 4 points to calculate the surface normal, (create 2 vectors that are not parallel, cross-multiply them and normalize that vector).
3, use the formula above with that normal-vector and all 4 points - to check that you get the same l for all four points.
4, test if also is identical to l
5, start over at point 1 with the next four points.
HTH

12 Comments

thank you for your advice and for your time.
I should multiply normal vector to all 4 points of each plane, am I right? And it will be my l. I found my normal using dot product of two vectors, as you wrote. But I dont know how to multiply all points to normal
Could you please help me how I shoudl write this multiplication. Cause I dont know how to multiply plane coordinates to normal. Or give an example
Best regards, Aknur
No you dont find the normal using the dot-product. A dot-product produces a scalar, and you need a vector. In order to produce a vector you have to do something else. One way to do this is using the cross-product between 2 vectors - provided that they are not parallel you will get a vector that is perpendicular to both vectors.
For you to do this you might have great use of the 2 best arrow-drawing functions on the file exchange: arrow3 and arrow. They will let you draw the arrows you work with and that ought to help you understand what your results are.
So first you should do something like:
p_4 = [3 3 3; 0 3 3; 3 3 0; 0 3 0];
plot3(p_1(:,1),p_1(:,2),p_1(:,3),'r.','markersize',18)
hold on
grid on
That shows the four point in what is claimed to be the fourth plane. If it is a plane (check by rotating the axes around), you know that the vector from one point to another on that plane is perpendicular to the normal (still unknown) - that means that we can generate two vectors that are perp to something like this:
v1 = p_4(2,:) - p_4(3,:);
v2 = p_4(1,:) - p_4(3,:);
arrow3([0 0 0],v1)
arrow3([0 0 0],v2)
axis auto
axis equal
Note that these are vectors "parallel to the plane" meaning that if you start at any point in the plane and move in the direction of v1 or v2 you will remain in the plane. Verify this by drawing an arrow from the fourth point in the direction of v1 or v2.
Then you calculate the normal vector by taking the cross-product:
n = cross(v1,v2);
n = n/norm(n);
arrow3([0 0 0],n)
Now you have the normal-vector of the plane. What remains is to determine l. You do that as explained above, and once you've done that you check if the given point A is also in that plane.
Thank you very much @Bjorn Gustavsson for your explanation
I could not understand how to calculate l, r * n
Could you please write example
I am sorry for my slow understanding(
I found my normal this way
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];
location_plane = 6;
for j=1:6
j
plane = planes(:,:,j);
p0 = plane(1,:);
p1 = plane(2,:);
p2 = plane(3,:);
p3 = plane(4,:);
V0 = plane(5,:);
Ri = [X0 Y0 Z0];
Rr = [XBar YBar ZBar];
A = p0-p2;
B = p0-p3;
n=cross(A,B); % normal vector of the Plane
n
That should work. Typically it is preferable to normalise n - to length 1. In this case it might not be strictly necessary - the difference is that l then will be in units of "lengths of n". But you might see it as "good practise" since then you know that you always work without that scaling.
Dear, @Bjorn Gustavsson Thank you very much for your explanation
I could not understand how to calculate l, r * n
Could you please write example
I am sorry for my slow understanding(
That step is rather easy (also use pen and paper to both write the equations and draw the points and vectors).
You calculate the distance the plane is shifted from the origin in the direction of by taking the dot-product between and one point in the plane. one definition of the dot-product in 3-D is:
l_dot = n(1)*r(1) + n(2)*r(2) + n(3)*r(3);
You can use that. However, matlab has a built-in function for dot-products too:
l_1 = dot(n,p1); % then check that you get the same l for the other 4 points too
Dear @Bjorn Gustavsson thank you so much for your expalantion and very detaieled answer.
Could you please write what is p1? Then I can use dot product of n of each plane and if l_1 or l = 0 then points lies on the plane right?
It is just one of your points, from your comment above.
@Bjorn Gustavsson thank you for your answer and clarification. I did smth like this. But at the end answer which is number of plane does not correct. Could you please check . Thank you so mcuh for your comments
X0 = 1.5;
Y0 = 3;
Z0 = 0;
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];
location_plane = 6;
for j=1:6 % j is number of plane
j
plane = planes(:,:,j);
p0 = plane(1,:); %p0 is top left point of plane
p1 = plane(2,:); %p1 is top right point of plane
p2 = plane(3,:); %p2 is bottom left point of plane
p3 = plane(4,:); %p3 is bottom right point of plane
V0 = plane(5,:); %point on the plane
% Pi is initial start point on the ray
Pi = [X0 Y0 Z0]; %initial start point
%Ri = [XBar YBar ZBar]; %direction vector with unit length
A = p0-p2; %calculate A and B then
B = p0-p3; %then to calculate Normal of each plane
n=cross(A,B); % Normal for each Plane
n
l0 = dot(p0,n);
l1 = dot(p1,n);
l2 = dot(p2,n);
l3 = dot(p3,n);
l4 = dot(Pi,n);
if l1 == l0 || l1 || l2 || l3
RS = planes(:,:,j);
else
RS ~= planes(:,:,j);
end
RS
plane_i = j;
j
end
I got same l for all 4 points (l0, l1, l2, l3 = =27), and l4 = dot(Pi,n) equal 0,
how then I can define on which plane lies my point with
You have to make the same check with your point A. If you get the same l for as for one plane then A lies on that plane, if you get the same l for multiple planes then A lies in all those planes.

Sign in to comment.

More Answers (0)

Products

Release

R2021b

Community Treasure Hunt

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

Start Hunting!