-
Notifications
You must be signed in to change notification settings - Fork 5
/
Ry.m
48 lines (40 loc) · 1.19 KB
/
Ry.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function [XYZ] = ry(XYZ,b,units)
% 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
%
% $Revision: 1.1 $ $Date: 2004/11/12 01:30:25 $
% Licence: GNU GPL, no express or implied warranties
% History: 04/2002, Darren.Weber_at_radiology.ucsf.edu
% Developed after example 3.1 of
% Mathews & Fink (1999), Numerical
% Methods Using Matlab. Prentice Hall: NY.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~exist('units','var'), units = 'radians'; end
% convert degrees to radians
if isequal(units,'degrees'),
b = b*pi/180;
end
Ry = [ cos(b) 0 sin(b); 0 1 0; -sin(b) 0 cos(b) ];
if isequal(size(XYZ,1),3),
XYZ = Ry * XYZ;
else
XYZ = XYZ';
if isequal(size(XYZ,1),3),
XYZ = [Ry * XYZ]';
else
error('Ry: Input XYZ must be [N,3] or [3,N] matrix.\n');
end
end
return