Home > matGeom > geom3d > createRotationOz.m

createRotationOz

PURPOSE ^

CREATEROTATIONOZ Create the 4x4 matrix of a 3D rotation around z-axis.

SYNOPSIS ^

function trans = createRotationOz(varargin)

DESCRIPTION ^

CREATEROTATIONOZ Create the 4x4 matrix of a 3D rotation around z-axis.

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

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

   TRANS = createRotationOz(ORIGIN, THETA);
   TRANS = createRotationOz(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, createRotationOy

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function trans = createRotationOz(varargin)
0002 %CREATEROTATIONOZ Create the 4x4 matrix of a 3D rotation around z-axis.
0003 %
0004 %   TRANS = createRotationOz(THETA);
0005 %   Returns the transform matrix corresponding to a rotation by the angle
0006 %   THETA (in radians) around the Oz axis. A rotation by an angle of PI/2
0007 %   would transform the vector [1 0 0] into the vector [0 1 0].
0008 %
0009 %   The returned matrix has the form:
0010 %   [cos(THETA) -sin(THETA)  0  0]
0011 %   [sin(THETA)  cos(THETA)  0  0]
0012 %   [    0           0       1  0]
0013 %   [    0           0       0  1]
0014 %
0015 %   TRANS = createRotationOz(ORIGIN, THETA);
0016 %   TRANS = createRotationOz(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, createRotationOy
0023 %
0024 
0025 %   ---------
0026 %   author : David Legland
0027 %   INRA - TPV URPOI - BIA IMASTE
0028 %   created the 06/04/2004.
0029 %
0030 
0031 %   HISTORY
0032 %   2008/11/24 changed convention for angle
0033 %   22/04/2009 rename as createcreateRotationOz
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) == 4
0056     % origin (x and y) and angle
0057     dx = varargin{1};
0058     dy = varargin{2};
0059     dz = varargin{3};
0060     theta = varargin{4};
0061 end
0062 
0063 % compute coefs
0064 cot = cos(theta);
0065 sit = sin(theta);
0066 
0067 % create transformation
0068 trans = [...
0069     cot -sit 0 0;...
0070     sit  cot 0 0;...
0071     0 0 1 0;...
0072     0 0 0 1];
0073 
0074 % add the translation part
0075 t = [1 0 0 dx;0 1 0 dy;0 0 1 dz;0 0 0 1];
0076 trans = t * trans / t;

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