Rotating a coordinate with a rotation matrix
Show older comments
So I'm working with a rotation matrix, basically trying to simulate

Where
and
are coordinates. H is a transformation matrix such as rotation
rot = [cosd(5),sind(5);-sind(5),cosd(5)];
Now, according to the equation, multiplying the transformation matrix with a coordinate
would result in a coordinate
but if
is [9,1] for example, if i multiply with the rotation matrix.
test_coor = [9;1];
h = [cosd(5),sind(5);-sind(5),cosd(5)];
out = test_coor * h;
I would get:
out =
9.0529
0.2118
But it's in decimals. So do i have to round it up the values after? Or am i supposed to do something with it to get
?
3 Comments
Bruno Luong
on 10 Sep 2019
Edited: Bruno Luong
on 10 Sep 2019
Why you want to round up? The coordinates are real numbers, that might contain fractional part.
Stewart Tan
on 10 Sep 2019
Bruno Luong
on 10 Sep 2019
Edited: Bruno Luong
on 10 Sep 2019
So you want to find out the (xi,yi) such that
H*[xi,yi] = [9;1] % 1 or 0, make your own mind
?
In that case
H = [cosd(5),sind(5);-sind(5),cosd(5)];
xy_j = [9;1];
xy_i = H'xy_j
you can then check
H*xy_i
Accepted Answer
More Answers (1)
Timothy Simon Thomas
on 30 May 2020
Edited: Timothy Simon Thomas
on 30 May 2020
Rotation Matrix acting on a Vector
Parameters
Theta holds the angle to be rotated by, vector is the initial vector.
vector=[1;6]
theta=270;
Plot Initial Vector
plot([0 vector(1)],[0 vector(2)],'r--^','LineWidth',2);
title("Vector Rotation","BackgroundColor",'y')
hold on;
Rotation Matrix
2D-rotation matrix on the X-Y plane.
Rot_by_theta=[cosd(theta) -sind(theta) ; sind(theta) cosd(theta)]
Rotate
Multiply the initial vector with the rotation matrix to get the rotated vector.
rotated_vector=(Rot_by_theta*vector);
Plot Rotated Vector
Insert 0 at the begining to visualize the vector
plot([0 rotated_vector(1)],[0 rotated_vector(2)],'m-o','LineWidth',2);
legend("Ini_vector","Rotated")
Aesthetics
Draws X-Y axes, sets limts between -10 and 10 on both axes
grid on
xlim([-10 10])
ylim([-10 10])
line([xlim],[0 0]);
line([0 0],[ylim]);
hold off
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



