Skip to content
Snippets Groups Projects
Commit 8ba6eaf5 authored by Laura Nervo's avatar Laura Nervo
Browse files

gtDisorientation : added 'convention' parameter to switch crystal axes...

gtDisorientation : added 'convention' parameter to switch crystal axes convention for hexagonal materials. Better commented the header and indented. Corrected conversion from 3-indexes to 4-indexes with new function.

Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>
parent 676d0224
No related branches found
No related tags found
No related merge requests found
function hkl = gtCrystFourIndexes2Miller(hkil, miller_type)
% GTCRYSTFOURINDEXES2MILLER Converts the Miller-Bravais notation (hkil) to the
% Miller notation
%
% hkl = gtCrystFourIndexes2Miller(hkil, miller_type)
% --------------------------------------------------
% INPUT:
% hkil = <double> plane normal Miller-Bravais indexes (Nx4)
% miller_type = <string> 'plane' / 'direction'
%
% OUTPUT:
% hkl = <double> Miller notation for hexagonal materials
%
% Version 001 22-10-2013 by LNervo
%
% Ref. LaboTex 3.0: Piotr Ozga, "Hexagonal Axes: Conventions & Conversions"
hkl = zeros(size(hkil,1), 3);
switch miller_type
case 'direction'
hkl(:,1) = hkil(:,1) - hkil(:,3);
hkl(:,2) = hkil(:,2) - hkil(:,3);
hkl(:,3) = hkil(:,4);
case 'plane'
hkl(:,1) = hkil(:,1);
hkl(:,2) = hkil(:,2);
hkl(:,3) = hkil(:,4);
end
end % end of function
function [hkil, hkil_int] = gtCrystMiller2FourIndexes(hkl, miller_type)
% GTCRYSTMILLER2FOURINDEXES Converts the Miller notation (hkl) to the
% four indexes Miller-Bravais notation
%
% [hkil, hkil_int] = gtCrystMiller2FourIndexes(hkl, miller_type)
% --------------------------------------------------------------
% INPUT:
% hkl = <double> plane normal Miller indexes (Nx3)
% miller_type = <string> 'plane' / 'direction'
%
% OUTPUT:
% hkil = <double> Miller-Bravais notation for hexagonal
% materials (float allowed)
% hkil_int = <double> Miller-Bravais indexes for hexagonal materials
% as integers
%
% Version 001 22-10-2013 by LNervo
%
% Ref. LaboTex 3.0: Piotr Ozga, "Hexagonal Axes: Conventions & Conversions"
hkil = zeros(size(hkl,1), 4);
switch miller_type
case 'direction'
hkil(:,1) = 2*hkl(:,1) - hkl(:,2);
hkil(:,2) = 2*hkl(:,2) - hkl(:,1);
hkil(:,3) = - (hkl(:,1) + hkl(:,2));
hkil(:,4) = 3*hkl(:,3);
case 'plane'
hkil(:,1) = hkl(:,1);
hkil(:,2) = hkl(:,2);
hkil(:,3) = - (hkl(:,1) + hkl(:,2));
hkil(:,4) = hkl(:,3);
end
if nargout > 1
for ii=1:size(hkil,1)
tmp = hkil(ii,:);
tmp((tmp > 10^-9 & tmp <= 0.1) | tmp == 0)=[];
minimum(ii) = max(min(abs(tmp)), 0);
hkil_int(ii,:) = hkil(ii,:) ./minimum(ii);
hkil_int(ii,:) = fix(hkil_int(ii,:));
end
end
end % end of function
......@@ -2,35 +2,43 @@ function [mis_angle, mis_axis, info] = gtDisorientation(ori1, ori2, symm, vararg
% GTDISORIENTATION Easy function to calculate the disorientation angle and axis
% between two sets of grains
%
% [mis_angle, mis_axis] = gtDisorientation(ori1, ori2, symm, [varargin])
% ----------------------------------------------------------------------
% [mis_angle, mis_axis, info] = gtDisorientation(ori1, ori2, symm, [varargin])
% ----------------------------------------------------------------------------
% INPUT:
% ori1 = <double> Orientations for grains set 1
% ori2 = <double> Orientations for grains set 2
% symm = <struct> Symmetry operators list from gtCrystGetSymmetryOperators
% ori1 = <double> Orientations for grains set 1
% ori2 = <double> Orientations for grains set 2
% symm = <struct> Symmetry operators list from gtCrystGetSymmetryOperators
%
% OPTIONAL INPUT (varargin as a list of pairs, see parse_pv_pairs.m):
% input = <string> Input orientation ({'rod'}, 'orimat', or 'euler')
% rod: input array sized 3xN
% orimat: input array sized 3x3xN
% euler: input array sized 3xN
% mode = <string> Mode of rotation ({'passive'} or 'active')
% sort = <string> Sort disorientation axis components after taking
% absolute values (if empty, do nothing at all)
% ({''}, 'ascend' or 'descend')
% latticepar = <double> Lattice parameters (1x6 for hexagonal crystals)
% input = <string> Input orientation ({'rod'}, 'orimat', or 'euler')
% rod: input array sized 3xN
% orimat: input array sized 3x3xN
% euler: input array sized 3xN
% mode = <string> Mode of rotation ({'passive'} or 'active')
% sort = <string> Sort disorientation axis components after taking
% absolute values (if empty, do nothing at all)
% ({''}, 'ascend' or 'descend')
% latticepar = <double> Lattice parameters (1x6 for hexagonal crystals)
% convention = <string> Convention used for the unit cell {'Y'}/'X' in
% case of hexagonal unit cell
%
% OUTPUT:
% mis_angle = <double> Misorientation angles between the 2 grain sets
% mis_axis = <double> Misorientation axes between the 2 grain sets
% mis_angle = <double> Misorientation angles between the 2 grain sets
% mis_axis = <double> Misorientation axes between the 2 grain sets
% info = <struct> Extra info
%
% Verison 002 24-10-2013 by LNervo, laura.nervo@esrf.fr
% Added argument 'convention'
%
% Version 001 27-06-2013 by YGuilhem, yoann.guilhem@esrf.fr
% Set default parameters and parse input parameters from varargin
par.input = 'rod';
par.mode = 'passive';
par.sort = '';
par.input = 'rod';
par.mode = 'passive';
par.sort = '';
par.latticepar = [];
par.convention = 'X';
par = parse_pv_pairs(par, varargin);
Symm = {symm.g3};
......@@ -87,13 +95,26 @@ if nargout > 1
tmp_info(Ngrain1).symm_i = [];
tmp_info(Ngrain1).symm_j = [];
tmp_info(Ngrain1).netg = [];
for ii = 1:Ngrain1;
gA = g1(:, :, ii);
gB = g2(:, :, ii);
[mis_angle(ii), mis_axis(ii, :), tmp_info(ii)] = calcDisorientation(gA, gB, Symm);
end
if (~isempty(par.latticepar)) && par.latticepar(6) == 120 % it must be hexagonal
mis_axis = gtCart2Hex(mis_axis, par.latticepar);
[mis_angle(ii), mis_axis(ii, :), info] = calcDisorientation(gA, gB, Symm);
tmp_info(ii) = gtAddMatFile(tmp_info(ii), info, true);
tmp_info(ii).mis_angle = mis_angle(ii, :);
tmp_info(ii).mis_axis = mis_axis(ii, :);
if (~isempty(par.latticepar)) && par.latticepar(6) == 120 % it must be hexagonal
mis_axis_hex_cart(ii, 1:4) = gtCart2Hex(mis_axis(ii,:), par.latticepar, par.convention);
tmp_info(ii).mis_axis_hex_cart = mis_axis_hex_cart(ii, :);
if strcmp(par.mode, 'passive')
[mis_axis_hex(ii, :), mis_axis_hex_int(ii, :)] = gtCrystMiller2FourIndexes(mis_axis(ii,:),'direction');
tmp_info(ii).mis_axis_hex_int = mis_axis_hex_int(ii, :);
tmp_info(ii).mis_axis_hex = mis_axis_hex(ii, :);
end
end
end
if nargout > 2
info = tmp_info;
......
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