Effacer les filtres
Effacer les filtres

Calculate the normal vector between two nodes in the space

30 vues (au cours des 30 derniers jours)
Alberto Acri
Alberto Acri le 11 Août 2024 à 12:41
Modifié(e) : Torsten le 11 Août 2024 à 15:26
Hi! I have two nodes A and B. These are positioned in space with the same value of X and Y but different Z. The normal in this case would be n=[0 0 1] (red plane parallel to the XY plane).
I would like to calculate the normal n 'green' in the case of nodes A and C. Is this possible?
A = [-33.24 -10.70 7.41];
B = [A(1,1), A(1,2), A(1,3)+5];
N = [A;B];
C = [A(1,1), A(1,2)+7, A(1,3)+5];
NN = [A;C];
figure
plot3(A(1,1),A(1,2),A(1,3),'k.','Markersize',30);
hold on
plot3(B(1,1),B(1,2),B(1,3),'r.','Markersize',30);
plot3(C(1,1),C(1,2),C(1,3),'g.','Markersize',30);
plot3(N(:,1),N(:,2),N(:,3),'-k','LineWidth',1);
plot3(NN(:,1),NN(:,2),NN(:,3),'-k','LineWidth',1);
hold off
axis equal
(YZ view)

Réponse acceptée

Torsten
Torsten le 11 Août 2024 à 12:49
Modifié(e) : Torsten le 11 Août 2024 à 12:57
n = [0 0 1] points from A to B. So I don't understand what you mean by "normal" to the line connecting two points in 3d.
Usually, it's the set of all vectors perpendicular to the line. You get a basis for this set of vectors by the "null" command:
A = [0 0 0];
B = [0 0 1];
AB = -A + B;
N = null(AB)
N = 3x2
0 -1 1 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
N.'*AB.' % Check for orthogonality
ans = 2x1
0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
  2 commentaires
Alberto Acri
Alberto Acri le 11 Août 2024 à 15:10
My terminology may not be correct.
The vector 'n' I called 'normal' because if I create a plane with the components of 'n' it turns out to be a plane parallel to the XY plane (because only Z varies). The value of 'n' is valid for all nodes from A to B.
I wanted to know if there was a way to identify the value of 'n' in case the direction of the nodes is AC. This value of 'n' will be the same for all nodes present between A and C (as for the AB case).
Let me know if I have made myself clear!
Torsten
Torsten le 11 Août 2024 à 15:26
Modifié(e) : Torsten le 11 Août 2024 à 15:26
Then, as in your first simple example, n is simply the vector connecting A and C, computed as -A+C ( maybe normalized to length 1 as (-A+C)/norm(-A+C) )

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by