Skip to content

Instantly share code, notes, and snippets.

@jhiscocks
Last active June 22, 2025 14:56
Show Gist options
  • Save jhiscocks/1a092ede5d5520bf04f68fe9bde0bd5b to your computer and use it in GitHub Desktop.
Save jhiscocks/1a092ede5d5520bf04f68fe9bde0bd5b to your computer and use it in GitHub Desktop.
This script plots the orientation of a selected parent data point along with the possible twin variants and their schmid factors #mtexScript
%% Schmid pole figure
%this script plots the orientation of a selected parent data point along
%with the possible twin variants and their schmid factors
%the function Schmid must be installed
%input; ebsd data must be available
%output; pole figure plots
cs=ebsd('Magnesium').CS;
% get the parent orientation
figure; plot(ebsd('Magnesium'), ebsd('Magnesium').orientations)
disp('select the parent')
[x,y]=ginput(1);
oriP=ebsd(x,y);
%calculate the schmid factors, using the avaialbe script force is assumed
%to be positive in x, for other cases input it
[~,~,~,~,ExtTwinArray]=SchmidR2(oriP);
%convert oriP to an orientation below
oriP=oriP.orientations;
%calculate the orientations of the twin variants
%define the six twin axes which match with the order of those input into
%the SchmidR2 code.
ax13=Miller(-1,2,-1,0, cs);
ax14=Miller(1,-2,1,0, cs);
ax15=Miller(-1,-1,2,0, cs);
ax16=Miller(1,1,-2,0, cs);
ax17=Miller(2,-1,-1,0, cs);
ax18=Miller(-2,1,1,0, cs);
%find the vector3d which is the direction of the twin axis in the parent
vari13=oriP*ax13;
vari14=oriP*ax14;
vari15=oriP*ax15;
vari16=oriP*ax16;
vari17=oriP*ax17;
vari18=oriP*ax18;
%rotate the c axis around the twin axis
rot13=rotation('axis',vari13,'angle',86.3*degree);
rot14=rotation('axis',vari14,'angle',86.3*degree);
rot15=rotation('axis',vari15,'angle',86.3*degree);
rot16=rotation('axis',vari16,'angle',86.3*degree);
rot17=rotation('axis',vari17,'angle',86.3*degree);
rot18=rotation('axis',vari18,'angle',86.3*degree);
%these rotated vectors represent the potential twins
s13=rot13*oriP;
s14=rot14*oriP;
s15=rot15*oriP;
s16=rot16*oriP;
s17=rot17*oriP;
s18=rot18*oriP;
%plot the pole figure
%h=[Miller(0,0,1,cs), Miller(1,0,0,cs)]
h=Miller(0,0,1,cs);
figure;
plotPDF(oriP,h,'upper','projection','eangle','grid','grid_res',15*degree,'MarkerSize',10)
strP='P';
annotate(oriP,'label',{strP},'MarkerSize',1,'MarkerFaceColor','r','VerticalAlignment','top');
hold on
plotPDF(s13,h,'upper','projection','eangle', 'markertype','+','MarkerSize',5)
plotPDF(s14,h,'upper','projection','eangle', 'markertype','+','MarkerSize',5)
plotPDF(s15,h,'upper','projection','eangle', 'markertype','+','MarkerSize',5)
plotPDF(s16,h,'upper','projection','eangle', 'markertype','+','MarkerSize',5)
plotPDF(s17,h,'upper','projection','eangle', 'markertype','+','MarkerSize',5)
plotPDF(s18,h,'upper','projection','eangle', 'markertype','+','MarkerSize',5)
%get the SF values from the array output
str13=num2str(round(ExtTwinArray(1,1),3));
str14=num2str(round(ExtTwinArray(1,2),3));
str15=num2str(round(ExtTwinArray(1,3),3));
str16=num2str(round(ExtTwinArray(1,4),3));
str17=num2str(round(ExtTwinArray(1,5),3));
str18=num2str(round(ExtTwinArray(1,6),3));
annotate(s13,'label',{str13},'MarkerSize',1,'MarkerFaceColor','r','VerticalAlignment','top');
annotate(s14,'label',{str14},'MarkerSize',1,'MarkerFaceColor','r','VerticalAlignment','top');
annotate(s15,'label',{str15},'MarkerSize',1,'MarkerFaceColor','r','VerticalAlignment','top');
annotate(s16,'label',{str16},'MarkerSize',1,'MarkerFaceColor','r','VerticalAlignment','top');
annotate(s17,'label',{str17},'MarkerSize',1,'MarkerFaceColor','r','VerticalAlignment','top');
annotate(s18,'label',{str18},'MarkerSize',1,'MarkerFaceColor','r','VerticalAlignment','top');
hold off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment