-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneighborMisOrs.m
52 lines (37 loc) · 1.25 KB
/
neighborMisOrs.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function [misXTAL,misSPEC] = neighborMisOrs(ebsd)
%% neighbor misorientations per orientation
% compute all adjacent measurements
[~,~,I_FD] = spatialDec([ebsd.prop.x(:), ebsd.prop.y(:)],ebsd.unitCell,'unitCell');
A_D = I_FD.' * I_FD;
% order
n = 2;
A_D1 = A_D;
for i = 1:n-1
A_D = A_D + A_D*A_D1 + A_D1*A_D;
end
clear A_D1
% extract adjacent pairs
[Dl, Dr] = find(A_D);
% take only ordered pairs of same, indexed phase
use = Dl > Dr & ebsd.phaseId(Dl) == ebsd.phaseId(Dr) & ebsd.isIndexed(Dl);
Dl = Dl(use); Dr = Dr(use);
phaseId = ebsd.phaseId(Dl);
% calculate misorientation angles and axes
misXTAL = struct();
misSPEC = struct();
axPhase = struct();
omegaPhase = struct();
% iterate all phases
for p=1:numel(ebsd.phaseMap)
currentPhase = phaseId == p;
if any(currentPhase)
o_Dl = orientation(ebsd.rotations(Dl(currentPhase)),ebsd.CSList{p});
o_Dr = orientation(ebsd.rotations(Dr(currentPhase)),ebsd.CSList{p});
phase = ebsd(Dl(currentPhase)).mineral;
% misorientations in crystal coordinates
misXTAL.(phase) = o_Dl.\o_Dr;
% misorientations in specimen coordinates
misSPEC.(phase) = orientation('axis',axis(o_Dl,o_Dr),'angle',angle(o_Dl,o_Dr));
end
end
end