【发布时间】:2017-03-08 05:21:43
【问题描述】:
我有一组数据点,我想将每个数据在平面中逆时针旋转一个随机角度,围绕同一平面中的不同点。在第一次尝试中,我可以将它们在同一平面上的不同点逆时针旋转一定角度:
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-');
问题是,当我尝试旋转矩阵时,旋转矩阵的维度并不像它应该的那样相等。我不知道在这种情况下我应该如何创建旋转矩阵。 谁能建议如何解决这个问题?任何答案都非常感谢。
【问题讨论】:
-
这个问题没人能回答,有点奇怪
-
这并不“奇怪”。要么现在没有人可以回答你,要么人们根本不知道答案。我们在这里回答有关志愿者身份的问题。这不是一份全职工作。期望立即得到答案不是您应该采取的行为。
标签: matlab matrix rotation matlab-guide