How to define for which plane lies a given point with coordinates?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
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
Bjorn Gustavsson
on 4 Apr 2023
0 votes
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
Aknur
on 5 Apr 2023
Dear, @Bjorn Gustavsson
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
Bjorn Gustavsson
on 5 Apr 2023
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.
Aknur
on 5 Apr 2023
I could not understand how to calculate l, r * n
Could you please write example
I am sorry for my slow understanding(
Aknur
on 5 Apr 2023
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
Bjorn Gustavsson
on 5 Apr 2023
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.
Aknur
on 5 Apr 2023
I could not understand how to calculate l, r * n
Could you please write example
I am sorry for my slow understanding(
Bjorn Gustavsson
on 5 Apr 2023
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
Aknur
on 6 Apr 2023
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?
Bjorn Gustavsson
on 6 Apr 2023
It is just one of your points, from your comment above.
Aknur
on 6 Apr 2023
@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
Aknur
on 6 Apr 2023
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
Bjorn Gustavsson
on 6 Apr 2023
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.
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.More Answers (0)
Categories
Find more on Vector Data in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)