Rotating a coordinate with a rotation matrix
Mostrar comentarios más antiguos
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 comentarios
Bruno Luong
el 10 de Sept. de 2019
Editada: Bruno Luong
el 10 de Sept. de 2019
Why you want to round up? The coordinates are real numbers, that might contain fractional part.
Stewart Tan
el 10 de Sept. de 2019
Bruno Luong
el 10 de Sept. de 2019
Editada: Bruno Luong
el 10 de Sept. de 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
Respuesta aceptada
Más respuestas (1)
Timothy Simon Thomas
el 30 de Mayo de 2020
Editada: Timothy Simon Thomas
el 30 de Mayo de 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
Categorías
Más información sobre Image Arithmetic en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




