function [T_21,i,j,k,G1,G2,S_12,cos_a,cos_b,cos_c] = transformace12(XYZ)
%transformace ze souradneho systemu 1 do 2

%souradnice O2 v systemu 1
r1_02=XYZ(1,:);
[r1_02_x,r1_02_y,r1_02_z] = get_xryrzr(r1_02);

% souradnice A v systemu 1
  r1_A=XYZ(2,:);
 [r1_A_x,r1_A_y,r1_A_z] = get_xryrzr(r1_A);
% souradnice B v systemu 1
  r1_B=XYZ(3,:);
 [r1_B_x,r1_B_y,r1_B_z] = get_xryrzr(r1_B);

%vektory 02,A,B v systému 1
r1_02=[r1_02_x,r1_02_y,r1_02_z];
r1_A=[r1_A_x,r1_A_y,r1_A_z];
r1_B=[r1_B_x,r1_B_y,r1_B_z];

%vektory A,B,i,j,k v systému 2
r2_A=r1_A-r1_02;
r2_B=r1_B-r1_02;

i=r2_A/norm(r2_A);
i_B=r2_B/norm(r2_B);
%vekt.soucin i, i_B
k_spatnvel=cross(i,i_B);
k=k_spatnvel/norm(k_spatnvel);
%vekt.soucin i, k
j=cross(k,i);

%transformacni matice

S_12=[i',j',k'];
S_21=S_12';
nul_vekt=[0,0,0,1];

ref_vekt=[0 0 1];

cos_a=ref_vekt*i';
cos_b=ref_vekt*j';
cos_c=ref_vekt*k';




T_12=[S_12,r1_02';nul_vekt];
T_21=inv(T_12);

%prevod vektoru z 1 do 2

g1=XYZ(4,:);
g2=XYZ(5,:);

a1=[g1,1];
a2=[g2,1];

A1=T_21*a1';
A2=T_21*a2';

G1=[A1(1) A1(2) A1(3)];
G2=[A2(1) A2(2) A2(3)];


end

