Given the Rotation Matrix (M), rotate any 2D vector in a counterclockwise by theta (x), then show that M'x rotates the vector clockwise back to the original position

10 views (last 30 days)
I have a homework assignment, and I am asked to rotate a vector (v) by the rotation matrix (M), by any angle (x) in a counter clockwise direction, then show that M'x rotates the vector back to the original position.
My code looks like this:
%theta=x
%R=M
v=[100 100]
x=45
R=[cosd(x) -sind(x);sind(x) cosd(x)]
vR=v*R
quiver(0,0,v(1),v(2))
hold on
quiver(0,0,vR(1),vR(2))
S=R'
vS=v*S
quiver(0,0,v(1),v(2))
hold on
quiver(0,0,vS(1),vS(2))
My plot looks like this:
  3 Comments
Jimmy Cleveland
Jimmy Cleveland on 25 Mar 2018
Walter, Thanks for the reply. Not sure how I would go about proving that the transpose of the rotation matrix would rotate the vector back to the original position. Thanks, Jimmy
Walter Roberson
Walter Roberson on 25 Mar 2018
Take the formula you have for R and write out the terms of
R.' * R
and remember one of the fundamental properties relating sine and cosine.
I recommend you work in radians to make the formulas simpler

Sign in to comment.

Accepted Answer

Jimmy Cleveland
Jimmy Cleveland on 25 Mar 2018
Thanks to both of you!

More Answers (1)

Image Analyst
Image Analyst on 25 Mar 2018
Edited: Image Analyst on 25 Mar 2018
Try using ismembertol() to determine if v and vs are within some small number, like 0.00001 or something. Then, you got the rotation matrix on the wrong side. Try it this way.
v = [100; 100] % Initialize to point along the 45 degree line.
x = 45; % Define angle to rotate by.
% Construct rotation matrix.
M = [cosd(x) -sind(x); sind(x) cosd(x)]
vR = M * v
% Plot original vector.
subplot(1, 2, 1); % Plot in the left plot.
quiver(0, 0, v(1), v(2), 'LineWidth', 2)
text(v(1), v(2), 'Original');
grid on;
hold on
axis equal;
xlim([-5,150]);
ylim([-5,150]);
% Plot rotated vector.
quiver(0, 0, vR(1), vR(2), 'LineWidth', 2)
text(vR(1), vR(2), 'Rotated');
% Rotate vR back to v location.
vS = M' * vR
% Plot rotated vector.
subplot(1, 2, 2); % Plot in the left plot.
quiver(0, 0, vR(1), vR(2), 'LineWidth', 2)
text(vR(1), vR(2), 'Rotated');
grid on;
hold on
axis equal;
xlim([-5,150]);
ylim([-5,150]);
% Plot restored vector.
quiver(0, 0, vS(1), vS(2), 'LineWidth', 2)
text(vS(1), vS(2), 'Rotated back');
theyMatch = ismembertol(v, vS, 0.0001)
if all(theyMatch)
uiwait(helpdlg('They match'));
else
uiwait(helpdlg('They do not match'));
end
As for why quiver does not go all the way out to the point it should, like (100,100), I have no idea.

Community Treasure Hunt

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

Start Hunting!