ry - Rotate 3D Cartesian coordinates around the Y axis Useage: [XYZ] = ry(XYZ,beta,units) XYZ is a [3,N] or [N,3] matrix of 3D Cartesian coordinates 'beta' - angle of rotation about the Y axis 'units' - angle is either 'degrees' or 'radians' the default is beta in radians If input XYZ = eye(3), the XYZ returned is the rotation matrix. See also rx rz
0001 function [XYZ] = ry(XYZ,b,units) 0002 0003 % ry - Rotate 3D Cartesian coordinates around the Y axis 0004 % 0005 % Useage: [XYZ] = ry(XYZ,beta,units) 0006 % 0007 % XYZ is a [3,N] or [N,3] matrix of 3D Cartesian coordinates 0008 % 0009 % 'beta' - angle of rotation about the Y axis 0010 % 'units' - angle is either 'degrees' or 'radians' 0011 % the default is beta in radians 0012 % 0013 % If input XYZ = eye(3), the XYZ returned is 0014 % the rotation matrix. 0015 % 0016 % See also rx rz 0017 % 0018 0019 % $Revision: 1.1 $ $Date: 2004/11/12 01:30:25 $ 0020 0021 % Licence: GNU GPL, no express or implied warranties 0022 % History: 04/2002, Darren.Weber_at_radiology.ucsf.edu 0023 % Developed after example 3.1 of 0024 % Mathews & Fink (1999), Numerical 0025 % Methods Using Matlab. Prentice Hall: NY. 0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0027 0028 if ~exist('units','var'), units = 'radians'; end 0029 0030 % convert degrees to radians 0031 if isequal(units,'degrees'), 0032 b = b*pi/180; 0033 end 0034 0035 Ry = [ cos(b) 0 sin(b); 0 1 0; -sin(b) 0 cos(b) ]; 0036 0037 if isequal(size(XYZ,1),3), 0038 XYZ = Ry * XYZ; 0039 else 0040 XYZ = XYZ'; 0041 if isequal(size(XYZ,1),3), 0042 XYZ = [Ry * XYZ]'; 0043 else 0044 error('Ry: Input XYZ must be [N,3] or [3,N] matrix.\n'); 0045 end 0046 end 0047 0048 return