Home > matGeom > geom2d > createTranslation.m

createTranslation

PURPOSE ^

CREATETRANSLATION Create the 3*3 matrix of a translation.

SYNOPSIS ^

function trans = createTranslation(varargin)

DESCRIPTION ^

CREATETRANSLATION Create the 3*3 matrix of a translation.

   TRANS = createTranslation(DX, DY);
   Returns the translation corresponding to DX and DY.
   The returned matrix has the form :
   [1 0 TX]
   [0 1 TY]
   [0 0  1]

   TRANS = createTranslation(VECTOR);
   Returns the matrix corresponding to a translation by the vector [x y].


   See also:
   transforms2d, transformPoint, createRotation, createScaling

   ---------
   author : David Legland
   INRA - TPV URPOI - BIA IMASTE
   created the 06/04/2004.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function trans = createTranslation(varargin)
0002 %CREATETRANSLATION Create the 3*3 matrix of a translation.
0003 %
0004 %   TRANS = createTranslation(DX, DY);
0005 %   Returns the translation corresponding to DX and DY.
0006 %   The returned matrix has the form :
0007 %   [1 0 TX]
0008 %   [0 1 TY]
0009 %   [0 0  1]
0010 %
0011 %   TRANS = createTranslation(VECTOR);
0012 %   Returns the matrix corresponding to a translation by the vector [x y].
0013 %
0014 %
0015 %   See also:
0016 %   transforms2d, transformPoint, createRotation, createScaling
0017 %
0018 %   ---------
0019 %   author : David Legland
0020 %   INRA - TPV URPOI - BIA IMASTE
0021 %   created the 06/04/2004.
0022 %
0023 
0024 %   HISTORY
0025 %   22/04/2009: rename as createTranslation
0026 
0027 % process input arguments
0028 if isempty(varargin)
0029     tx = 0;
0030     ty = 0;
0031 elseif length(varargin)==1
0032     var = varargin{1};
0033     tx = var(1);
0034     ty = var(2);
0035 else
0036     tx = varargin{1};
0037     ty = varargin{2};
0038 end
0039 
0040 % create the matrix representing the translation
0041 trans = [1 0 tx ; 0 1 ty ; 0 0 1];

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