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

gtHexagonalUnitCell / gtCubicUnitCell : updated version with fixed crystallographic axes


Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>
parent 05f3700a
No related branches found
No related tags found
No related merge requests found
function data = gtCubicUnitCell(varargin)
% GTCUBICUNITCELL Draws the cubic unit cell with crystallographic axes
% for Euler angles (0,0,0)
%
% data = gtCubicUnitCell(varargin)
% --------------------------------
% Draws the unit cell using this convention:
% Xs // <100> crystallographic axis
% Ys // <010> crystallographic axis
% Zs // <001> crystallographic axis
%
% Sample axes are Xs,Ys,Zs. Please refer to the
% DCTdoc_Crystal_orientation_descriptions.pdf in the DCT_Documentation
% folder for the graintracking code.
app.facecolors = [];
app.centered = false;
......@@ -10,6 +23,7 @@ app.numbers = false;
app.patch = false;
app.sampleaxes = false;
app.crystaxes = false;
app.caxis = false;
app.view = [103 20];
app.add_vertices = false;
......@@ -19,10 +33,11 @@ c=1;
a=1/app.ratio;
% calculation of vertices
%
%
%
x0 = [0 1 1 0 0]*a;
y0 = [0 0 1 1 0]*a;
if app.centered
z0 = repmat(-c/2,1,length(x0));
z1 = repmat(+c/2,1,length(x0));
......@@ -35,6 +50,9 @@ vertices(1,:)=[];
vertices(5,:)=[];
if app.add_vertices
vertices(end+1,:) = [0 0 z0(1)];
vertices(end+1,:) = [0 0 z1(1)];
vertices(end+1,:) = [0 0 (z1(1)-z0(1))/3];
vertices(end+1,:) = [0 0 (z1(1)-z0(1))/3*2];
......@@ -43,20 +61,26 @@ if app.add_vertices
vertices(end+1,:) = [0 0 (z1(1)-z0(1))/4*3];
end
caxis(1,:) = [0 0 z0(1)-c/4];
caxis(2,:) = [0 0 z1(1)+c/4];
faces = {[1 2 6 5]; [2 3 7 6]; [3 4 8 7]; [4 1 5 8];...
[5 6 7 8]; [1 2 3 4]};
hkl = [1 0 0; 0 1 0; -1 0 0; 0 -1 0;...
0 0 1; 0 0 -1]';
faces_sides = [1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8];
faces_end = [5 6 7 8; 1 2 3 4]; %
faceColors = [...
1 1 0;...
0 0 1;...
1 0 0;...
0 1 1;...
1 0 1;...
faceColors = [ ...
1 1 0; ...
0 0 1; ...
1 0 0; ...
0 1 1; ...
1 0 1; ...
0 1 0];
if ~isempty(app.facecolors)
faceColors = app.facecolors;
end
......@@ -65,10 +89,10 @@ if size(faceColors,1)==1
end
% for crystallographic axes and labels
orig=repmat([0 0 z0(1)],4,1);
xcrys=[1;0;0;0];
ycrys=[0;1;0;0];
zcrys=[z0(1);z0(1);z0(1);z1(1)+0.4];
orig=repmat([0 0 z0(1)],3,1);
xcrys=[0.6;0;0];
ycrys=[0;0.6;0];
zcrys=[z0(1);z0(1);z0(1)+0.6];
lcrys={'a [100]';...
'b [010]';...
'c [001]'};
......@@ -84,9 +108,14 @@ if app.draw
for ii=1:length(x0)
plot3([x0(ii) x0(ii)],[y0(ii) y0(ii)],[z0(ii) z1(ii)], 'b-', 'LineWidth', 1)
end
if app.caxis
line([0 0],[0 0],[z0(1)-c/4 z1(1)+c/4])
end
% cryst axes
if app.crystaxes
quiver3(orig(:,1),orig(:,2),orig(:,3),xcrys,ycrys,zcrys,0,'k')
quiver3(0,0,z0(1),0.6,0,0,0,'k','LineWidth',2)
quiver3(0,0,z0(1),0,0.6,0,0,'k','LineWidth',2)
quiver3(0,0,z0(1),0,0,0.6,0,'k','LineWidth',2)
text(xcrys-0.1,ycrys+0.1,zcrys,lcrys,'Color',[0 0 0])
end
view(app.view)
......@@ -120,17 +149,18 @@ if app.draw
end
if nargout == 1
data.vertices = vertices;
data.faces = faces;
data.vertices = vertices;
data.caxis = caxis;
data.faces = faces;
data.faces_sides = faces_sides;
data.faces_end = faces_end;
data.facecolors = faceColors;
data.hkl = hkl;
data.orig = orig;
data.xcrys = xcrys;
data.ycrys = ycrys;
data.zcrys = zcrys;
data.lcrys = lcrys;
data.facecolors = faceColors;
data.hkl = hkl;
data.orig = orig;
data.xcrys = xcrys;
data.ycrys = ycrys;
data.zcrys = zcrys;
data.lcrys = lcrys;
if app.draw
data.hf = gcf;
if app.patch
......
......@@ -5,17 +5,15 @@ function data = gtHexagonalUnitCell(varargin)
% data = gtHexagonalUnitCell(varargin)
% ------------------------------------
% Draws the unit cell using this convention:
% Xs // to <2-1-10> or <100> axis (a-axis)
% Ys // to
% Xs // to <2-1-10> or <100> crystallographic axis (a-axis)
% Ys // to <10-10> or <010> crystallographic axis
% Zs // to <0001> or <001> crystallographic axis (c-axis)
%
% Crystallographic axes are Xc, Yc, Zc which corresponds to a,b,c.
% For hexagonal unit cells, there are the equivalents axes a1,a2,a3,c in
% which a1//a, a2 is a1 rotated 120 deg counterclockwise, a3 is a2 rotated
% 120 degrees counterclockwise.
% Sample axes are Xs,Ys,Zs. Please refer to the
% DCTdoc_Crystal_orientation_descriptions.pdf in the DCT_Documentation
% folder for the graintracking code.
%
%
app.facecolors = [];
app.centered = false;
......@@ -33,15 +31,15 @@ app.add_vertices = false;
app = parse_pv_pairs(app, varargin);
% lattice axes' length; c is normalized to 1
c=1;
a=1/app.ratio;
% calculation of vertices
% first 6 are for 000-1 plane and first is at X=0 and then counterclockwise
% calculation of vertices: first 6 are for 000-1 plane and first is at X=0
% then counterclockwise
v=0:60:360;
x0 = a*cosd(v);
y0 = a*sind(v);
if app.centered
z0 = repmat(-c/2,1,length(x0));
z1 = repmat(+c/2,1,length(x0));
......@@ -117,10 +115,10 @@ if app.draw
end
% cryst axes
if app.crystaxes
quiver3(0,0,z0(1),1,0,0,0,'k')
quiver3(0,0,z0(1),-0.5,0.866,0,0,'k')
quiver3(0,0,z0(1),-0.5,-0.866,0,0,'k')
quiver3(0,0,z0(1),0,0,1,0,'k')
quiver3(0,0,z0(1),1,0,0,0,'k','LineWidth',2)
quiver3(0,0,z0(1),-0.5,0.866,0,0,'k','LineWidth',2)
quiver3(0,0,z0(1),-0.5,-0.866,0,0,'k','LineWidth',2)
quiver3(0,0,z0(1),0,0,1,0,'k','LineWidth',2)
text(xcrys-0.1,ycrys+0.1,zcrys,lcrys,'Color',[0 0 0])
end
view(app.view)
......
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