From: Matt Thomas on
Hi All -

I have a matrix that I need to rotate a specified number of degrees about the x,y origin. I have found resources for matrix rotation for 90 degrees but I need a way to do it a user specified amount (say, for example, 5 degrees).

Can anyone point me in the right direction?

Thanks!

matt
From: Matt J on
"Matt Thomas" <matt.at(a)gmail.com> wrote in message <i1krpq$iuc$1(a)fred.mathworks.com>...
> Hi All -
>
> I have a matrix that I need to rotate a specified number of degrees about the x,y origin. I have found resources for matrix rotation for 90 degrees but I need a way to do it a user specified amount (say, for example, 5 degrees).
======

If you have the Image Processing Toolbox, you can use imrotate(). Otherwise, you might have to fall back to interp2().
From: Andy on
"Matt Thomas" <matt.at(a)gmail.com> wrote in message <i1krpq$iuc$1(a)fred.mathworks.com>...
> Hi All -
>
> I have a matrix that I need to rotate a specified number of degrees about the x,y origin. I have found resources for matrix rotation for 90 degrees but I need a way to do it a user specified amount (say, for example, 5 degrees).
>
> Can anyone point me in the right direction?
>
> Thanks!
>
> matt

It sounds like you found rot90? FYI, I do not think it means what you think it means.
From: Ben on
function [m] = rotmat(a,b,c);
%calculates the rotation matrix in order XYZ in a right handed system
%the coordinate system is rotated, not the points!

ca=cos(a);
sa=sin(a);
cb=cos(b);
sb=sin(b);
cc=cos(c);
sc=sin(c);
m1=[1 0 0;0 ca -sa;0 sa ca];%rotation only about x axis
m2=[cb 0 sb;0 1 0;-sb 0 cb];%rotation only about y axis
m3=[cc -sc 0;sc cc 0;0 0 1];%rotation only about z axis
% m1=[1 0 0;0 ca sa;0 -sa ca];
% m2=[cb 0 -sb;0 1 0;sb 0 cb];
% m3=[cc sc 0;-sc cc 0;0 0 1];
m=m1*m2*m3;


succes
From: Ravi on
Hi Matt,

If your matrix is a 1-D column vector, the problem is of coordinate transformation.

If your matrix is a 2D matrix that represents a tensor (such as stress, moment of inertia), the problem is of tensor transformation.

Let it be desired to transform from base to target coordinate system.

Let T= nxn orthogonal transformation matrix from base to target coordinate system (explained below)

1-D column vector:
X0= nx1 column vector in base coordinate system
X = nx1 column vector in target coordinate system

Then X=T*X0

2-D tensor matrix :
K0= nxn tensor matrix in base coordinate system
K = nxn tensor matrix in target coordinate system

Then K=T*K0*T' where T' is the transpose of T

Transformation Matrix T:
Transformation Matrix T is problem-dependent orthogonal matrix (inverse of T=transpose of T).
The rows of T are the direction cosines of the axis of the target coordinate system with respect to the base coordinate system.

For example, if it is desired to rotate about the Z-axis of the base coordinate system,

T=[
cos(angle) sin(angle) 0
cos(angle+pi/2) sin(angle+pi/2) 0
0 0 1 ]

where angle=rotation angle

If you need to rotate about X or Y-axis, modify T appropriately.

Hope this helps !

Ravi


"Matt Thomas" <matt.at(a)gmail.com> wrote in message <i1krpq$iuc$1(a)fred.mathworks.com>...
> Hi All -
>
> I have a matrix that I need to rotate a specified number of degrees about the x,y origin. I have found resources for matrix rotation for 90 degrees but I need a way to do it a user specified amount (say, for example, 5 degrees).
>
> Can anyone point me in the right direction?
>
> Thanks!
>
> matt
 |  Next  |  Last
Pages: 1 2
Prev: solve
Next: passing MATLAB structures to C/C++