COMPOSETRANSFORMS3D Concatenate several space transformations. TRANS = composeTransforms3d(TRANS1, TRANS2, ...); Computes the affine transform equivalent to performing successively TRANS1, TRANS2, ... Example: PTS = rand(20, 3); ROT1 = createRotationOx(pi/3); ROT2 = createRotationOy(pi/4); ROT3 = createRotationOz(pi/5); ROTS = composeTransforms3d(ROT1, ROT2, ROT3); Then: PTS2 = transformPoint3d(PTS, ROTS); will give the same result as: PTS3 = transformPoint3d(transformPoint3d(transformPoint3d(PTS, ... ROT1), ROT2), ROT3); See also: transforms3d, transformPoint3d --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 29/29/2006.
0001 function trans = composeTransforms3d(varargin) 0002 %COMPOSETRANSFORMS3D Concatenate several space transformations. 0003 % 0004 % TRANS = composeTransforms3d(TRANS1, TRANS2, ...); 0005 % Computes the affine transform equivalent to performing successively 0006 % TRANS1, TRANS2, ... 0007 % 0008 % Example: 0009 % PTS = rand(20, 3); 0010 % ROT1 = createRotationOx(pi/3); 0011 % ROT2 = createRotationOy(pi/4); 0012 % ROT3 = createRotationOz(pi/5); 0013 % ROTS = composeTransforms3d(ROT1, ROT2, ROT3); 0014 % Then: 0015 % PTS2 = transformPoint3d(PTS, ROTS); 0016 % will give the same result as: 0017 % PTS3 = transformPoint3d(transformPoint3d(transformPoint3d(PTS, ... 0018 % ROT1), ROT2), ROT3); 0019 % 0020 % See also: 0021 % transforms3d, transformPoint3d 0022 % 0023 % --------- 0024 % 0025 % author : David Legland 0026 % INRA - TPV URPOI - BIA IMASTE 0027 % created the 29/29/2006. 0028 % 0029 0030 trans = varargin{nargin}; 0031 for i=length(varargin)-1:-1:1 0032 trans = trans * varargin{i}; 0033 end