Newer
Older
Nicola Vigano
committed
function uvtw = gtCart2Hex(UVW, latticepar, convention)
% GTCART2HEX Converts a direction in Cartesian crystal coordinates (UVW) to the
% Miller-Bravais indexes in the direct space (uvtw)
Laura Nervo
committed
%
Nicola Vigano
committed
% uvtw = gtCart2Hex(UVW, latticepar, convention)
Laura Nervo
committed
% ----------------------------------------------
% It follows the X-convention using right handed CS.
Nicola Vigano
committed
% From (UVW) direction in cartesian space to (uvtw) plane normal in hexagonal real space
%
% INPUT:
Nicola Vigano
committed
% UVW = <double> direction in cartesian coordinates (N,3)
Laura Nervo
committed
% latticepar = <double> lattice parameters (row vector 1,6)
% convention = <string> hexagonal unit cell convention {'X'}/'Y'
%
% OUTPUT:
Nicola Vigano
committed
% uvtw = <double> plane normal in hexagonal direct space described by
Laura Nervo
committed
% Miller-Bravais indexes (N,4)
Laura Nervo
committed
% Version 002 25-10-2013 by LNervo
if ~exist('convention','var') || isempty(convention)
convention = 'X';
end
Nicola Vigano
committed
if strcmpi(convention, 'X')
Laura Nervo
committed
% rotates counterclockwise
Nicola Vigano
committed
UVW = rotateVectors(UVW,'angle',30,'axis',[0 0 1]);
Laura Nervo
committed
end
Nicola Vigano
committed
uvtw = zeros(size(UVW,1), 4);
Laura Nervo
committed
% change to hexagonal axes
Nicola Vigano
committed
uvtw(:,1) = UVW(:,1) - (UVW(:,2)/sqrt(3));
uvtw(:,2) = UVW(:,2)*2/sqrt(3);
uvtw(:,3) = -(uvtw(:,1) + uvtw(:,2));
uvtw(:,4) = UVW(:,3);
Laura Nervo
committed
% allow for unit cell parameters
Nicola Vigano
committed
uvtw(:,1:3) = uvtw(:,1:3)*(latticepar(1)*sqrt(3)/2);
uvtw(:,4) = uvtw(:,4)*latticepar(3);
Laura Nervo
committed
end % end of function