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

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 % E-mail: david.legland@inrae.fr
0021 % Created: 2004-04-06
0022 % Copyright 2004-2024 INRA - TPV URPOI - BIA IMASTE
0023 
0024 % process input arguments
0025 if isempty(varargin)
0026     tx = 0;
0027     ty = 0;
0028 elseif isscalar(varargin)
0029     var = varargin{1};
0030     tx = var(1);
0031     ty = var(2);
0032 else
0033     tx = varargin{1};
0034     ty = varargin{2};
0035 end
0036 
0037 % create the matrix representing the translation
0038 trans = [1 0 tx ; 0 1 ty ; 0 0 1];

Generated on Thu 21-Nov-2024 11:30:22 by m2html © 2003-2022