diff --git a/4_grains/gtCart2Hex.m b/4_grains/gtCart2Hex.m deleted file mode 100644 index 905da62702540f3ea0df005d1161cc4939925a74..0000000000000000000000000000000000000000 --- a/4_grains/gtCart2Hex.m +++ /dev/null @@ -1,57 +0,0 @@ -function hkil = gtCart2Hex(hkl) -% GTCART2HEX Convert a plane normal in cartesian coordinates (hkl) -% hkil = gtCart2Hex(hkl) -% ---------------------- -% INPUT: -% hkl = plane normal indexes -% -% OUTPUT: -% hkil = cartesian coordinates for hexagonal materials -% -% Version 002 25-11-2011 by LNervo -% *** update version *** -% -% Version 001 June-2008 by AKing -% Four index hexagonal coordinatesa are given -% reverse of the formulae implemented by Sabine in gtForwardSimulate_360 -% the output {hkil} is not normalised in any way. - - -load('parameters.mat') - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% cart to hex -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -hkil=zeros(size(hkl,1), 4); - -%change to hexagonal axes -hkil(:,1) = hkl(:,1) - (hkl(:,2)/sqrt(3)); -hkil(:,2) = hkl(:,2)*2/sqrt(3); -hkil(:,3) = -(hkil(:,1)+hkil(:,2)); -hkil(:,4) = hkl(:,3); - -%allow for unit cell parameters -hkil(:,1:3) = hkil(:,1:3)*(parameters.cryst.latticepar(1)*sqrt(3))/2; -hkil(:,4) = hkil(:,4)*parameters.cryst.latticepar(3); - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% hex to orthogonal -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% i=1 -% hkil=[1 1 -2 1] -% -% for i=1:8 -% hkl(i,1)= hkil(i,1) + 0.5 * hkil(i,2); -% hkl(i,2)= 3^0.5/2 *hkil(i,2); -% hkl(i,3)= hkil(i,4); -% -% hkl(i,1)=hkl(i,1)*2/(sqrt(3)*parameters.cryst.latticepar(1)); -% hkl(i,2)=hkl(i,2)*2/(sqrt(3)*parameters.cryst.latticepar(1)); -% hkl(i,3)=hkl(i,3)/parameters.cryst.latticepar(3); -% -% %normalise -% tmp = sqrt(sum((hkl.*hkl),2)); -% hkl = hkl./(repmat(tmp,1,3)) -% end - -end % end function diff --git a/zUtil_Cryst/gtCart2Hex.m b/zUtil_Cryst/gtCart2Hex.m new file mode 100644 index 0000000000000000000000000000000000000000..64b8ca1284c5c97bd274b3d6891f87794cf14563 --- /dev/null +++ b/zUtil_Cryst/gtCart2Hex.m @@ -0,0 +1,35 @@ +function hkil = gtCart2Hex(hkl, latticepar) +% GTCART2HEX Convert a plane normal in cartesian coordinates (hkl) to the four +% indexes +% +% hkil = gtCart2Hex(hkl, latticepar) +% ---------------------------------- +% INPUT: +% hkl = plane normal Miller indexes <double Nx3> +% latticepar = lattice parameters <double 1x6> +% +% OUTPUT: +% hkil = cartesian coordinates for hexagonal materials +% +% Version 002 25-11-2011 by LNervo +% *** update version *** +% +% Version 001 June-2008 by AKing +% Four index hexagonal coordinates are given! +% reverse of the formulae implemented by Sabine in gtForwardSimulate_360 +% the output {hkil} is not normalised in any way. + + +hkil=zeros(size(hkl,1), 4); + +%change to hexagonal axes +hkil(:,1) = hkl(:,1) - (hkl(:,2)/sqrt(3)); +hkil(:,2) = hkl(:,2)*2/sqrt(3); +hkil(:,3) = -(hkil(:,1)+hkil(:,2)); +hkil(:,4) = hkl(:,3); + +%allow for unit cell parameters +hkil(:,1:3) = hkil(:,1:3)*(latticepar(1)*sqrt(3))/2; +hkil(:,4) = hkil(:,4)*latticepar(3); + +end % end function diff --git a/zUtil_Cryst/gtHex2Cart.m b/zUtil_Cryst/gtHex2Cart.m new file mode 100644 index 0000000000000000000000000000000000000000..bb79b48eb534ac30f803ccc2cba369aa09f0bea6 --- /dev/null +++ b/zUtil_Cryst/gtHex2Cart.m @@ -0,0 +1,27 @@ +function cartesian = gtHex2Cart(hkil, latticepar) +% GTHEX2CART +% cartesian = gtHex2Cart(hkil, latticepar) +% ---------------------------------------- +% Transforms from direct hexagonal to cartesian coordinates +% and normalise +% +% Same as the old function gtCrystHKL2Cart + + +for i=1:size(hkil,1) + cartesian(i,1) = hkil(i,1) + 0.5 * hkil(i,2); + cartesian(i,2) = 3^0.5/2 *hkil(i,2); + cartesian(i,3) = hkil(i,4); + + % allow lattice parameters + cartesian(i,1) = cartesian(i,1)*2/(sqrt(3)*latticepar(1)); + cartesian(i,2) = cartesian(i,2)*2/(sqrt(3)*latticepar(1)); + cartesian(i,3) = cartesian(i,3)/latticepar(3); +end + + +% normalise +tmp = sqrt(sum((cartesian.*cartesian),2)); +cartesian = cartesian./(repmat(tmp,1,3)); + +end