フィルターのクリア

Large amount of coordinates transformation in 3D

1 回表示 (過去 30 日間)
M Teaxdriv
M Teaxdriv 2022 年 7 月 13 日
回答済み: Walter Roberson 2022 年 7 月 13 日
Hello,
I am trying to perform transformation of large amount of coordinates, but firstly I am doing it on this small example:
I would like to rotate by 10 degrees about y axis x y z coordinates ( size is 8 x 3). How to perform such rotation? I have found rotation matrices but they are 3x3 and if I want to mupliply matrices [3x3] * [8x3] it is not possible.
Therefore I would like to ask you for help.
theta = 10;
A = [0 0 0; 1 1 1; 0 0 1; 1 1 0; 1 0 1; 0 1 0; 0 1 1; 1 0 0];
x = A(:,1); y = A(:,2); z = A(:,3);
RY = [
cosd(theta) 0 sind(theta)
0 1 0;
-sind(theta) 0 cosd(theta)];
ARY = RY*A;
Best regards
Michal

採用された回答

Chunru
Chunru 2022 年 7 月 13 日
Transpose A:
theta = 10;
A = [0 0 0; 1 1 1; 0 0 1; 1 1 0; 1 0 1; 0 1 0; 0 1 1; 1 0 0]';
x = A(:,1); y = A(:,2); z = A(:,3);
RY = [
cosd(theta) 0 sind(theta)
0 1 0;
-sind(theta) 0 cosd(theta)];
ARY = RY*A
ARY = 3×8
0 1.1585 0.1736 0.9848 1.1585 0 0.1736 0.9848 0 1.0000 0 1.0000 0 1.0000 1.0000 0 0 0.8112 0.9848 -0.1736 0.8112 0 0.9848 -0.1736
A
A = 3×8
0 1 0 1 1 0 0 1 0 1 0 1 0 1 1 0 0 1 1 0 1 0 1 0

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 7 月 13 日
theta = 10;
M = makehgtform('yrotate', deg2rad(theta))
M = 4×4
0.9848 0 0.1736 0 0 1.0000 0 0 -0.1736 0 0.9848 0 0 0 0 1.0000
A = [0 0 0; 1 1 1; 0 0 1; 1 1 0; 1 0 1; 0 1 0; 0 1 1; 1 0 0];
x = A(:,1); y = A(:,2); z = A(:,3);
c = zeros(size(x));
xyzc = [x, y, z, c];
newxyz = xyzc * M
ans = 8×4
0 0 0 0 0.8112 1.0000 1.1585 0 -0.1736 0 0.9848 0 0.9848 1.0000 0.1736 0 0.8112 0 1.1585 0 0 1.0000 0 0 -0.1736 1.0000 0.9848 0 0.9848 0 0.1736 0
newx = newxyz(:,1); newy = newxyz(:,2); newz = newxyz(:,3);

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by