필터 지우기
필터 지우기

Translate vector to a center point

조회 수: 1 (최근 30일)
Alessandro Ruda
Alessandro Ruda 2022년 3월 3일
댓글: Jan 2022년 3월 4일
Dear MatLab comunity,
I have an array of few thousands xyz coordinates of three points in a molecule: A,B and C.
I created two array of vectors:
AB = [(A(:,1)-B(:,1)), (A(:,2)-B(:,2)), (A(:,3)-B(:,3))];
BC = [(C(:,1)-B(:,1)), (C(:,2)-B(:,2)), (C(:,3)-B(:,3))];
The two vectors share one of the point (B). Now I want to translate the two vector - keeping of course the same orientation and magnitude - so that the origin is the center of mass , which in my case is:
COM = [3.9721615314483643 -8.11227798461914 -0.34564414620399475]
How can I do that?
Thank you in advance!
/alex

답변 (1개)

Jan
Jan 2022년 3월 3일
At first simplify
AB = [(A(:,1)-B(:,1)), (A(:,2)-B(:,2)), (A(:,3)-B(:,3))];
BC = [(C(:,1)-B(:,1)), (C(:,2)-B(:,2)), (C(:,3)-B(:,3))];
to:
AB = A - B;
BC = C - B;
Now I'm not sure if I understand, what you are asking for. Vectors can be seen as directions or location. Moving them while keepinmg the direction is not meaning ful. This works with lines, but not with vectors, which can be move in space freely.
But maybe all you want to do is:
AB - COM
BC - COM
  댓글 수: 2
Alessandro Ruda
Alessandro Ruda 2022년 3월 3일
Okay, not really. I haven't explained clearly.
So I have a molecule and I calculated the center of mass and the principal axis of inertia and these are:
COM = [3.9721615314483643 -8.11227798461914 -0.34564414620399475]
X_ax = [0.43753358721733093 0.719929575920105 -0.5387632250785828]
Y_ax = [0.5724487900733948 0.2390475869178772 0.7843204736709595]
Z_ax = [0.6934455633163452 -0.6515809297561646 -0.3075314462184906]
Then I have these array of points A(x,y,z), B(x,y,z) and C(x,y,z). Each of these array has few thousands of coordinates.
Now I want first to generate the vectors AB and BC and then calculate the angle between these and each of the principal axis separately.
I hope I have explained it clearly, what would be the best way to do it?
/alex
Jan
Jan 2022년 3월 4일
Sorry, I do not get it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by