Rotation of an xy coordinate system
80 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi fellow MatLabbers, this is my first post. I hope I hang around here and ask questions and hopefully answer some at some point.
So... My first post question is:
I have a triangle with vectors (1,0) (2,4) and (-2,2) and I am supposed to rotate it by 2pi/3 in respect to the ORIGIN. Then I need to calculate the new coordinates after the rotation. Then I need to plot both the original and rotated triangle. This is what I have so far:
-----------
clear all
x = [1 2 -2 1];
y = [0 4 2 0];
theta = (2*pi)/3;
v=[x;y];
R = [cos(theta) sin(theta); -sin(theta) cos(theta)];
so = R*v;
x_rotated = so(1,:);
y_rotated = so(2,:);
% make a plot
plot(x, y, 'k-', x_rotated, y_rotated);
axis equal
x_rotated
y_rotated
-----------
I am not entirely sure if my result is correct because I assume since it needs to rotate in respect to the origin, the first vector should? stay the same.
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Object Programming en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!