mtex
mtex copied to clipboard
Internal faces in crystal shape
Dear all, Would be an interesting feature to include the possibility to plot internal planes in the crystal shape. It would help in the visualization of slip systems, twinning and grain boundaries, for example.
I think a plane (given by its normal vector) could be plotted with:
% define a crystal shape
cS = crystalShape.olivine;
pcS=plot(cS);
alpha(pcS,0.5);
hold on
%define the normal to a plane:
v=[1 1 1];
x1=0;y1=0;z1=0; % center coordinates
w = null(v); % Find two orthonormal vectors which are orthogonal to v
P=[-1,1;-1,1]; % x Square limits
Q=[-1,-1;1,1]; % y square limits
X = x1+w(1,1)*P+w(1,2)*Q; % Compute the corresponding cartesian coordinates...
Y = y1+w(2,1)*P+w(2,2)*Q; % ... using the two vectors in w
Z = z1+w(3,1)*P+w(3,2)*Q;
hold on
gb_plane=surf (X,Y,Z,'FaceColor','k','FaceAlpha',0.4);
hold off
But I have no idea how to limit it to the crystal shape. Any ideas on how to implement it?
Thank you,
Filippe
Hi, maybe you can keep working from here:
cS = crystalShape.olivine;
pcS=plot(cS);
alpha(pcS,0.5);
hold on
p = cS(Miller(0,1,0,cS.CS));
s = - p.faceCenter; % shift to the center
plot(1.3*(p + s),'FaceColor','r') % potentially scale if needed
hold off
Cheers, Rüdiger
indeed a thing on my Wishlist too. could be used to display slipplanes, twins etc. I would think this is very similar to showing the intersection of a crystal shape with the sample surface.
Hi All, Just wanted to express my interest in this also. I have written a script that will take a certain orientation (Miller or Euler) and plot the crystal shape in either bcc or hcp with the specified orientation, indicating the alignment of the crystal planes with the specimen directions. However at the moment this only works for the planes that create the crystal shape. Highlighting additional planes within the crystal shape, along with a vector indicating a direction within the plane would be useful to aid the visualisation of slip systems that are active within a certain texture component i.e. aligned with specimen directions. I would like to further use this to investigate co-deformation in dual phase Ti microstructures. Happy to share my script as a starting point. Cheers, Nick
a few years later... Using @vector3d/planeIntersect might eventually work.
- scaling needs to be manually set and might be direction dependent,
- for some planes (e.g. (100) in olivine cS), a qhull error arises (Error computing the convex hull. The points may be coplanar or collinear.)
- shifting the plane to the center using centroid not always works (e.g. (001) in olivine cS ). Shift by mean(V) might work better
%% Plot internal face, and crystal directions
% a given crystal shape
cS= crystalShape.olivine;
% plot given plane(s)
p=Miller(0,0,1,cS.CS,'hkl');
% plot given direction(s)
v=Miller({1,0,0},{0,1,0},{0,0,1},cS.CS,'uvw');
% axis colors
rgb=eye(3);
% param
scaleFactor=0.79; % should be direction dependent instead of scalar?
tol = 1e-5;
% get face normal
fN=vector3d(p)./norm(vector3d(p));
% ensure N is vector3d and apply habitus scaling
N = cS.N(:); %#ok<*PROP>
if cS.habitus >0
N = N ./ ((abs(N.h) * cS.extension(1)).^cS.habitus + ...
(abs(N.k) * cS.extension(2)).^cS.habitus + ...
(abs(N.l) * cS.extension(3)).^cS.habitus).^(1/cS.habitus);
end
N = unique(vector3d(N.symmetrise),'stable');
% compute vertices as intersections between the given plane and other two planes
[a,b]= allTriple(1:length(N));
V = planeIntersect(fN,N(a),N(b));
% take only the finite ones
V = V(V.isfinite);
%
% take only those inside the polyhedron
V = V(all(dot_outer(V,N) <= 1 + tol,2));
V = unique(V);
% triangles of the convex hull of vertices
T = convhull(squeeze(double(V)));
% scale and shift to center
V = scaleFactor*V(:) ./ max(norm(V)) ./ 2;
% V=V-centroid(V); % doesnt work all the time
V=V-mean(V); % doesnt work all the time
% plot crystal shape
% figure;plot(cS,'faceAlpha',0.6,'colored'); hold on;
figure;plot(cS,'faceAlpha',0.6,'faceColor','DarkOliveGreen'); hold on;
% plot inner surface
p_str=['(',num2str(round(p).hkl),')'];
trisurf(T,V.x,V.y,V.z,'FaceColor','black','EdgeColor','none','DisplayName',p_str);hold on
% plot Directions
for ii=1:length(v)
vNorm=scaleFactor*v(ii)./ max(norm(v(ii))) ./ 2;
v_str=['[',num2str(v(ii).uvw),']'];
arrow3d(vNorm,'facecolor',rgb(ii,:),'faceAlpha',0.6,'label',v_str,'displayName',v_str)
end
hold off
view(3)
cheers, Filippe
I'm trying to use this piece of code to plot some slip planes and directions in cubic shapes, it works quite nicely.
I did get an error (when plotting 111 planes) for the convhull (Error computing the convex hull. Not enough unique points specified.), which I managed to fix by (arbitrarily) making N smaller (N = N/5), before calculating the planeIntersect.
Hi Filippe,
some more years later I have included this feature into MTEX :) Thank you for your work. See ed0cb824de336f28579d514088d8a52e786fd030
Ralf