Translate vector to a center point

12 views (last 30 days)
Alessandro Ruda
Alessandro Ruda on 3 Mar 2022
Commented: Jan on 4 Mar 2022
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

Answers (1)

Jan
Jan on 3 Mar 2022
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 Comments
Jan
Jan on 4 Mar 2022
Sorry, I do not get it.

Sign in to comment.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by