Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
graintracking
DCT
Commits
5a0504a1
Commit
5a0504a1
authored
11 years ago
by
Laura Nervo
Browse files
Options
Downloads
Patches
Plain Diff
gtHex2Cart / gtCart2Hex : added option to change convention for hexagonal materials
Signed-off-by:
Laura Nervo
<
laura.nervo@esrf.fr
>
parent
7559bc0e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
zUtil_Cryst/gtCart2Hex.m
+32
-24
32 additions, 24 deletions
zUtil_Cryst/gtCart2Hex.m
zUtil_Cryst/gtHex2Cart.m
+36
-15
36 additions, 15 deletions
zUtil_Cryst/gtHex2Cart.m
with
68 additions
and
39 deletions
zUtil_Cryst/gtCart2Hex.m
+
32
−
24
View file @
5a0504a1
function
hkil
=
gtCart2Hex
(
hkl
,
latticepar
)
% GTCART2HEX Convert a plane normal in cartesian coordinates (hkl) to the four
% indexes
function
hkil
=
gtCart2Hex
(
uvw
,
latticepar
,
convention
)
% GTCART2HEX Converts a plane normal in cartesian coordinates (uvw) to the
% Miller-Bravais indexes in the direct space (hkil)
%
% hkil = gtCart2Hex(uvw, latticepar, convention)
% ----------------------------------------------
% It follows the X-convention using right handed CS.
% From (uvw) direction in cartesian space to (hkil) plane normal in hexagonal real space
%
% hkil = gtCart2Hex(hkl, latticepar)
% ----------------------------------
% INPUT:
% hkl = plane normal Miller indexes <double Nx3>
% latticepar = lattice parameters <double 1x6>
% uvw = <double> plane normal in cartesian coordinates (N,3)
% latticepar = <double> lattice parameters (row vector 1,6)
% convention = <string> hexagonal unit cell convention {'X'}/'Y'
%
% OUTPUT:
% hkil = cartesian coordinates for hexagonal materials
%
% Version 002 25-11-2011 by LNervo
% *** update version ***
% hkil = <double> plane normal in hexagonal direct space described by
% Miller-Bravais indexes (N,4)
%
% Version 001 June-2008 by AKing
% 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.
% Version 002 25-10-2013 by LNervo
if
~
exist
(
'convention'
,
'var'
)
||
isempty
(
convention
)
convention
=
'X'
;
end
if
strcmp
(
convention
,
'X'
)
% rotates counterclockwise
uvw
=
rotateVectors
(
uvw
,
'angle'
,
30
,
'axis'
,[
0
0
1
]);
end
hkil
=
zeros
(
size
(
hkl
,
1
),
4
);
hkil
=
zeros
(
size
(
uvw
,
1
),
4
);
%change to hexagonal axes
hkil
(:,
1
)
=
hkl
(:,
1
)
-
(
hkl
(:,
2
)/
sqrt
(
3
))
;
hkil
(:,
2
)
=
hkl
(:,
2
)
*
2
/
sqrt
(
3
)
;
hkil
(:,
3
)
=
-
(
hkil
(:,
1
)
+
hkil
(:,
2
));
hkil
(:,
4
)
=
hkl
(:,
3
);
%
change to hexagonal axes
hkil
(:,
1
)
=
uvw
(:,
1
)
*
sqrt
(
3
)/
2
-
uvw
(:,
2
)/
2
;
hkil
(:,
2
)
=
uvw
(:,
2
);
hkil
(:,
3
)
=
-
(
hkil
(:,
1
)
+
hkil
(:,
2
));
hkil
(:,
4
)
=
uvw
(:,
3
);
%allow for unit cell parameters
hkil
(:,
1
:
3
)
=
hkil
(:,
1
:
3
)
*
(
latticepar
(
1
)
*
sqrt
(
3
))/
2
;
%
allow for unit cell parameters
hkil
(:,
1
:
3
)
=
hkil
(:,
1
:
3
)
*
latticepar
(
1
);
hkil
(:,
4
)
=
hkil
(:,
4
)
*
latticepar
(
3
);
end
% end function
end
% end
of
function
This diff is collapsed.
Click to expand it.
zUtil_Cryst/gtHex2Cart.m
+
36
−
15
View file @
5a0504a1
function
normalised_hkls
=
gtHex2Cart
(
all_hkils
,
latticepar
)
% GTHEX2CART
% normalised_hkls = gtHex2Cart(all_hkils, latticepar)
% ---------------------------------------------------
% Transforms from direct hexagonal to cartesian coordinates
% and normalise
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
%
% Same as the old function gtCrystHKL2Cart
% 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
if
~
exist
(
'convention'
,
'var'
)
||
isempty
(
convention
)
convention
=
'X'
;
end
% going to cartesian reciprocal space + normalisation of the cartesian
% space
all_hkls
(:,
1
)
=
all_
hkil
s
(:,
1
)
+
0.5
*
all_
hkil
s
(:,
2
);
all_hkls
(:,
2
)
=
sqrt
(
3
)/
2
*
all_
hkil
s
(:,
2
);
all_hkls
(:,
3
)
=
all_
hkil
s
(:,
4
);
uvw
(:,
1
)
=
hkil
(:,
1
)
*
2
/
sqrt
(
3
)
+
hkil
(:,
2
)/
sqrt
(
3
);
uvw
(:,
2
)
=
hkil
(:,
2
);
uvw
(:,
3
)
=
hkil
(:,
4
);
all_hkls
(:,
1
)
=
all_hkls
(:,
1
)
*
2
/(
sqrt
(
3
)
*
latticepar
(
1
));
all_hkls
(:,
2
)
=
all_hkls
(:,
2
)
*
2
/(
sqrt
(
3
)
*
latticepar
(
1
));
all_hkls
(:,
3
)
=
all_hkls
(:,
3
)/
latticepar
(
3
);
%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
tmp
=
sqrt
(
sum
((
all_hkls
.*
all_hkls
),
2
));
normalised_hkls
=
all_hkls
.
/(
repmat
(
tmp
,
1
,
3
));
tmp
=
sqrt
(
sum
((
uvw
.*
uvw
),
2
));
uvw
=
uvw
.
/(
repmat
(
tmp
,
1
,
3
));
if
strcmp
(
convention
,
'X'
)
% rotates counterclockwise
uvw
=
rotateVectors
(
uvw
,
'angle'
,
30
,
'axis'
,[
0
0
1
]);
end
end
% end of function
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment