Can I rotate an array by 15 degrees?.

19 views (last 30 days)
Yrobel Lima
Yrobel Lima on 25 Sep 2017
Commented: Walter Roberson on 25 Sep 2017
Can I rotate an array by 15 degrees?. Thanks
  1 Comment
Stephen23
Stephen23 on 25 Sep 2017
Once you define for us what that means, then yes. Please show what this matrix looks like once it has been rotated by fifteen degrees:
>> [0,1;1,0]
ans =
0 1
1 0

Sign in to comment.

Answers (2)

Bjorn Gustavsson
Bjorn Gustavsson on 25 Sep 2017
As Stephen points out you need to specify matters a bit more. Primarily what rotate by 15 degrees would mean for arrays in dimensions larger than 2.
For the 2-D case this should do it:
rotM = @(phi) [cos(phi) -sin(phi);sin(phi) cos(phi)]; rot15_a = rotM(15*pi/180)*a;
I have seen people using other notations for the rotation angle...
HTH
  3 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 25 Sep 2017
Edited: Bjorn Gustavsson on 25 Sep 2017
Yes, I thought that reasonably obvious?
Walter Roberson
Walter Roberson on 25 Sep 2017
Coordinates are more often given with the x and y as columns rather than as rows.
If the reader was thinking in terms of rotating images rather than in terms of applying rotation to coordinate matrices, then they might not immediately recognize that the rotM code is not directly suitable for rotating images.

Sign in to comment.


Walter Roberson
Walter Roberson on 25 Sep 2017
Sometimes imrotate() is what is needed.
But only sometimes.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!