Home > vbmeg > external > iso2mesh > rotatevec3d.m

rotatevec3d

PURPOSE ^

SYNOPSIS ^

function newpt=rotatevec3d(pt,v1,u1,p0)

DESCRIPTION ^

 newpt=rotatevec3d(pt,v1,u1,p0)

 rotate 3D points from one Cartesian coordinate system to another

 author: Qianqian Fang, <q.fang at neu.edu>

 input: 
   pt: 3D points defined in a standard Cartesian system where a unitary
       z-vector is (0,0,1), 3 columns for x, y and z 
   v1: the unitary z-vector for the target coordinate system
   u1: the unitary z-vector for the source coordinate system, if ignored,
       u1=(0,0,1) 
   p0: offset of the new coordinate system, if ignored, p0=(0,0,0)

 output:
   newpt: the transformed 3D points

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function newpt=rotatevec3d(pt,v1,u1,p0)
0002 %
0003 % newpt=rotatevec3d(pt,v1,u1,p0)
0004 %
0005 % rotate 3D points from one Cartesian coordinate system to another
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 %
0009 % input:
0010 %   pt: 3D points defined in a standard Cartesian system where a unitary
0011 %       z-vector is (0,0,1), 3 columns for x, y and z
0012 %   v1: the unitary z-vector for the target coordinate system
0013 %   u1: the unitary z-vector for the source coordinate system, if ignored,
0014 %       u1=(0,0,1)
0015 %   p0: offset of the new coordinate system, if ignored, p0=(0,0,0)
0016 %
0017 % output:
0018 %   newpt: the transformed 3D points
0019 %
0020 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0021 %
0022 
0023 if(nargin<2)
0024     error('you must give at least pt and v1');
0025 end
0026 if(nargin==2)
0027     u1=[0,0,1];
0028 end
0029 if(nargin<=3)
0030     p0=[0,0,0];
0031 end
0032 
0033 u1=u1/norm(u1);
0034 v1=v1/norm(v1);
0035 
0036 [R,s]=rotmat2vec(u1,v1);
0037 newpt=(R*pt'*s)';
0038 
0039 if(nargin>3)
0040   p0=p0(:)';
0041   newpt=newpt+repmat(p0,size(newpt,1),1);
0042 end

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