disp(' ');
disp(' coordinate_transformation_3D.m ');
disp(' ver 1.0  March 3, 2010 ');
disp(' by Tom Irvine ');
disp(' ');
%
clear p;
clear vect;
clear tm_ol;
clear ncoord;
%
disp(' Enter vector which represent the local X-axis in the global system. ');
disp(' This must be a vector with three numbers. ');
vect=input(' ')
x=vect(1);
y=vect(2);
z=vect(3);
%
omega_j=atan2(y,x);
omega_k=atan2(z,(sqrt(x^2+y^2)));
omega_l=0;
%
omega_k=-omega_k;
%
cos_omega_j=cos(omega_j);
sin_omega_j=sin(omega_j);
%
cos_omega_k=cos(omega_k);
sin_omega_k=sin(omega_k);
%
cos_omega_l=cos(omega_l);
sin_omega_l=sin(omega_l);
%
omega_oj(1,:)=[cos_omega_j  -sin_omega_j   0]; 
omega_oj(2,:)=[sin_omega_j   cos_omega_j   0]; 
omega_oj(3,:)=[     0            0         1]; 
%
omega_jk(1,:)=[cos_omega_k   0  sin_omega_k ];
omega_jk(2,:)=[        0     1       0      ];
omega_jk(3,:)=[-sin_omega_k  0  cos_omega_k];
%
omega_kl(1,:)=[1        0           0       ];
omega_kl(2,:)=[0   cos_omega_l  -sin_omega_l];
omega_kl(3,:)=[0   sin_omega_l   cos_omega_l];
%
tm_ol=omega_oj*omega_jk*omega_kl;
%
disp(' Transformation matrix ');
tm_ol
disp(' Input coordinates in local system to conver to global system. ');
disp(' This must be a vector with three numbers. ');
p=input(' ')
sz=size(p);
if(sz(2)>sz(1))
    p=p';
end
ncoord=tm_ol*p;
disp(' New Coordinate in Global System ');
out1=sprintf(' [%g %g %g]',ncoord(1),ncoord(2),ncoord(3));
disp(out1);