Skip to content
Snippets Groups Projects
Commit e8c86a8d authored by Laura Nervo's avatar Laura Nervo Committed by Nicola Vigano
Browse files

Some header formatting and drawing improving... try to compare gtPlotHexagon...

Some header formatting and drawing improving... try to compare gtPlotHexagon and gtHexagonalUnitCell

Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@964 4c865b51-4357-4376-afb4-474e03ccb993
parent 4fdd9d05
No related branches found
No related tags found
No related merge requests found
function vertices = hexagon(a,c,draw) function vertices = gtHexagonalUnitCell(a,c,draw)
% create a hexagonal grid (radius <r>) % create a hexagonal grid (radius <r>)
...@@ -21,10 +21,19 @@ if draw ...@@ -21,10 +21,19 @@ if draw
figure; figure;
line(x0,y0,z0); line(x0,y0,z0);
line(x0,y0,z1); line(x0,y0,z1);
hold on; hold on;
plot3(x0,y0,z0,'r*') plot3(x0,y0,z0,'r*')
plot3(x0(1),y0(1),z0(1),'b*') plot3(x0(1),y0(1),z0(1),'b*')
plot3(x0,y0,z1,'r*')
plot3(x0(1),y0(1),z1(1),'b*')
for ii=1:length(x0)
plot3([x0(ii) x0(ii)],[y0(ii) y0(ii)],[z0(ii) z1(ii)], 'b-', 'LineWidth', 1)
end
% lab system : x y z vectors
quiver3(-1,0,0,2,0,0,'r');
quiver3(0,-1,0,0,2,0,'k');
quiver3(0,0,-1,0,0,2,'b');
axis equal; axis equal;
xlabel('x (100)') xlabel('x (100)')
ylabel('y (010)') ylabel('y (010)')
...@@ -80,4 +89,4 @@ end ...@@ -80,4 +89,4 @@ end
% 'linestyle','none',... % 'linestyle','none',...
% 'color',[1,0,0]); % 'color',[1,0,0]);
end end
\ No newline at end of file
function hf = gtPlotHexagon(grains, r_vectors, angle, cmap)
function gtPlotHexagon(grains, r_vectors, angle, cmap) % hf = gtPlotHexagon(grains, r_vectors, angle, cmap)
% --------------------------------------------------
%make a figure containing subplots of the unit cells of the selected grains % make a figure containing subplots of the unit cells of the selected grains
%angle is the angle of the section plane, defined as in % angle is the angle of the section plane, defined as in
%gtShowSampleSurface % gtShowSampleSurface
%can pass in a colormap as well, so colours match the section % can pass in a colormap as well, so colours match the section
%
%as in gtShowSampleSurface % as in gtShowSampleSurface
%Deal with coordinate systems. R-vector orientation data in the instrument % Deal with coordinate systems. R-vector orientation data in the instrument
%system: x//beam, z upwards, y towards door. % system: x//beam, z upwards, y towards door.
%In the reconstructed tomography/grain map data, z is downwards, y//x % In the reconstructed tomography/grain map data, z is downwards, y//x
%instruments, x//y instrument. % instruments, x//y instrument.
%Finally present all information in the frame of the tomo data. % Finally present all information in the frame of the tomo data.
if ~exist('cmap', 'var') if ~exist('cmap', 'var')
...@@ -22,43 +22,43 @@ end ...@@ -22,43 +22,43 @@ end
% patch object hexagonal prism % patch object hexagonal prism
%12 corners % 12 corners
%[u v x w] % [u v t w]
corners4=[2 -1 -1 3;... corners4=[ 2 -1 -1 3;...
-1 2 -1 3;... -1 2 -1 3;...
-1 -1 2 3;... -1 -1 2 3;...
1 1 -2 3;... 1 1 -2 3;...
1 -2 1 3;... 1 -2 1 3;...
-2 1 1 3]; -2 1 1 3];
corners4=[corners4; corners4]; corners4=[corners4; corners4];
corners4(7:12, 4)=-3;%lower corners corners4(7:12, 4)=-3;%lower corners
%turn these into 3 index coords % turn these into 3 index coords
corners3(:,3)=corners4(:,4); corners3(:,3) = corners4(:,4);
corners3(:,1)=(corners4(:,1)-corners4(:,3))*cosd(30); corners3(:,1) = (corners4(:,1)-corners4(:,3))*cosd(30);
corners3(:,2)=corners4(:,2)-((corners4(:,1)+corners4(:,3))*sind(30)); corners3(:,2) = corners4(:,2)-((corners4(:,1)+corners4(:,3))*sind(30));
corners3=corners3./repmat(sqrt(sum((corners3.*corners3),2)), 1,3); corners3 = corners3./repmat(sqrt(sum((corners3.*corners3),2)), 1,3);
id=figure; hf=figure;
%apply the R-vector % apply the R-vector
for i=1:length(grains) for i=1:length(grains)
grain=grains(i); grainID = grains(i);
R=r_vectors(find(r_vectors(:,1)==grain),2:4); R = r_vectors(find(r_vectors(:,1)==grainID),2:4);
g=Rod2g(R); g = Rod2g(R);
corners3a=(g*corners3')'; corners3a = (g*corners3')';
%allow for the two coordinate systems. Transform from instrument to % allow for the two coordinate systems. Transform from instrument to
%reconstructed tomo coordinates: x-->y y-->x z-->-z % reconstructed tomo coordinates: x-->y y-->x z-->-z
corners3a=[corners3a(:,2) corners3a(:,1) -corners3a(:,3)]; %corners3a=[corners3a(:,2) corners3a(:,1) -corners3a(:,3)];
%do the rotate to follow the the section plane % do the rotate to follow the section plane
corners3b = ([cosd(angle) sind(angle) 0; -sind(angle) cosd(angle) 0;0 0 1]*corners3a')'; corners3b = ([cosd(angle) sind(angle) 0; -sind(angle) cosd(angle) 0;0 0 1]*corners3a')';
%write these corners into the correct format for patch % write these corners into the correct format for patch
%corners3a is "vertices" % corners3a is "vertices"
hex_faces=[1 4 2 6 3 5; 7 11 9 12 8 10]; hex_faces=[1 4 2 6 3 5; 7 11 9 12 8 10];
rec_faces=[1 7 10 4;... rec_faces=[1 7 10 4;...
4 2 8 10;... 4 2 8 10;...
...@@ -68,28 +68,29 @@ for i=1:length(grains) ...@@ -68,28 +68,29 @@ for i=1:length(grains)
5 1 7 11]; 5 1 7 11];
subplot(1, length(grains), i); subplot(1, length(grains), i);
%reference hex % reference hex
%patch('Vertices', corners3, 'Faces', hex_faces, 'FaceColor', 'b', 'FaceAlpha', 0.4) % patch('Vertices', corners3, 'Faces', hex_faces, 'FaceColor', 'b', 'FaceAlpha', 0.4)
%patch('Vertices', corners3, 'Faces', rec_faces, 'FaceColor', 'b', 'FaceAlpha', 0.4) % patch('Vertices', corners3, 'Faces', rec_faces, 'FaceColor', 'b', 'FaceAlpha', 0.4)
%reference background like the section plane % reference background like the section plane
xpos=min(mean(corners3b([1 4 2 6 3 5], 1)), mean(corners3b([7 11 9 12 8 10], 1))); xpos=min(mean(corners3b([1 4 2 6 3 5], 1)), mean(corners3b([7 11 9 12 8 10], 1)));
section_plane_vertices=[xpos 1 1; xpos 1 -1; xpos -1 1; xpos -1 -1]; section_plane_vertices=[xpos 1 1; xpos 1 -1; xpos -1 1; xpos -1 -1];
section_plane_face=[1 2 4 3]; section_plane_face=[1 2 4 3];
patch('Vertices', section_plane_vertices, 'Faces', section_plane_face, 'FaceColor', 'k', 'FaceAlpha', 0.4) patch('Vertices', section_plane_vertices, 'Faces', section_plane_face, 'FaceColor', 'k', 'FaceAlpha', 0.4)
%including the rotation for sectioning % including the rotation for sectioning
patch('Vertices', corners3b, 'Faces', hex_faces, 'FaceColor', cmap(grain+1,:), 'FaceAlpha', 1) patch('Vertices', corners3b, 'Faces', hex_faces, 'FaceColor', cmap(grainID+1,:), 'FaceAlpha', 1)
patch('Vertices', corners3b, 'Faces', rec_faces, 'FaceColor', cmap(grain+1,:), 'FaceAlpha', 1) patch('Vertices', corners3b, 'Faces', rec_faces, 'FaceColor', cmap(grainID+1,:), 'FaceAlpha', 1)
set(get(get(id, 'CurrentAxes'), 'Title'), 'String', sprintf('grain %d unit cell', grain)) set(get(get(hf, 'CurrentAxes'), 'Title'), 'String', sprintf('grain %d unit cell', grainID))
set(get(get(id, 'CurrentAxes'), 'xLabel'),'String', 'x axis') set(get(get(hf, 'CurrentAxes'), 'xLabel'),'String', 'x axis')
set(get(get(id, 'CurrentAxes'), 'yLabel'),'String', 'y axis') set(get(get(hf, 'CurrentAxes'), 'yLabel'),'String', 'y axis')
set(get(get(id, 'CurrentAxes'), 'zLabel'),'String', 'z axis') set(get(get(hf, 'CurrentAxes'), 'zLabel'),'String', 'z axis')
set(get(id, 'CurrentAxes'), 'zdir','reverse') %set(get(hf, 'CurrentAxes'), 'zdir','reverse')
set(get(id, 'CurrentAxes'), 'xdir','reverse') %set(get(hf, 'CurrentAxes'), 'xdir','reverse')
%need to mirror twice to stay consistant with tomo % need to mirror twice to stay consistant with tomo
set(get(id, 'CurrentAxes'), 'view', [90 0]) set(get(hf, 'CurrentAxes'), 'view', [90 0])
axis tight axis tight
axis equal
axis vis3d axis vis3d
end end
......
function gtShowSampleSurface(vol, angle, depth_orig, cmap, r_vectors, grains) function gtShowSampleSurface(vol, angle, depth_orig, cmap, r_vectors, grains)
%rotate volume by angle, remove layer depth pixels thick from surface % gtShowSampleSurface(vol, angle, depth_orig, cmap, r_vectors, grains)
%use volume with surface added (surface label is 800, grains 1-700) % --------------------------------------------------------------------
%show what's left % rotate volume by angle, remove layer depth pixels thick from surface
%highlight grains of interest % use volume with surface added (surface label is 800, grains 1-700)
%show trace of basal planes on section, display inclination, using % show what's left
%gtPlotHexagon to display crystallographic orientation. % highlight grains of interest
% show trace of basal planes on section, display inclination, using
%rotation convention for section: starting from 12-6 o'clock on grain map // y, angle % gtPlotHexagon to display crystallographic orientation.
%is measured clockwise. Hence, first cut of interest is around 13.1 %
%degrees. Depth is removed from the left of the sample, after rotation % rotation convention for section: starting from 12-6 o'clock on grain map // y, angle
% is measured clockwise. Hence, first cut of interest is around 13.1
%Deal with coordinate systems. R-vector orientation data in the instrument % degrees. Depth is removed from the left of the sample, after rotation
%system: x//beam, z upwards, y towards door. %
%In the reconstructed tomography/grain map data, z is downwards, y//x % Deal with coordinate systems. R-vector orientation data in the instrument
%instruments, x//y instrument. % system: x//beam, z upwards, y towards door.
%Finally present all information in the frame of the tomo data. % In the reconstructed tomography/grain map data, z is downwards, y//x
% instruments, x//y instrument.
% Finally present all information in the frame of the tomo data.
vol=imrotate(vol, angle, 'nearest', 'crop'); vol=imrotate(vol, angle, 'nearest', 'crop');
......
...@@ -20,17 +20,17 @@ color = [0.501960813999176 0.501960813999176 0.501960813999176]; ...@@ -20,17 +20,17 @@ color = [0.501960813999176 0.501960813999176 0.501960813999176];
% Create axes % Create axes
set(gca,'ZMinorTick','on') set(gca,'ZMinorTick','on')
set(gca,'ZColor',color); set(gca,'ZColor',color);
set(gca,'YMinorTick','on'); set(gca,'YMinorTick','on');
set(gca,'YColor',color); set(gca,'YColor',color);
set(gca,'XMinorTick','on'); set(gca,'XMinorTick','on');
set(gca,'XColor',color); set(gca,'XColor',color);
set(gca,'FontSize',12); set(gca,'FontSize',12);
set(gca,'Visible','on'); set(gca,'Visible','on');
set(gca,'Box','on'); set(gca,'Box','on');
set(gca,'XGrid','on'); set(gca,'XGrid','on');
set(gca,'YGrid','on'); set(gca,'YGrid','on');
set(gca,'ZGrid','on'); set(gca,'ZGrid','on');
% Create xlabel % Create xlabel
xlabel('X','Color',color); xlabel('X','Color',color);
% Create ylabel % Create ylabel
......
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