Rotating X and Y coordinates with a certain angle.
16 views (last 30 days)
Show older comments
Pavlos Farangitakis
on 27 Nov 2018
Commented: Pavlos Farangitakis
on 27 Nov 2018
Hello,
I have a 7162176x2 array of cells that represent Cartesian coordinates. Column 1 is X, Column 2 is Y. I am trying to rotate these coordinates by 10 degrees clockwise.
I have read through matrix rotation, vector rotation and point rotation and from what I gather I need to create a rotation matrix and then multiply all my sets of points with it. This is what I have concluded to work with (I am including the before and after steps to make it easier to understand):
clear all
% SORT EXPORT IN THE SAME MANNER AS A .PRM FILE
m=csvread('file.csv',1,0); %REMOVE HEADER
%---------------------------------
%ORDER COLUMNS
n=m(1:end,[7 8 9 1]); %PICK DESIRED CELLS TO USE FOR OUTPUT
coordT=n(1:end,[1 2]); %GET X AND Y TO ROTATE
%ROTATION
theta=-10; %TO ROTATE CLOCKWISE BY X DEGREES
R=[cosd(theta) -sind(theta); sind(theta) cosd(theta)]; %CREATE THE MATRIX
rotcoord=R*coordT; %MULTIPLY VECTORS BY THE ROT MATRIX
%REPLACE X and Y columns on n with rotcoord X and Y
However it seems that the dimensions don't match. Am I approaching this the right way?
Apologies if this is something very simple that I am missing,
Thank you,
Pavlos
0 Comments
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!