Home > matGeom > geom3d > recenterTransform3d.m

recenterTransform3d

PURPOSE ^

RECENTERTRANSFORM3D Change the fixed point of an affine 3D transform.

SYNOPSIS ^

function res = recenterTransform3d(transfo, center)

DESCRIPTION ^

RECENTERTRANSFORM3D Change the fixed point of an affine 3D transform.

   TRANSFO2 = recenterTransform3d(TRANSFO, CENTER)
   where TRANSFO is a 4x4 transformation matrix, and CENTER is a 1x3 row
   vector, computes the new transformations that uses the same linear part
   (defined by the upper-left 3x3 corner of the transformation matrix) as
   the initial transform, and that will leave the point CENTER unchanged.

   

   Example
   % creating a re-centered rotation using:   
   rot1 = createRotationOx(pi/3);
   rot2 = recenterTransform3d(rot1, [3 4 5]);
   % will give the same result as:
   rot3 = createRotationOx([3 4 5], pi/3);
   

   See also
   transforms3d, createRotationOx, createRotationOy, createRotationOz
   createTranslation3d

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2010-07-27,    using Matlab 7.9.0.529 (R2009b)
 Copyright 2010 INRA - Cepia Software Platform.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function res = recenterTransform3d(transfo, center)
0002 %RECENTERTRANSFORM3D Change the fixed point of an affine 3D transform.
0003 %
0004 %   TRANSFO2 = recenterTransform3d(TRANSFO, CENTER)
0005 %   where TRANSFO is a 4x4 transformation matrix, and CENTER is a 1x3 row
0006 %   vector, computes the new transformations that uses the same linear part
0007 %   (defined by the upper-left 3x3 corner of the transformation matrix) as
0008 %   the initial transform, and that will leave the point CENTER unchanged.
0009 %
0010 %
0011 %
0012 %   Example
0013 %   % creating a re-centered rotation using:
0014 %   rot1 = createRotationOx(pi/3);
0015 %   rot2 = recenterTransform3d(rot1, [3 4 5]);
0016 %   % will give the same result as:
0017 %   rot3 = createRotationOx([3 4 5], pi/3);
0018 %
0019 %
0020 %   See also
0021 %   transforms3d, createRotationOx, createRotationOy, createRotationOz
0022 %   createTranslation3d
0023 %
0024 % ------
0025 % Author: David Legland
0026 % e-mail: david.legland@grignon.inra.fr
0027 % Created: 2010-07-27,    using Matlab 7.9.0.529 (R2009b)
0028 % Copyright 2010 INRA - Cepia Software Platform.
0029 
0030 % remove former translation part
0031 res = eye(4);
0032 res(1:3, 1:3) = transfo(1:3, 1:3);
0033 
0034 % create translations
0035 t1 = createTranslation3d(-center);
0036 t2 = createTranslation3d(center);
0037 
0038 % compute translated transform
0039 res = t2*res*t1;

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