Home > matGeom > geom3d > transformVector3d.m

transformVector3d

PURPOSE ^

TRANSFORMVECTOR3D Transform a vector with a 3D affine transform.

SYNOPSIS ^

function varargout = transformVector3d(varargin)

DESCRIPTION ^

TRANSFORMVECTOR3D Transform a vector with a 3D affine transform.

   V2 = transformVector3d(V1, TRANS);
   Computes the vector obtained by transforming vector V1 with affine
   transform TRANS.
   V1 has the form [x1 y1 z1], and TRANS is a [3x3], [3x4], or [4x4]
   matrix, with one of the forms:
   [a b c]   ,   [a b c j] , or [a b c j]
   [d e f]       [d e f k]      [d e f k]
   [g h i]       [g h i l]      [g h i l]
                                [0 0 0 1]

   V2 = transformVector3d(V1, TRANS) also works when V1 is a [Nx3xMxEtc]
   array of double. In this case, V2 has the same size as V1.

   V2 = transformVector3d(X1, Y1, Z1, TRANS);
   Specifies vectors coordinates in three arrays with same size.

   [X2 Y2 Z2] = transformVector3d(...);
   Returns the coordinates of the transformed vector separately.


   See also:
   vectors3d, transforms3d, transformPoint3d

   ---------
   author : David Legland
   INRA - TPV URPOI - BIA IMASTE
   created the 25/11/2008 from transformPoint3d

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = transformVector3d(varargin)
0002 %TRANSFORMVECTOR3D Transform a vector with a 3D affine transform.
0003 %
0004 %   V2 = transformVector3d(V1, TRANS);
0005 %   Computes the vector obtained by transforming vector V1 with affine
0006 %   transform TRANS.
0007 %   V1 has the form [x1 y1 z1], and TRANS is a [3x3], [3x4], or [4x4]
0008 %   matrix, with one of the forms:
0009 %   [a b c]   ,   [a b c j] , or [a b c j]
0010 %   [d e f]       [d e f k]      [d e f k]
0011 %   [g h i]       [g h i l]      [g h i l]
0012 %                                [0 0 0 1]
0013 %
0014 %   V2 = transformVector3d(V1, TRANS) also works when V1 is a [Nx3xMxEtc]
0015 %   array of double. In this case, V2 has the same size as V1.
0016 %
0017 %   V2 = transformVector3d(X1, Y1, Z1, TRANS);
0018 %   Specifies vectors coordinates in three arrays with same size.
0019 %
0020 %   [X2 Y2 Z2] = transformVector3d(...);
0021 %   Returns the coordinates of the transformed vector separately.
0022 %
0023 %
0024 %   See also:
0025 %   vectors3d, transforms3d, transformPoint3d
0026 %
0027 %   ---------
0028 %   author : David Legland
0029 %   INRA - TPV URPOI - BIA IMASTE
0030 %   created the 25/11/2008 from transformPoint3d
0031 %
0032 
0033 if nargin~=2 && nargin~=4
0034     error('Invalid number of input arguments. Type ''help transformVector3d'' for details.');
0035 end
0036 
0037 % Extract only the linear part of the affine transform
0038 trans = varargin{end};
0039 trans(1:4,4) = [0; 0; 0; 1];
0040 
0041 % Call transformPoint3d using equivalent output arguments
0042 varargout = cell(1, max(1,nargout));
0043 [varargout{:}] = transformPoint3d(varargin{1:end-1}, trans);

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