Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slrotmat
Home > sltoolbox > smallmat > slrotmat.m

slrotmat

PURPOSE ^

SLROTMAT Get the 2x2 rotation matrix

SYNOPSIS ^

function R = slrotmat(theta)

DESCRIPTION ^

SLROTMAT Get the 2x2 rotation matrix

 $ Syntax $
   - R = slrotmat(theta)

 $ Arguments $
   - theta:      the radian of rotation
   - R:          the rotation matrix

 $ Description $
   - R = slrotmat(theta) computes the 2x2 rotation matrix R which
     rotates a 2D point anti-clockwisely by radian of theta. 
     If theta is a scalar, then R will be a 2x2 matrix, if
     theta is an n1 x n2 x ... array, then R will be a set of 
     matrices stored in an 2 x 2 x n1 x n2 x ... array.

 $ Remarks $
   - The R is given by following formula:
     R = [ cos(theta)   -sin(theta);
           sin(theta)    cos(theta) ];

 $ History $
   - Created by Dahua Lin on Apr 23, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:

SOURCE CODE ^

0001 function R = slrotmat(theta)
0002 %SLROTMAT Get the 2x2 rotation matrix
0003 %
0004 % $ Syntax $
0005 %   - R = slrotmat(theta)
0006 %
0007 % $ Arguments $
0008 %   - theta:      the radian of rotation
0009 %   - R:          the rotation matrix
0010 %
0011 % $ Description $
0012 %   - R = slrotmat(theta) computes the 2x2 rotation matrix R which
0013 %     rotates a 2D point anti-clockwisely by radian of theta.
0014 %     If theta is a scalar, then R will be a 2x2 matrix, if
0015 %     theta is an n1 x n2 x ... array, then R will be a set of
0016 %     matrices stored in an 2 x 2 x n1 x n2 x ... array.
0017 %
0018 % $ Remarks $
0019 %   - The R is given by following formula:
0020 %     R = [ cos(theta)   -sin(theta);
0021 %           sin(theta)    cos(theta) ];
0022 %
0023 % $ History $
0024 %   - Created by Dahua Lin on Apr 23, 2006
0025 %
0026 
0027 if isscalar(theta)  % single
0028     R = [cos(theta), -sin(theta);
0029          sin(theta),  cos(theta)];
0030 else % multiple
0031     TM = reshape(theta, [1, 1, size(theta)]);
0032     CM = cos(TM);
0033     SM = sin(TM);
0034     R = [CM, -SM;
0035          SM,  CM];
0036 end
0037 
0038     
0039 
0040

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com