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
59cf80d3
Commit
59cf80d3
authored
11 years ago
by
Yoann Guilhem
Committed by
Nicola Vigano
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix for gtCrystVector2SST
Signed-off-by:
Yoann Guilhem
<
yoann.guilhem@esrf.fr
>
parent
b183ae48
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
zUtil_Cryst/gtCrystVector2SST.m
+19
-16
19 additions, 16 deletions
zUtil_Cryst/gtCrystVector2SST.m
zUtil_Cryst/gtVectorCryst2Lab.m
+38
-20
38 additions, 20 deletions
zUtil_Cryst/gtVectorCryst2Lab.m
zUtil_Cryst/gtVectorLab2Cryst.m
+38
-20
38 additions, 20 deletions
zUtil_Cryst/gtVectorLab2Cryst.m
with
95 additions
and
56 deletions
zUtil_Cryst/gtCrystVector2SST.m
+
19
−
16
View file @
59cf80d3
...
...
@@ -38,11 +38,12 @@ function [rgb, Vsst, Vsst_p, Vc_symm] = gtCrystVector2SST(Vc, crystal_system, sy
symm
=
cat
(
3
,
symm
,
-
symm
);
% Here we want to do a vectorized call to get Vc_symm = symm * Vc
Vc_symm
=
gtVectorLab2Cryst
(
Vc
,
symm
);
% It is simportant to get symmetry operator index as first index
Vc_symm
=
gtVectorLab2Cryst
(
Vc
,
symm
,
[
2
3
1
]);
x
=
Vc_symm
(:,
1
,
:
);
y
=
Vc_symm
(:,
2
,
:
);
z
=
Vc_symm
(:,
3
,
:
);
x
=
Vc_symm
(:,
:
,
1
);
y
=
Vc_symm
(:,
:
,
2
);
z
=
Vc_symm
(:,
:
,
3
);
% Define angles
...
...
@@ -82,7 +83,7 @@ function [rgb, Vsst, Vsst_p, Vc_symm] = gtCrystVector2SST(Vc, crystal_system, sy
% Pick equiv that is in our triangle
iSST
=
anglesR
>=
minAngleR
&
anglesR
<
maxAngleR
&
anglesB
>=
minAngleB
&
anglesB
<
maxAngleB
;
ok
=
squeeze
(
sum
(
iSST
,
3
));
ok
=
squeeze
(
sum
(
iSST
,
1
));
ok_no
=
(
ok
==
0
);
ok_too
=
(
ok
>
1
);
...
...
@@ -93,9 +94,9 @@ function [rgb, Vsst, Vsst_p, Vc_symm] = gtCrystVector2SST(Vc, crystal_system, sy
disp
(
find
(
ok_no
));
disp
(
' vectors:'
);
disp
(
Vc
(
ok_no
,
:));
iSST
(
ok_no
,
:
,
1
)
=
1
;
anglesR
(
ok_no
,
:
,
1
)
=
0
;
anglesB
(
ok_no
,
:
,
1
)
=
0
;
iSST
(
1
,
ok_no
,
:)
=
1
;
anglesR
(
1
,
ok_no
,
:)
=
0
;
anglesB
(
1
,
ok_no
,
:)
=
0
;
end
if
any
(
ok_too
)
warning
(
'gtCrystVector2SST:too_many_indices_found'
,
...
...
...
@@ -104,14 +105,15 @@ function [rgb, Vsst, Vsst_p, Vc_symm] = gtCrystVector2SST(Vc, crystal_system, sy
disp
(
find
(
ok_too
));
disp
(
' vectors:'
);
disp
(
Vc
(
ok_too
,
:));
i_too
=
find
(
iSST
(
ok_too
,
:,
:));
iSST
(
ok_too
,
:,
i_too
(
2
:
end
))
=
0
;
i_too
=
find
(
iSST
(
:,
ok_too
,
:));
iSST
(
i_too
(
2
:
end
)
,
ok_too
,
:
)
=
0
;
end
angleR
=
anglesR
(
iSST
);
angleB
=
anglesB
(
iSST
);
angleR
=
squeeze
(
anglesR
(
iSST
));
angleB
=
squeeze
(
anglesB
(
iSST
));
if
nargout
>
1
Vsst
=
reshape
(
Vc_symm
(
iSST
(:,
[
1
1
1
]
,
:
)),
[],
3
);
Vsst
=
reshape
(
Vc_symm
(
iSST
(:,
:,
[
1
1
1
])),
[],
3
);
if
nargout
>
2
denom
=
1
+
Vsst
(:,
3
);
Vsst_p
=
Vsst
(:,
1
:
2
)
.
/
denom
(:,
[
1
1
]);
...
...
@@ -119,9 +121,9 @@ function [rgb, Vsst, Vsst_p, Vc_symm] = gtCrystVector2SST(Vc, crystal_system, sy
end
% Color map
red
=
squeeze
(
angleR
/
maxAngleR
)
;
green
=
squeeze
(
(
maxAngleR
-
angleR
)/
maxAngleR
.*
(
maxAngleB
-
angleB
)/
maxAngleB
)
;
blue
=
squeeze
(
(
maxAngleR
-
angleR
)/
maxAngleR
.*
angleB
/
maxAngleB
)
;
red
=
angleR
/
maxAngleR
;
green
=
(
maxAngleR
-
angleR
)/
maxAngleR
.*
(
maxAngleB
-
angleB
)/
maxAngleB
;
blue
=
(
maxAngleR
-
angleR
)/
maxAngleR
.*
angleB
/
maxAngleB
;
rgb
=
[
red
green
blue
];
if
saturate
...
...
@@ -129,3 +131,4 @@ function [rgb, Vsst, Vsst_p, Vc_symm] = gtCrystVector2SST(Vc, crystal_system, sy
end
end
% end of function
This diff is collapsed.
Click to expand it.
zUtil_Cryst/gtVectorCryst2Lab.m
+
38
−
20
View file @
59cf80d3
function
Vs
=
gtVectorCryst2Lab
(
Vc
,
g
,
diag
)
function
Vs
=
gtVectorCryst2Lab
(
Vc
,
g
,
mode
)
% GTVECTORLAB2CRYST Express crystal row vector(s) in laboratory CS.
%
% Vs = gtVectorCryst2Lab(Vc, g,
diag
)
% Vs = gtVectorCryst2Lab(Vc, g
[
,
mode]
)
% -----------------------------------
%
% INPUT:
% Vc = <double> Vector(s) expressed in the crystal CS.
% g = <cell> Cell containing crystal orientation matrix(ces).
% diag = <logical> If true, turn on diag mode which apply each
% orientation matrix g_i to corresponding vector Vc_i.
% Only valid if equal number of vectors and matrices.
% Vc = <double> Vector(s) expressed in the crystal CS.
% g = <double> Array containing crystal orientation matrix(ces).
% mode = <string> Can be either 'diag' or a 3 coord vector {[3 1 2]},
% <int> This affect the output shape when multiple input
% vectors and matrices, i.e. M>1 and N>1
% See further explanations about the output.
%
% OUTPUT:
% Vs = <double>
Input vector(s) Vc expressed in the laboratory CS.
%
Shape of output depends of input size (see below).
% Vs = <double> Input vector(s) Vc expressed in the laboratory CS.
% Shape of output depends of input size (see below).
%
% Note:
% This function can be used in
4
different modes:
% This function can be used in different modes:
% - Vc = 1x3 array (1 row vector) , g = 3x3xN array
% output: N vectors expressed in the laboratory CS
% output size: [N 3]
...
...
@@ -27,19 +28,40 @@ function Vs = gtVectorCryst2Lab(Vc, g, diag)
%
% - Vc = Mx3 array (M row vectors) , g = 3x3xN array
% output: MxN vectors expressed in the laboratory CS
% output size: [M 3 N]
% output size: [M 3 N] by default, can be modified using numeric mode
% 1: input vector coordinate dimension (3)
% 2: input orientation matrix dimension (N)
% 3: input vector index dimension (M)
%
% - diag mode (only if
N=M
, need diag
argument
, otherwise previous case)
% - diag mode (only if
M=N
, need
'
diag
' mode
, otherwise previous case)
% Vc = Mx3 array (M row vectors) , g = 3x3xN array (M=N)
% output: M vectors expressed in the laboratory CS
% output size: [M 3 M]
%
% Version 001 02-04-2013 by YGuilhem
if
~
exist
(
'diag'
,
'var'
)
||
isempty
(
diag
)
diag
=
false
;
% Get number of vectors (M) and orientation matrices (N)
M
=
size
(
Vc
,
1
);
N
=
size
(
g
,
3
);
diag
=
false
;
if
~
exist
(
'mode'
,
'var'
)
||
isempty
(
mode
)
mode
=
[
3
1
2
];
elseif
isnumeric
(
mode
)
mode
=
mode
(:)
.'
;
if
size
(
mode
,
2
)
~=
3
||
~
all
(
between
(
mode
,
ones
(
size
(
mode
)),
3
*
ones
(
size
(
mode
))))
gtError
(
'gtVectorCryst2Lab:wrong_mode'
,
...
'Numeric mode should have 3 coordinates in [1 3]!'
);
end
elseif
ischar
(
mode
)
&&
strcmp
(
mode
,
'diag'
)
if
M
~=
N
gtError
(
'gtVectorCryst2Lab:wrong_mode'
,
...
[
'
''
diag
''
mode needs as many vectors as matrices!'
]);
end
diag
=
true
;
else
diag
=
logical
(
diag
);
gtError
(
'gtVectorCryst2Lab:wrong_mode'
,
...
[
'Unknown mode
''
'
mode
'
''
!'
]);
end
% Check input orientation matrices g size
...
...
@@ -57,10 +79,6 @@ if size(Vc, 2) ~= 3
'Input array Vc should be sized Mx3!'
);
end
% Get number of vectors (M) and orientation matrices (N)
M
=
size
(
Vc
,
1
);
N
=
size
(
g
,
3
);
if
M
==
1
&&
N
>
1
% Transpose and reshape Vc
Vc
=
reshape
(
Vc
.'
,
[
3
1
M
]);
...
...
@@ -92,7 +110,7 @@ elseif M > 1 && N > 1
Vc
=
reshape
(
Vc
.'
,
[
3
1
1
M
]);
% Multiply and sum along 1st axis to reproduce Vs = Vc . g
Vs
=
permute
(
squeeze
(
sum
(
bsxfun
(
@
times
,
Vc
,
g
),
1
)),
[
3
1
2
]);
Vs
=
permute
(
squeeze
(
sum
(
bsxfun
(
@
times
,
Vc
,
g
),
1
)),
[
mode
]);
else
gtError
(
'gtVectorCryst2Lab:wrong_input_size'
,
...
...
...
This diff is collapsed.
Click to expand it.
zUtil_Cryst/gtVectorLab2Cryst.m
+
38
−
20
View file @
59cf80d3
function
Vc
=
gtVectorLab2Cryst
(
Vs
,
g
,
diag
)
function
Vc
=
gtVectorLab2Cryst
(
Vs
,
g
,
mode
)
% GTVECTORLAB2CRYST Express laboratory row vector(s) in crystal CS.
%
% Vc = gtVectorLab2Cryst(Vs, g,
diag
)
% Vc = gtVectorLab2Cryst(Vs, g
[
,
mode]
)
% -----------------------------------
%
% INPUT:
% Vs = <double> Vector(s) expressed in the lab CS.
% g = <double> Array containing crystal orientation matrix(ces).
% diag = <logical> If true, turn on diag mode which apply each
% orientation matrix g_i to corresponding vector Vs_i.
% Only valid if equal number of vectors and matrices.
% Vs = <double> Vector(s) expressed in the lab CS.
% g = <double> Array containing crystal orientation matrix(ces).
% mode = <string> Can be either 'diag' or a 3 coord vector {[3 1 2]},
% <int> This affect the output shape when multiple input
% vectors and matrices, i.e. M>1 and N>1
% See further explanations about the output.
%
% OUTPUT:
% Vc = <double>
Input vector(s) Vs expressed in the crystal CS.
%
Shape of output depends of input size (see below).
% Vc = <double> Input vector(s) Vs expressed in the crystal CS.
% Shape of output depends of input size (see below).
%
% Note:
% This function can be used in
4
different modes:
% This function can be used in different modes:
% - Vs = 1x3 array (1 row vector) , g = 3x3xN array
% output: N vectors expressed in the crystal CS defined by g matrices
% output size: [N 3]
...
...
@@ -27,19 +28,40 @@ function Vc = gtVectorLab2Cryst(Vs, g, diag)
%
% - Vs = Mx3 array (M row vectors) , g = 3x3xN array
% output: MxN vectors expressed in the crystals CS defined by g matrices
% output size: [M 3 N]
% output size: [M 3 N] by default, can be modified using numeric mode
% 1: input vector coordinate dimension (3)
% 2: input orientation matrix dimension (N)
% 3: input vector index dimension (M)
%
% - diag mode (only if M=N, need diag
argument
, otherwise previous case)
% - diag mode (only if M=N, need
'
diag
' mode
, otherwise previous case)
% Vs = Mx3 array (M row vectors) , g = 3x3xN array (M=N)
% output: M vectors expressed in the crystal CS defined by g matrices
% output size: [M 3 M]
%
% Version 001 17-10-2012 by YGuilhem
if
~
exist
(
'diag'
,
'var'
)
||
isempty
(
diag
)
diag
=
false
;
% Get number of vectors (M) and orientation matrices (N)
M
=
size
(
Vs
,
1
);
N
=
size
(
g
,
3
);
diag
=
false
;
if
~
exist
(
'mode'
,
'var'
)
||
isempty
(
mode
)
mode
=
[
3
1
2
];
elseif
isnumeric
(
mode
)
mode
=
mode
(:)
.'
;
if
size
(
mode
,
2
)
~=
3
||
~
all
(
between
(
mode
,
ones
(
size
(
mode
)),
3
*
ones
(
size
(
mode
))))
gtError
(
'gtVectorLab2Cryst:wrong_mode'
,
...
'Numeric mode should have 3 coordinates in [1 3]!'
);
end
elseif
ischar
(
mode
)
&&
strcmp
(
mode
,
'diag'
)
if
M
~=
N
gtError
(
'gtVectorLab2Cryst:wrong_mode'
,
...
[
'
''
diag
''
mode needs as many vectors as matrices!'
]);
end
diag
=
true
;
else
diag
=
logical
(
diag
);
gtError
(
'gtVectorLab2Cryst:wrong_mode'
,
...
[
'Unknown mode
''
'
mode
'
''
!'
]);
end
% Check input orientation matrices g size
...
...
@@ -57,10 +79,6 @@ if size(Vs, 2) ~= 3
'Input array Vs should be sized Mx3!'
);
end
% Get number of vectors (M) and orientation matrices (N)
M
=
size
(
Vs
,
1
);
N
=
size
(
g
,
3
);
if
M
==
1
&&
N
>
1
% Transpose and reshape Vs
Vs
=
reshape
(
Vs
.'
,
[
1
3
M
]);
...
...
@@ -92,7 +110,7 @@ elseif M > 1 && N > 1
Vs
=
reshape
(
Vs
.'
,
[
1
3
1
M
]);
% Multiply and sum along 2nd axis to reproduce Vc = g . Vs
Vc
=
permute
(
squeeze
(
sum
(
bsxfun
(
@
times
,
g
,
Vs
),
2
)),
[
3
1
2
]
);
Vc
=
permute
(
squeeze
(
sum
(
bsxfun
(
@
times
,
g
,
Vs
),
2
)),
mode
);
else
gtError
(
'gtVectorLab2Cryst:wrong_input_size'
,
...
...
...
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