Rotate a 3D data cloud to align with one axis

12 ビュー (過去 30 日間)
Nima Mirzaeian
Nima Mirzaeian 2020 年 1 月 13 日
編集済み: Image Analyst 2020 年 1 月 15 日
Hello! I have a cloud of data points in form of a spindle. How can I rotate the entire set so that the spindle long axis align with x axis? Thank you!

採用された回答

Looky
Looky 2020 年 1 月 14 日
I'm not sure if any built in functions exist for this purpose.
However, one mathematical way would be the following:
  1. Determine long axis of the spindle(how to do this depends on how you create your spindle). Save as vector r and normalize it: r=r/norm(r);
  2. Determine angle between r and the x-axis, use dot product between r and (1, 0, 0) => angle=acosd(dot(r,[1, 0, 0]))
  3. Determine rotation-vector u by crossing x-axis and r: u=cross([1,0,0],r);u=u/norm(u);
  4. Implement rotation matrix, see here: Wiki RotMat
  5. Multiply the vector representation of every single point with the rotation matrix
Example implementation of the rotation matrix(angle in degree):
u=u/norm(u);
rotMat=eye(3)*cosd(angle(1))+sind(angle(1))*[0,-u(3), u(2);u(3),0,-u(1);-u(2),u(1) 0]+(1-cosd(angle(1)))* [u(1)^2, u(1)*u(2), u(1)*u(3); u(1)*u(2), u(2)^2, u(2)*u(3); u(1)*u(3), u(2)*u(3), u(3)^2 ];
vector=vector*rotMat;
vector=vector/norm(vector);
  1 件のコメント
Nima Mirzaeian
Nima Mirzaeian 2020 年 1 月 15 日
Thanks!! It worked!

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 1 月 15 日
編集済み: Image Analyst 2020 年 1 月 15 日
You might be looking for the view() function, if you want to rotate the whole coordinate system (data plus axes) so that you're looking at it "straight on" or from a certain angle/viewpoint.

カテゴリ

Help Center および File ExchangePoint Cloud Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by