Newer
Older
Laura Nervo
committed
function uvw = gtHex2Cart(hkil, latticepar, convention)
% GTHEX2CART Converts a plane normal in direct hexagonal space described by
% Miller-Bravais indexes (hkil) to the cartesian coordinates in the
% real space (uvw) normalising it
% uvw = gtHex2Cart(hkil, latticepar, convention)
% ----------------------------------------------
% It follows the X-convention using right handed CS
% From (hkil) plane normal in real space to (uvw) direction in cartesian space
Laura Nervo
committed
% INPUT:
% hkil = <double> Miller-Bravais indexes (N,4)
% latticepar = <double> Lattice parameters (1,6)
% convention = <string> hexagonal unit cell convention {'X'}/'Y'
%
% OUTPUT:
% uvw = <double> Direction of plane normal in the cartesian
% normalised space (N,3)
%
% Version 002 25-10-2013 by LNervo
Laura Nervo
committed
if ~exist('convention','var') || isempty(convention)
convention = 'X';
end
% going to cartesian reciprocal space + normalisation of the cartesian
% space
Laura Nervo
committed
uvw(:,1) = hkil(:,1)*2/sqrt(3) + hkil(:,2)/sqrt(3);
uvw(:,2) = hkil(:,2);
uvw(:,3) = hkil(:,4);
Laura Nervo
committed
%scale with unit cell parameters
uvw(:,1) = uvw(:,1)/latticepar(1);
uvw(:,2) = uvw(:,2)/latticepar(1);
uvw(:,3) = uvw(:,3)/latticepar(3);
% normalise hkls vector
Laura Nervo
committed
tmp = sqrt(sum((uvw.*uvw),2));
uvw = uvw./(repmat(tmp,1,3));
Laura Nervo
committed
if strcmp(convention, 'X')
% rotates counterclockwise
uvw = rotateVectors(uvw,'angle',30,'axis',[0 0 1]);
end
Laura Nervo
committed
end % end of function