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

Fix use of gtCrystHKL2CartesianMatrix


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

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@874 4c865b51-4357-4376-afb4-474e03ccb993
parent b1bcd9a3
No related branches found
No related tags found
No related merge requests found
function [Bmat, Amat] = gtCrystHKL2CartesianMatrix(lp)
%
% FUNCTION Bmat = gtCrystHKL2CartesianMatrix(lp)
% [Bmat, Amat] = gtCrystHKL2CartesianMatrix(lp)
% ---------------------------------------------
% Returns a 3x3 matrix that can be used for coordinate transform from
% a signed HKL into a Cartesian vector in real space and for any lattice
% and unit cell.
%
% Returns a 3x3 matrix that can be used for coordinate transform from
% a signed HKL into a Cartesian vector in real space and for any lattice
% and unit cell.
%
% The Cartesian (orthogonal) basis (X,Y,Z) is defined such that:
% - lattice vectors of the unit cell are a1, a2, a3 (not orthogonal)
% - X is parallel with a1
% - Y lies in the a1-a2 plane
% - Z is cross(X,Y)
% The Cartesian (orthogonal) basis (X,Y,Z) is defined such that:
% - lattice vectors of the unit cell are a1, a2, a3 (not orthogonal)
% - X is parallel with a1
% - Y lies in the a1-a2 plane
% - Z is cross(X,Y)
%
% The definition corresponds to the one in Poulsen's 3DRXRD book, Chapter
% 3. This function essentially computes the B matrix in the equation
% Gc = B*Ghkl (used with column vectors!)
%
% INPUT lp - unit cell lattice parameters in real space
% [a b c alpha beta gamma] (angles are in degrees)
% The definition corresponds to the one in Poulsen's 3DRXRD book, Chapter
% 3. This function essentially computes the B matrix in the equation
% Gc = B*Ghkl (used with column vectors!)
%
% OUTPUT Bmat - the transformation matrix for column vectors (!)
% INPUT:
% lp = unit cell lattice parameters in real space
% [a b c alpha beta gamma] (angles are in degrees)
%
% mod Andy - return the A matrix too (real space) for dealing with UVW
% lattice directions.
% OUTPUT:
% Bmat = the transformation matrix for column vectors (!)
% Amat = the A matrix too (real space) for dealing with UVW
% lattice directions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Lattice vectors in real space, in a Cartesian basis
......@@ -42,6 +43,11 @@ z3 = sqrt(lp(3)^2 - x3^2 - y3^2);
% Assemble 'a3'
a3 = [x3 y3 z3];
% Volume of spanned by 'a'-s (determinant of matrix of a-s)
crossa2a3 = [a2(2)*a3(3)-a2(3)*a3(2); a2(3)*a3(1)-a2(1)*a3(3); a2(1)*a3(2)-a2(2)*a3(1)];
avol = a1*crossa2a3;
% for output
Amat=[a1 a2 a3];
......@@ -53,9 +59,7 @@ Amat=[a1 a2 a3];
% b2 = cross(a3,a1)/avol
% b3 = cross(a1,a2)/avol
% Volume of spanned by 'a'-s (determinant of matrix of a-s)
crossa2a3 = [a2(2)*a3(3)-a2(3)*a3(2); a2(3)*a3(1)-a2(1)*a3(3); a2(1)*a3(2)-a2(2)*a3(1)];
avol = a1*crossa2a3;
b1 = crossa2a3/avol;
b2 = [a3(2)*a1(3)-a3(3)*a1(2); a3(3)*a1(1)-a3(1)*a1(3); a3(1)*a1(2)-a3(2)*a1(1)]/avol;
......
......@@ -65,7 +65,7 @@ elseif spacegroup==194 % hexagonal case
% UVW direction)
% Miller notation for directions <UVW>
Amat = gtCrystUVW2CartesianMatrix(lp);
[~,Amat] = gtCrystHKL2CartesianMatrix(lp);
for ii=1:size(twin_axis, 1)
twin_axis_cart(ii, :) = Amat*twin_axis(ii, :)';
......
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