how to find a normal vector?

for example, there are 2 points. P0(4,3,2) ,P1(8,5,4) and the vector ->P0P1
I know that In three dimension, there are infinite number of vectors perpendicular to a given vector.
but i know the point which is on the plane.
To use this function, I need to find a normal vector of the plane.
In my case, P1 point wil be the V0 and P1 for this function.
[I,check]=plane_line_intersect(n,V0,P0,P1)
% n: normal vector of the Plane
% V0: any point that belong s to the Plane
% P0: end point 1 of the segment P0P1
% P1: end point 2 of the segment P0P1

 Risposta accettata

Matt J
Matt J il 25 Giu 2022
Modificato: Matt J il 25 Giu 2022
In my case, P1 point wil be the V0 and P1 for this function.
You need 3 distinct, non-colinear points in a the plane to calculate its normal. If V0,P0,V1 are such points, then you would do,
normal=cross(P1-P0,V-P0)

10 Commenti

Thanks Matt J
as i said, i know one point which is on a plane. to do cross product i made two arbitrary point.
but when i used the function, it only returns x and y value. all z value is zero
do you have any idea to solve this problem?
Here is my code
intersection_point = [];
for i = 1:length(mean_trajectory_double)
O = [mean_trajectory_double(i,1),mean_trajectory_double(i,2),mean_trajectory_double(i,3)];
P = [mean_trajectory_double(i,1)+1,mean_trajectory_double(i,2)+1,mean_trajectory_double(i,3)-1000];
Q = [mean_trajectory_double(i,1)+2,mean_trajectory_double(i,2)+2,mean_trajectory_double(i,3)+1000];
OP = Q-O;
OQ = P-O;
normalvector = cross(OP,OQ);
for j = 1:length(RKSI_Arr_33R)
for k = 1:length(RKSI_Arr_33R(j).Latitude)-1
[I,check]=plane_line_intersect([normalvector(1) normalvector(2) normalvector(3)]...
,[mean_trajectory_double(i,1) mean_trajectory_double(i,2) mean_trajectory_double(i,3)]...
,[RKSI_Arr_33R(j).Longitude(k) RKSI_Arr_33R(j).Latitude(k) RKSI_Arr_33R(j).BAlt(k)]...
,[RKSI_Arr_33R(j).Longitude(k+1) RKSI_Arr_33R(j).Latitude(k+1) RKSI_Arr_33R(j).BAlt(k+1)]);
end
end
intersection_point = [intersection_point;I];
end
O is the point I know already and P, Q is what i made.
mean_trajectory_double(i,1) is longitude
mean_trajectory_double(i,2) is latitude
mean_trajectory_double(i,3) is altitude
I changed the P and Q's altitude several time, but it always returend zero.
and in making two arbitrary point(P,Q), if there are better way, tell me please.
Thanks.
Torsten
Torsten il 25 Giu 2022
Modificato: Torsten il 25 Giu 2022
I don't understand your question.
If P0P1 is perpendicular to the plane and P1 lies in the plane, then the equation of the plane is
(-P0 + P1).' * x = (-P0 + P1).' * P1
where P0, P1 are given as column vectors.
Sierra
Sierra il 25 Giu 2022
I know that. What I'm asking is that to get the normal vector, I need 3 points on a plane.
but i know only one point on a plane. so how can i get the other two points?
Thanks Torsten.
Torsten
Torsten il 25 Giu 2022
Modificato: Torsten il 25 Giu 2022
P0 = [4 3 2];
P1 = [8 5 4];
normal_to_plane = (-P0 + P1);
% Generate two vectors that span the plane
in_plane = null(normal_to_plane)
% Generate two points in the plane
Q = P1.' + in_plane(:,1)
S = P1.' + in_plane(:,2)
% Test whether points Q, S are in plane
test_Q_in_plane = normal_to_plane*Q - normal_to_plane*P1.'
test_S_in_plane = normal_to_plane*S - normal_to_plane*P1.'
Matt J
Matt J il 25 Giu 2022
Modificato: Matt J il 25 Giu 2022
but i know only one point on a plane. so how can i get the other two points?
You said you know 3 points in the plane: P0,P1,V0
As I said in my original answer, you must be given 3 non-colinear points in the plane to determine its equaiton. It is a minimum requirement.
If you want to know only its normal, you must be given two vectors parallel to the plane. This is also a minimum requirement.
Sierra
Sierra il 25 Giu 2022
All i know is P0 and P1. and I want to know Q and S point.
Matt J
Matt J il 25 Giu 2022
Modificato: Matt J il 25 Giu 2022
There is no relationship between S,Q and P0,P1 conveyed in your picture. Also, your question asked how to determine the normal to the plane. But the difference vector P1-P0 is the normal to the plane, so you already know it. S and Q have nothing to do with anything.
Also, what happened to V0? Where is V0 in your picture?
Torsten
Torsten il 25 Giu 2022
I renamed the points in the plane as Q and S in the code above.
Thanks Torsten, your code worked perfectly.
but I have one problem in 'z' value.
intersection_point = cell(30,3)
lon = [];
lat = [];
alt = [];
for i = 1:length(mean_trajectory_double)-1
P0 = [mean_trajectory_double(i,:)];
P1 = [mean_trajectory_double(i+1,:)];
normal_to_plane = (-P0 + P1);
P2_in_plane = P1.' + in_plane(:,1);
P3_in_plane = P1.' + in_plane(:,2);
lon = [];
lat = [];
alt = [];
for j = 1:100
for k = 1:100
[I,check]=plane_line_intersect([normal_to_plane(1) normal_to_plane(2) normal_to_plane(3)]...
,[mean_trajectory_double(i,1) mean_trajectory_double(i,2) mean_trajectory_double(i,3)]...
,[RKSI_Arr_33R(j).Longitude(k) RKSI_Arr_33R(j).Latitude(k) RKSI_Arr_33R(j).BAlt(k)]...
,[RKSI_Arr_33R(j).Longitude(k+1) RKSI_Arr_33R(j).Latitude(k+1) RKSI_Arr_33R(j).BAlt(k+1)]);
end
lon = [lon;I(1)];
lat = [lat;I(2)];
alt = [alt;I(3)];
end
intersection_point{i,1} = [lon];
intersection_point{i,2} = [lat];
intersection_point{i,3} = [alt];
end
there is no problem in x(lon),y(lat) value. but z(alt) value print same number.
Sierra
Sierra il 25 Giu 2022
To Matt J
I thought P1 is V0, P1 in this function.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Centro assistenza e File Exchange

Richiesto:

il 25 Giu 2022

Commentato:

il 25 Giu 2022

Community Treasure Hunt

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

Start Hunting!

Translated by