How to rotate entire 3d data with x,y,z values along a particular axis (say x axis)?

412 ビュー (過去 30 日間)
Sagar
Sagar 2014 年 3 月 30 日
編集済み: Visa Suomi 2017 年 9 月 26 日
I need to rotate my 3d dataset defined by x,y,z coordinate along x axis at a specified angle (say 45 degree). This kinds of rotations are often needed when processing scanner and LIDAR data. MATLAB can do exactly what I want to do, but in graphic objects only i.e. using rotate(h,direction,alpha). However, this doesn't change the source data. I need to get the new rotated data, how can I retrieve the new rotated x,y,z data? Or, could you please suggest how to calculate in MATLAB?
Thank you,

採用された回答

Roger Stafford
Roger Stafford 2014 年 3 月 30 日
Let X,Y,Z be arrays of the rotated points in the dataset. For rotation along the x-axis:
X = x;
Y = y*cos(p)-z*sin(p);
Z = y*sin(p)+z*cos(p);
For rotation p radians in the direction from the y-axis toward the z-axis, that is, in accordance with the "right-hand rule" about the positive x-axis.
  2 件のコメント
Sagar
Sagar 2014 年 3 月 31 日
編集済み: Sagar 2014 年 3 月 31 日
Thanks, exactly what I was looking for. It would be great, if you can provide similar formula for rotating around y and z axis as well.
Visa Suomi
Visa Suomi 2017 年 9 月 26 日
編集済み: Visa Suomi 2017 年 9 月 26 日
Here are the transformations for all three axes.
Around X-axis:
X = x;
Y = y*cos(theta) - z*sin(theta);
Z = y*sin(theta) + z*cos(theta);
Around Y-axis:
X = x*cos(theta) + z*sin(theta);
Y = y;
Z = z*cos(theta) - x*sin(theta);
Around Z-axis:
X = x*cos(theta) - y*sin(theta);
Y = x*sin(theta) + y*cos(theta);
Z = z;

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

その他の回答 (1 件)

Matt J
Matt J 2014 年 3 月 30 日
  7 件のコメント
Matt J
Matt J 2014 年 3 月 31 日
Sorry, never mind. The syntax needs to be
XYZnew = AxelRot(XYZ, angle, [1 0 0],[]);
Sagar
Sagar 2014 年 3 月 31 日
That works. Thanks,
-Sagar

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

カテゴリ

Help Center および File Exchange3-D Scene Control についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by