How to apply affine transformation or simple rotation on n points?

3 ビュー (過去 30 日間)
Muhammad Iqbal
Muhammad Iqbal 2020 年 1 月 24 日
回答済み: Image Analyst 2020 年 1 月 24 日
Can any one help me to apply random rotation (from 1 degree to 360 degree) on the following points :
I tried the following option but failed to generate the rotation scenario.
theta =90;
R=[cosd(theta) -sind(theta) 0 ;
sind(theta) cosd(theta) 0;
0 0 1];
P= [ 0 0 0;
15 0 0;
30 0 0;
45 0 0;
60 0 0];
rotpoint =P*R;

採用された回答

Image Analyst
Image Analyst 2020 年 1 月 24 日
Try it this way:
theta = 360 * rand;
rotationMatrix = [cosd(theta) -sind(theta) 0 ;
sind(theta) cosd(theta) 0;
0 0 1];
initialPoints = [ 0 0 0;
15 0 0;
30 0 0;
45 0 0;
60 0 0];
plot3(initialPoints(:, 1), initialPoints(:, 2), initialPoints(:, 3), 'b.', 'MarkerSize', 30);
hold on;
rotatedPoints = initialPoints * rotationMatrix
plot3(rotatedPoints(:, 1), rotatedPoints(:, 2), rotatedPoints(:, 3), 'r.', 'MarkerSize', 30);
grid on;
xlabel('X', 'FontSize', 20);
ylabel('Y', 'FontSize', 20);
zlabel('Z', 'FontSize', 20);
caption = sprintf('The initial points have been rotated by %.2f degrees', theta);
title(caption, 'FontSize', 20);
legend('Initial', 'Rotated');
0001 Screenshot.png

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by