我有一組數據點,我想在同一平面上以不同角度繞平面中的每個數據逆時針旋轉一個隨機角度。在第一次嘗試,我可以逆時針飛機大約在同一平面的不同點有一定角度旋轉它們:在matlab中通過2d中的不同角度旋轉矩陣
x = 16:25;
y = 31:40;
% create a matrix of these points, which will be useful in future calculations
v = [x;y];
center = [6:15;1:10];
% define a 60 degree counter-clockwise rotation matrix
theta = pi/3; % pi/3 radians = 60 degrees
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
% do the rotation...
vo = R*(v - center) + center;
% pick out the vectors of rotated x- and y-data
x_rotated = vo(1,:);
y_rotated = vo(2,:);
% make a plot
plot(x, y, 'k-', x_rotated, y_rotated, 'r-');
然後我試圖概括它通過隨機天使旋轉,但是有一個問題,我在第二個代碼解決不了:
x = 16:25;
y = 31:40;
% create a matrix of these points, which will be useful in future calculations
v = [x;y];
center = [6:15;1:10]; %center of rotation
% define random degree counter-clockwise rotation matrix
theta = pi/3*(rand(10,1)-0.5); % prandom angle
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
% do the rotation...
vo = R*(v - center) + center;
% pick out the vectors of rotated x- and y-data
x_rotated = vo(1,:);
y_rotated = vo(2,:);
% make a plot
plot(x, y, 'k-', x_rotated, y_rotated, 'r-');
的問題是,當我嘗試旋轉矩陣,旋轉矩陣尺寸不等於所應當。我不知道如何在這種情況下創建旋轉矩陣。 任何人都可以建議如何解決這個問題?任何答案都非常感謝。
有沒有人可以回答這個問題有點奇怪 –
這不是「奇怪」。要麼現在沒有人可以回答你,或者人們根本不知道答案。我們在這裏回答關於志願者能力的問題。這不是全職工作。立即期待答案不是你應該在這裏採取的行爲。 – rayryeng