function trnsfm_pts = cv_trnsfm6(trnsfm, pts)
%
% cv_trnsfm5 - apply 4x4 transform matrix to set of points/normals
% Call: trnsfrm_pts = cv_trnsfm6(trnsfm,pts);
% On input:
%     trnsfm: 4x4 transform matrix
%     pts:    n by 6 matrix of points (x,y,z,a,b,c)
% On output:
%     trnsfm_pts: transformed points/normals
% Author:
%     Tom Henderson
%     7 January 2000
% Custom Functions Used:
%     none
% Method:
%     make points homogeneous coordinates (add 4th dimensional component equal to 1)
%     then transpose points to be 4xn; then multiply 4x4 times 4xn
% Testing:
% 90 degree rotation around y; translation of [1,2,3]
% > pts
%
% pts =
%
%     0     0     0     0     0     1
%     0     1     0     0     0     1
%     0     0     1     0     0     1
%     1     0     0     0     0     1
%
% > T2 = [0 0 -1 1; 0 1 0 2; 1 0 0 3; 0 0 0 1]
%
% T2 =
%
%     0     0    -1     1
%     0     1     0     2
%     1     0     0     3
%     0     0     0     1
%
% > cv_trnsfm6(T2,pts)
%
% ans =
%
%     1     2     3    -1     0     0
%     1     3     3    -1     0     0
%     0     2     3    -1     0     0
%     1     2     4    -1     0     0
%
% >
[rows, cols] = size(pts);
pts_h = [pts(:,1:3) ones(rows,1)]';   % add homogeneous component
t_pts = (trnsfm*pts_h)';  % transform
t_pts = t_pts(:,1:3);  % strip homogeneous component
norms_h = [pts(:,4:6) ones(rows,1)]'; % add homogeneous component to normals
T = trnsfm;
T(1:3,4) = zeros(3,1);
t_norms = (T*norms_h)'; % transform
t_norms = t_norms(:,1:3);
trnsfm_pts = [t_pts t_norms];
