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