MATLAB: How to rotate points on 2D coordinate systems

how to rotate points on 2d coordinate systems

I have some points on a 2D Cartesian coordinate system. I want to rotate all these points 90 degrees counterclockwise. What is the best solution? (When I work with 3D coordinates, I use “view” to change the view direction, but apparently, it doesn’t work with 2D coordinates)

Best Answer

Hello,
You can rotate your points with a rotation matrix:
Here's a simple implementation,
% Create rotation matrix
theta = 90; % to rotate 90 counterclockwise
R = [cosd(theta) -sind(theta); sind(theta) cosd(theta)];
% Rotate your point(s)
point = [3 5]'; % arbitrarily selected
rotpoint = R*point;
The rotpoint is the 90 degree counterclockwise rotated version of your original point.
Hope this helps!