필터 지우기
필터 지우기

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 CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by