Rotation of an xy coordinate system
81 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Matt J
on 30 Oct 2020
Looks fine to me. When you rotate about the origin, the only point that stays fixed is the origin.
3 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Object Programming 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!