Home > matGeom > geom3d > createRotationOy.m

createRotationOy

PURPOSE ^

CREATEROTATIONOY Create the 4x4 matrix of a 3D rotation around y-axis.

SYNOPSIS ^

function trans = createRotationOy(varargin)

DESCRIPTION ^

CREATEROTATIONOY Create the 4x4 matrix of a 3D rotation around y-axis.

   TRANS = createRotationOy(THETA);
   Returns the transform matrix corresponding to a rotation by the angle
   THETA (in radians) around the Oy axis. A rotation by an angle of PI/2
   would transform the vector [0 0 1] into the vector [1 0 0].

   The returned matrix has the form:
   [ cos(THETA)  0  sin(THETA)  0 ]
   [    0        1       0      0 ]
   [-sin(THETA)  0  cos(THETA)  0 ]
   [    0        0       0      1 ]

   TRANS = createRotationOy(ORIGIN, THETA);
   TRANS = createRotationOy(X0, Y0, Z0, THETA);
   Also specifies origin of rotation. The result is similar as performing
   translation(-X0, -Y0, -Z0), rotation, and translation(X0, Y0, Z0).


   See also:
   transforms3d, transformPoint3d, createRotationOx, createRotationOz

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function trans = createRotationOy(varargin)
0002 %CREATEROTATIONOY Create the 4x4 matrix of a 3D rotation around y-axis.
0003 %
0004 %   TRANS = createRotationOy(THETA);
0005 %   Returns the transform matrix corresponding to a rotation by the angle
0006 %   THETA (in radians) around the Oy axis. A rotation by an angle of PI/2
0007 %   would transform the vector [0 0 1] into the vector [1 0 0].
0008 %
0009 %   The returned matrix has the form:
0010 %   [ cos(THETA)  0  sin(THETA)  0 ]
0011 %   [    0        1       0      0 ]
0012 %   [-sin(THETA)  0  cos(THETA)  0 ]
0013 %   [    0        0       0      1 ]
0014 %
0015 %   TRANS = createRotationOy(ORIGIN, THETA);
0016 %   TRANS = createRotationOy(X0, Y0, Z0, THETA);
0017 %   Also specifies origin of rotation. The result is similar as performing
0018 %   translation(-X0, -Y0, -Z0), rotation, and translation(X0, Y0, Z0).
0019 %
0020 %
0021 %   See also:
0022 %   transforms3d, transformPoint3d, createRotationOx, createRotationOz
0023 %
0024 
0025 %   ---------
0026 %   author : David Legland
0027 %   INRA - TPV URPOI - BIA IMASTE
0028 %   created the 18/02/2005.
0029 %
0030 
0031 %   HISTORY
0032 %   2008/11/24 changed convention for angle
0033 %   22/04/2009 rename as createcreateRotationOy
0034 
0035 
0036 % default values
0037 dx = 0;
0038 dy = 0;
0039 dz = 0;
0040 theta = 0;
0041 
0042 % get input values
0043 if length(varargin) == 1
0044     % only one argument -> rotation angle
0045     theta = varargin{1};
0046     
0047 elseif length(varargin) == 2
0048     % origin point (as array) and angle
0049     var = varargin{1};
0050     dx = var(1);
0051     dy = var(2);
0052     dz = var(3);
0053     theta = varargin{2};
0054     
0055 elseif length(varargin) == 3
0056     % origin (x and y) and angle
0057     dx = varargin{1};
0058     dy = varargin{2};
0059     dz = 0;
0060     theta = varargin{3};
0061     
0062 elseif length(varargin) == 4
0063     % origin (x and y) and angle
0064     dx = varargin{1};
0065     dy = varargin{2};
0066     dz = varargin{3};
0067     theta = varargin{4};
0068 end
0069 
0070 % compute coefs
0071 cot = cos(theta);
0072 sit = sin(theta);
0073 
0074 % create transformation
0075 trans = [...
0076     cot  0  sit  0;...
0077     0    1    0  0;...
0078     -sit 0  cot  0;...
0079     0    0    0  1];
0080 
0081 % add the translation part
0082 t = [1 0 0 dx;0 1 0 dy;0 0 1 dz;0 0 0 1];
0083 trans = t * trans / t;

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019