フィルターのクリア

Calculate the normal vector between two nodes in the space

30 ビュー (過去 30 日間)
Alberto Acri
Alberto Acri 2024 年 8 月 11 日 12:41
編集済み: Torsten 2024 年 8 月 11 日 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)

採用された回答

Torsten
Torsten 2024 年 8 月 11 日 12:49
編集済み: Torsten 2024 年 8 月 11 日 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 件のコメント
Alberto Acri
Alberto Acri 2024 年 8 月 11 日 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 2024 年 8 月 11 日 15:26
編集済み: Torsten 2024 年 8 月 11 日 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) )

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by