Skip to content
Snippets Groups Projects
Commit e2ecdea8 authored by Laura Nervo's avatar Laura Nervo Committed by Nicola Vigano
Browse files

Conversion from hexagonal to orthogonal system and viceversa: created...

Conversion from hexagonal to orthogonal system and viceversa: created gtHex2Cart and moved gtCart2Hex into zUtil_Cryst folder.

Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@969 4c865b51-4357-4376-afb4-474e03ccb993
parent a373e365
No related branches found
No related tags found
No related merge requests found
function hkil = gtCart2Hex(hkl)
% GTCART2HEX Convert a plane normal in cartesian coordinates (hkl)
% hkil = gtCart2Hex(hkl)
% ----------------------
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 indexes
% hkl = plane normal Miller indexes <double Nx3>
% latticepar = lattice parameters <double 1x6>
%
% OUTPUT:
% hkil = cartesian coordinates for hexagonal materials
......@@ -12,16 +15,11 @@ function hkil = gtCart2Hex(hkl)
% *** update version ***
%
% Version 001 June-2008 by AKing
% Four index hexagonal coordinatesa are given
% 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.
load('parameters.mat')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% cart to hex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hkil=zeros(size(hkl,1), 4);
%change to hexagonal axes
......@@ -31,27 +29,7 @@ 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
hkil(:,1:3) = hkil(:,1:3)*(latticepar(1)*sqrt(3))/2;
hkil(:,4) = hkil(:,4)*latticepar(3);
end % end function
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment