Home > vbmeg > functions > common > coordinate > vb_affine_trans.m

vb_affine_trans

PURPOSE ^

Apply affine transformation to 'X'

SYNOPSIS ^

function Xout = vb_affine_trans(X, trans_mat, nflag)

DESCRIPTION ^

 Apply affine transformation to 'X'
  Xout = vb_affine_trans(X, trans_mat, nflag)
 --- Input
 X         : 3D-coordinate to be transformed (Nx3 vector)
 trans_mat : affine transformation matrix (4 x 3 or 4 x 4)
      Xout = [X 1] * trans_mat(:,1:3)
 nflag = 1 : X is normal vector and only rotation is applied
 --- Output
 Xout     : transformed coordinate   (Nx3 vector)
 Xout = [X  1]*trans_mat(:,1:3);

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function Xout = vb_affine_trans(X, trans_mat, nflag)
0002 % Apply affine transformation to 'X'
0003 %  Xout = vb_affine_trans(X, trans_mat, nflag)
0004 % --- Input
0005 % X         : 3D-coordinate to be transformed (Nx3 vector)
0006 % trans_mat : affine transformation matrix (4 x 3 or 4 x 4)
0007 %      Xout = [X 1] * trans_mat(:,1:3)
0008 % nflag = 1 : X is normal vector and only rotation is applied
0009 % --- Output
0010 % Xout     : transformed coordinate   (Nx3 vector)
0011 % Xout = [X  1]*trans_mat(:,1:3);
0012 %
0013 % Copyright (C) 2011, ATR All Rights Reserved.
0014 % License : New BSD License(see VBMEG_LICENSE.txt)
0015 
0016 if nargin < 3, nflag = 0; end;
0017 
0018 switch    nflag
0019 case    0
0020     Xout = [X  ones(size(X,1),1)]*trans_mat(:,1:3);
0021 case    1
0022     Xout = X*trans_mat(1:3,1:3);
0023 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005