From bbaadbafe3bf8aa0b26320bc99dadbc8d5b6c431 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 16:39:27 +0100 Subject: [PATCH 001/120] rename tripel to triple --- EBSDAnalysis/@grain2d/grain2d.m | 16 ++--- EBSDAnalysis/@grainBoundary/grainBoundary.m | 4 +- EBSDAnalysis/@grainBoundary/subSet.m | 6 +- .../display.m | 30 ++++----- .../plot.m | 8 +-- .../private/subsind.m | 0 .../subSet.m | 0 .../subsasgn.m | 2 +- .../subsref.m | 0 .../triplePointList.m} | 4 +- doc/BoundaryAnalysis/BoundaryAnalysis.toc | 2 +- .../{TripelPoints.m => TriplePoints.m} | 66 +++++++++---------- tools/math_tools/{allTripel.m => allTriple.m} | 4 +- 13 files changed, 71 insertions(+), 71 deletions(-) rename EBSDAnalysis/{@tripelPointList => @triplePointList}/display.m (51%) rename EBSDAnalysis/{@tripelPointList => @triplePointList}/plot.m (89%) rename EBSDAnalysis/{@tripelPointList => @triplePointList}/private/subsind.m (100%) rename EBSDAnalysis/{@tripelPointList => @triplePointList}/subSet.m (100%) rename EBSDAnalysis/{@tripelPointList => @triplePointList}/subsasgn.m (96%) rename EBSDAnalysis/{@tripelPointList => @triplePointList}/subsref.m (100%) rename EBSDAnalysis/{@tripelPointList/tripelPointList.m => @triplePointList/triplePointList.m} (93%) rename doc/BoundaryAnalysis/{TripelPoints.m => TriplePoints.m} (57%) rename tools/math_tools/{allTripel.m => allTriple.m} (61%) diff --git a/EBSDAnalysis/@grain2d/grain2d.m b/EBSDAnalysis/@grain2d/grain2d.m index 246ec6d72..9821d39b4 100644 --- a/EBSDAnalysis/@grain2d/grain2d.m +++ b/EBSDAnalysis/@grain2d/grain2d.m @@ -26,7 +26,7 @@ GOS % intragranular average misorientation angle x % x coordinates of the vertices of the grains y % y coordinates of the vertices of the grains - tripelPoints % tripel points + triplePoints % triple points end properties (Dependent = true, Access = protected) @@ -122,9 +122,9 @@ function grains = set.V(grains,V) grains.boundary.V = V; - % update V in tripel points - tP = grains.tripelPoints; - grains.tripelPoints.V = V(tP.id,:); + % update V in triple points + tP = grains.triplePoints; + grains.triplePoints.V = V(tP.id,:); end function idV = get.idV(grains) @@ -157,12 +157,12 @@ unit = grains.boundary.scanUnit; end - function tP = get.tripelPoints(grains) - tP = grains.boundary.tripelPoints; + function tP = get.triplePoints(grains) + tP = grains.boundary.triplePoints; end - function grains = set.tripelPoints(grains,tP) - grains.boundary.tripelPoints = tP; + function grains = set.triplePoints(grains,tP) + grains.boundary.triplePoints = tP; end end diff --git a/EBSDAnalysis/@grainBoundary/grainBoundary.m b/EBSDAnalysis/@grainBoundary/grainBoundary.m index 20527c77b..94e84e9b3 100644 --- a/EBSDAnalysis/@grainBoundary/grainBoundary.m +++ b/EBSDAnalysis/@grainBoundary/grainBoundary.m @@ -22,7 +22,7 @@ properties V = [] % vertices x,y coordinates scanUnit = 'um' % unit of the vertice coordinates - tripelPoints % tripel points + triplePoints % triple points end properties (Dependent = true) @@ -173,7 +173,7 @@ A_F = I_VF.' * I_VF; %#ok end - %function tp = get.tripelPoints(gB) + %function tp = get.triplePoints(gB) %end diff --git a/EBSDAnalysis/@grainBoundary/subSet.m b/EBSDAnalysis/@grainBoundary/subSet.m index 9e3ff81e0..d8aa009be 100644 --- a/EBSDAnalysis/@grainBoundary/subSet.m +++ b/EBSDAnalysis/@grainBoundary/subSet.m @@ -15,6 +15,6 @@ gB.phaseId = gB.phaseId(ind,:); gB.misrotation = gB.misrotation(ind); -% restrict tripel points -tP = gB.tripelPoints; -gB.tripelPoints = subSet(tP,any(gB.I_VF(tP.id,:),2)); +% restrict triple points +tP = gB.triplePoints; +gB.triplePoints = subSet(tP,any(gB.I_VF(tP.id,:),2)); diff --git a/EBSDAnalysis/@tripelPointList/display.m b/EBSDAnalysis/@triplePointList/display.m similarity index 51% rename from EBSDAnalysis/@tripelPointList/display.m rename to EBSDAnalysis/@triplePointList/display.m index 15049335f..4e1bc0b58 100644 --- a/EBSDAnalysis/@tripelPointList/display.m +++ b/EBSDAnalysis/@triplePointList/display.m @@ -8,7 +8,7 @@ function display(tP,varargin) % --------------------------------- disp(' '); -h = doclink('tripelPointList_index','tripelPointList'); +h = doclink('triplePointList_index','triplePointList'); if check_option(varargin,'vname') h = [get_option(varargin,'vname'), ' = ' h]; @@ -19,39 +19,39 @@ function display(tP,varargin) % empty grain boundary set if isempty(tP) - disp(' no tripel points in the list!') + disp(' no triple points in the list!') return end disp(' ') -tripel = allTripel(1:numel(tP.phaseMap)); +triple = allTriple(1:numel(tP.phaseMap)); % ebsd.phaseMap -matrix = cell(size(tripel,1),4); +matrix = cell(size(triple,1),4); -for ip = 1:size(tripel,1) +for ip = 1:size(triple,1) - num(ip) = nnz(tP.hasPhaseId(tripel(ip,1),tripel(ip,2),tripel(ip,3))); %#ok + num(ip) = nnz(tP.hasPhaseId(triple(ip,1),triple(ip,2),triple(ip,3))); %#ok matrix{ip,1} = int2str(num(ip)); % phases - if ischar(tP.CSList{tripel(ip,1)}) - matrix{ip,2} = tP.CSList{tripel(ip,1)}; + if ischar(tP.CSList{triple(ip,1)}) + matrix{ip,2} = tP.CSList{triple(ip,1)}; else - matrix{ip,2} = tP.CSList{tripel(ip,1)}.mineral; + matrix{ip,2} = tP.CSList{triple(ip,1)}.mineral; end - if ischar(tP.CSList{tripel(ip,2)}) - matrix{ip,3} = tP.CSList{tripel(ip,2)}; + if ischar(tP.CSList{triple(ip,2)}) + matrix{ip,3} = tP.CSList{triple(ip,2)}; else - matrix{ip,3} = tP.CSList{tripel(ip,2)}.mineral; + matrix{ip,3} = tP.CSList{triple(ip,2)}.mineral; end - if ischar(tP.CSList{tripel(ip,3)}) - matrix{ip,4} = tP.CSList{tripel(ip,3)}; + if ischar(tP.CSList{triple(ip,3)}) + matrix{ip,4} = tP.CSList{triple(ip,3)}; else - matrix{ip,4} = tP.CSList{tripel(ip,3)}.mineral; + matrix{ip,4} = tP.CSList{triple(ip,3)}.mineral; end end diff --git a/EBSDAnalysis/@tripelPointList/plot.m b/EBSDAnalysis/@triplePointList/plot.m similarity index 89% rename from EBSDAnalysis/@tripelPointList/plot.m rename to EBSDAnalysis/@triplePointList/plot.m index 05741dd96..8e82b5f75 100644 --- a/EBSDAnalysis/@tripelPointList/plot.m +++ b/EBSDAnalysis/@triplePointList/plot.m @@ -5,12 +5,12 @@ % the function % % Syntax -% plot(grains.tripelPoints) -% plot(grains.tripelPoints,'color','r') -% plot(grains('Forsterite').tripelPoints,gB('Forsterite','Forsterite').misorientation.angle) +% plot(grains.triplePoints) +% plot(grains.triplePoints,'color','r') +% plot(grains('Forsterite').triplePoints,gB('Forsterite','Forsterite').misorientation.angle) % % Input -% tP - @tripelPointList +% tP - @triplePointList % % Options % linewidth diff --git a/EBSDAnalysis/@tripelPointList/private/subsind.m b/EBSDAnalysis/@triplePointList/private/subsind.m similarity index 100% rename from EBSDAnalysis/@tripelPointList/private/subsind.m rename to EBSDAnalysis/@triplePointList/private/subsind.m diff --git a/EBSDAnalysis/@tripelPointList/subSet.m b/EBSDAnalysis/@triplePointList/subSet.m similarity index 100% rename from EBSDAnalysis/@tripelPointList/subSet.m rename to EBSDAnalysis/@triplePointList/subSet.m diff --git a/EBSDAnalysis/@tripelPointList/subsasgn.m b/EBSDAnalysis/@triplePointList/subsasgn.m similarity index 96% rename from EBSDAnalysis/@tripelPointList/subsasgn.m rename to EBSDAnalysis/@triplePointList/subsasgn.m index 0cd93f424..233d8c5ad 100644 --- a/EBSDAnalysis/@tripelPointList/subsasgn.m +++ b/EBSDAnalysis/@triplePointList/subsasgn.m @@ -1,7 +1,7 @@ function tP = subsasgn(tP,s,b) % overloads subsasgn -if ~isa(tP,'tripelPointList'), tP = b([]); end +if ~isa(tP,'triplePointList'), tP = b([]); end switch s(1).type diff --git a/EBSDAnalysis/@tripelPointList/subsref.m b/EBSDAnalysis/@triplePointList/subsref.m similarity index 100% rename from EBSDAnalysis/@tripelPointList/subsref.m rename to EBSDAnalysis/@triplePointList/subsref.m diff --git a/EBSDAnalysis/@tripelPointList/tripelPointList.m b/EBSDAnalysis/@triplePointList/triplePointList.m similarity index 93% rename from EBSDAnalysis/@tripelPointList/tripelPointList.m rename to EBSDAnalysis/@triplePointList/triplePointList.m index 49760c889..ec49f8551 100644 --- a/EBSDAnalysis/@tripelPointList/tripelPointList.m +++ b/EBSDAnalysis/@triplePointList/triplePointList.m @@ -1,4 +1,4 @@ -classdef tripelPointList < phaseList & dynProp +classdef triplePointList < phaseList & dynProp % grainBoundary list of grain boundaries in 2-D % % grainBoundary is used to extract, analyze and visualize grain @@ -25,7 +25,7 @@ end methods - function tP = tripelPointList(id,V,grainId,boundaryId,phaseId,phaseMap,CSList) + function tP = triplePointList(id,V,grainId,boundaryId,phaseId,phaseMap,CSList) if nargin == 0, return; end diff --git a/doc/BoundaryAnalysis/BoundaryAnalysis.toc b/doc/BoundaryAnalysis/BoundaryAnalysis.toc index ae37bb540..d231de6d1 100644 --- a/doc/BoundaryAnalysis/BoundaryAnalysis.toc +++ b/doc/BoundaryAnalysis/BoundaryAnalysis.toc @@ -1,4 +1,4 @@ BoundaryPlots TwinningAnalysis CSLBoundaries -TripelPoints \ No newline at end of file +TriplePoints \ No newline at end of file diff --git a/doc/BoundaryAnalysis/TripelPoints.m b/doc/BoundaryAnalysis/TriplePoints.m similarity index 57% rename from doc/BoundaryAnalysis/TripelPoints.m rename to doc/BoundaryAnalysis/TriplePoints.m index 30562ed01..0a182f98e 100644 --- a/doc/BoundaryAnalysis/TripelPoints.m +++ b/doc/BoundaryAnalysis/TriplePoints.m @@ -1,15 +1,15 @@ -%% Tripel points -% how to detect tripel points +%% Triple points +% how to detect triple points % %% Open in Editor % %% Contents -% This is some starting implementation for tripel points in orientation +% This is some starting implementation for triple points in orientation % images. -%% Calculation of tripel points +%% Calculation of triple points % -% MTEX automatically computes tripel points during grain reconstruction. +% MTEX automatically computes triple points during grain reconstruction. % They are acessable similarly to % as an property of the grain list. @@ -19,24 +19,24 @@ % compute grains grains = calcGrains(ebsd('indexed')); -% extract all tripel points -tP = grains.tripelPoints +% extract all triple points +tP = grains.triplePoints -%% Index tripel points by phase +%% Index triple points by phase % -% You may index tripel points by the adjacent phases. The following command -% gives you all tripel points with at least one phase being Forsterite +% You may index triple points by the adjacent phases. The following command +% gives you all triple points with at least one phase being Forsterite tP('Forsterite') %% -% The following command gives you all tripel points with at least two +% The following command gives you all triple points with at least two % phases being Forsterite tP('Forsterite','Forsterite') %% -% Finaly, we may mark all inner Diopside tripel points +% Finaly, we may mark all inner Diopside triple points % smooth the grains a bit grains = smooth(grains,2); @@ -44,23 +44,23 @@ % and plot them plot(grains); -% on top plot the tripel points +% on top plot the triple points hold on plot(tP('Diopside','Diopside','Diopside'),'displayName','Di-Di-Di','color','b') hold off -%% Index tripel points by grains +%% Index triple points by grains % -% Since, tripel points are asociated to grains we may single out tripel +% Since, triple points are asociated to grains we may single out triple % points that belong to a specific grain or some subset of grains. % find the index of the largest grain [~,id] = max(grains.area); -% the tripel points that belong to the largest grain -tP = grains(id).tripelPoints; +% the triple points that belong to the largest grain +tP = grains(id).triplePoints; -% plot these tripel points +% plot these triple points plot(grains(id),'FaceColor',[0.2 0.8 0.8],'displayName','largest grains'); hold on plot(grains.boundary) @@ -68,10 +68,10 @@ hold off -%% Index tripel points by grain boundary +%% Index triple points by grain boundary % -% Tripel points are not only a property of grains but also of grain -% boundaries. Thus we may ask for all tripel points that belong to +% Triple points are not only a property of grains but also of grain +% boundaries. Thus we may ask for all triple points that belong to % Fosterite - Forsterite boundaries with misorientation angle larger then % 60 degree @@ -81,43 +81,43 @@ % Fo - Fo segments with misorientation angle larger 60 degree gB_large = gB_Fo(gB_Fo.misorientation.angle>60*degree) -% plot the tripel points +% plot the triple points plot(grains) hold on plot(gB_large,'linewidth',2,'linecolor','w') -plot(gB_large.tripelPoints,'color','m') +plot(gB_large.triplePoints,'color','m') hold off -%% Boundary segments from tripel points +%% Boundary segments from triple points % % On the other hand we may also ask for the boundary segments that build up -% a tripel point. These are stored as the property boundaryId for each -% tripel points. +% a triple point. These are stored as the property boundaryId for each +% triple points. % -% lets take Forsterite tripel points -tP = grains.tripelPoints('Fo','Fo','Fo'); +% lets take Forsterite triple points +tP = grains.triplePoints('Fo','Fo','Fo'); -% the boundary segments which form the tripel points +% the boundary segments which form the triple points gB = grains.boundary(tP.boundaryId); -% plot the tripel point boundary segments +% plot the triple point boundary segments plot(grains) hold on plot(gB,'lineColor','w','linewidth',2) hold off %% -% Once we have extracted the boundary segments adjecent to a tripel point +% Once we have extracted the boundary segments adjecent to a triple point % we may also extract the corresponding misorientations. The following % command gives a n x 3 list of misorientations where n is the number of -% tripel points +% triple points mori = gB.misorientation %% -% Hence, we can compute for each tripel point the sum of misorientation +% Hence, we can compute for each triple point the sum of misorientation % angles by sumMisAngle = sum(mori.angle,2); diff --git a/tools/math_tools/allTripel.m b/tools/math_tools/allTriple.m similarity index 61% rename from tools/math_tools/allTripel.m rename to tools/math_tools/allTriple.m index 85f5bf4da..2961284a5 100644 --- a/tools/math_tools/allTripel.m +++ b/tools/math_tools/allTriple.m @@ -1,5 +1,5 @@ -function [x,y,z] = allTripel(d) -% all tripel of elements of x and y modulo permutation +function [x,y,z] = allTriple(d) +% all triple of elements of x and y modulo permutation % [x,y,z] = meshgrid(1:length(d)); From 9fa1bae4780fc2c1241231f2ed924b0463b98b2b Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 16:41:40 +0100 Subject: [PATCH 002/120] calcTriplePoints is a seperate function --- .../@grainBoundary/calcTriplePoints.m | 26 +++++++++++++++ EBSDAnalysis/@grainBoundary/grainBoundary.m | 32 +++++++------------ 2 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 EBSDAnalysis/@grainBoundary/calcTriplePoints.m diff --git a/EBSDAnalysis/@grainBoundary/calcTriplePoints.m b/EBSDAnalysis/@grainBoundary/calcTriplePoints.m new file mode 100644 index 000000000..d414c26b2 --- /dev/null +++ b/EBSDAnalysis/@grainBoundary/calcTriplePoints.m @@ -0,0 +1,26 @@ +function tP = calcTriplePoints(gB,grainsPhaseId) + +% compute triple points +I_VF = gB.I_VF; +I_VG = (I_VF * gB.I_FG)==2; +% triple points are those with exactly 3 neigbouring grains and 3 +% boundary segments +itP = full(sum(I_VG,2)==3 & sum(I_VF,2)==3); +[tpGrainId,~] = find(I_VG(itP,:).'); +tpGrainId = reshape(tpGrainId,3,[]).'; +tpPhaseId = full(grainsPhaseId(tpGrainId)); + +% compute ebsdId +% first step: compute faces at the triple point +% clean up incidence matrix +%I_FD(~any(I_FD,2),:) = []; +% incidence matrix between triple points and voronoi cells +%I_TD = I_VF(itP,:) * I_FD; +[tPBoundaryId,~] = find(I_VF(itP,:).'); +tPBoundaryId = reshape(tPBoundaryId,3,[]).'; + +tP = triplePointList(find(itP),gB.V(itP,:),... + tpGrainId,tPBoundaryId,tpPhaseId,gB.phaseMap,gB.CSList); + +end + diff --git a/EBSDAnalysis/@grainBoundary/grainBoundary.m b/EBSDAnalysis/@grainBoundary/grainBoundary.m index 94e84e9b3..18e99b6a0 100644 --- a/EBSDAnalysis/@grainBoundary/grainBoundary.m +++ b/EBSDAnalysis/@grainBoundary/grainBoundary.m @@ -40,6 +40,15 @@ methods function gB = grainBoundary(V,F,I_FD,ebsd,grainsPhaseId) + % + % Input + % V - [x,y] list of vertices + % F - [v1,v2] list of boundary segments + % I_FD - incidence matrix boundary segments vs. cells + % ebsd - + % grainPhaseId - + % + % if nargin == 0, return; end @@ -83,27 +92,8 @@ inv(ebsd.rotations(gB.ebsdId(isNotBoundary,2))) ... .* ebsd.rotations(gB.ebsdId(isNotBoundary,1)); - % compute tripel points - I_VF = gB.I_VF; - I_VG = (I_VF * gB.I_FG)==2; - % tripel points are those with exactly 3 neigbouring grains and 3 - % boundary segments - itP = full(sum(I_VG,2)==3 & sum(I_VF,2)==3); - [tpGrainId,~] = find(I_VG(itP,:).'); - tpGrainId = reshape(tpGrainId,3,[]).'; - tpPhaseId = full(grainsPhaseId(tpGrainId)); - - % compute ebsdId - % first step: compute faces at the tripel point - % clean up incidence matrix - %I_FD(~any(I_FD,2),:) = []; - % incidence matrix between tripel points and voronoi cells - %I_TD = I_VF(itP,:) * I_FD; - [tPBoundaryId,~] = find(I_VF(itP,:).'); - tPBoundaryId = reshape(tPBoundaryId,3,[]).'; - - gB.tripelPoints = tripelPointList(find(itP),gB.V(itP,:),... - tpGrainId,tPBoundaryId,tpPhaseId,gB.phaseMap,gB.CSList); + % compute triple points + gB.triplePoints = gB.calcTriplePoints(grainsPhaseId); end From 970cbd9e34955a2302874ecdf4583aacb44ec099 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 16:42:07 +0100 Subject: [PATCH 003/120] replace tripel by triple --- doc/ReleaseNotes/changelog.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/ReleaseNotes/changelog.m b/doc/ReleaseNotes/changelog.m index e14c9e88f..d35fcae7a 100644 --- a/doc/ReleaseNotes/changelog.m +++ b/doc/ReleaseNotes/changelog.m @@ -3,19 +3,19 @@ % %% MTEX 4.2 - 11/2015 % -% MTEX 4.2 introduces basic functionality for tripel junction analysis in +% MTEX 4.2 introduces basic functionality for triple junction analysis in % grain maps. % -% *Tripel points* +% *Triple points* % -% Tripel points are automatically computed during grain reconstruction and +% Triple points are automatically computed during grain reconstruction and % can be accessed by % -% grains.tripelPoints -% grains.boundary.tripelPoints +% grains.triplePoints +% grains.boundary.triplePoints % -% More details on how to work with tripel points can be found -% . +% More details on how to work with triple points can be found +% . % % *large EBSD data sets* % From a5b35e7931f69390ab9a563234893b5f98db3fd0 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 16:52:47 +0100 Subject: [PATCH 004/120] analog to symmetry/plotHKL --- geometry/@crystalSymmetry/plotUVW.m | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 geometry/@crystalSymmetry/plotUVW.m diff --git a/geometry/@crystalSymmetry/plotUVW.m b/geometry/@crystalSymmetry/plotUVW.m new file mode 100644 index 000000000..6d81e8c98 --- /dev/null +++ b/geometry/@crystalSymmetry/plotUVW.m @@ -0,0 +1,33 @@ +function plotUVW(cs,varargin) +% plot symmetry +% +% Input +% s - symmetry +% +% Output +% +% Options +% antipodal - include [[AxialDirectional.html,antipodal symmetry]] + +mtexFig = newMtexFigure(varargin{:}); + +% which directions to plot +m = Miller({1,0,0},{0,1,0},{0,0,1},{1,1,0},{0,1,1},{1,0,1},{1,1,1},cs,'uvw'); + +m = unique(m); +options = [{'symmetrised','labeled','MarkerEdgeColor','k','grid','doNotDraw'},varargin]; + +% plot them +washold = getHoldState(mtexFig.gca); +hold(mtexFig.gca,'all') +for i = 1:length(m) + m(i).scatter(options{:}); +end +hold(mtexFig.gca,washold) + + +% postprocess figure +setappdata(gcf,'CS',cs); +set(gcf,'tag','ipdf'); +mtexFig.drawNow('figSize',getMTEXpref('figSize'),varargin{:}); + From ebfd5accc103770e6766c7855737715729b7834a Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 17:00:54 +0100 Subject: [PATCH 005/120] changed html location --- doc/html/helptoc.xml | 996 +++++++++++++++++++++++++++++++++++++++++++ info.xml | 2 +- 2 files changed, 997 insertions(+), 1 deletion(-) create mode 100644 doc/html/helptoc.xml diff --git a/doc/html/helptoc.xml b/doc/html/helptoc.xml new file mode 100644 index 000000000..97c65e110 --- /dev/null +++ b/doc/html/helptoc.xml @@ -0,0 +1,996 @@ + + + MTEX ToolboxGetting Started with the MTEX ToolboxInstallation GuideDownload + MATLAB + Installation + Configuration and Troubleshooting + Compiling MTEX + + ConfigurationGlobal Configuration + The Option System + + Feature OverviewAnalyze and Visualize Crystallographic Geometries + Calculate with Model ODFs + Import, Analyze and Visualize Diffraction Data + Import, Analyze and Visualize EBSD Data + Recover Orientation Density Functions (ODFs) + Calculate Texture Characteristics + Create Publication Ready Plots + Writing Scripts to Process Many Data Sets + + Pole Figure TutorialImport diffraction data + Plot Raw Data + ODF Estimation + Quantify the Reconstruction Error + Visualize the ODF + + Short EBSD Analysis TutorialData import + Visualize EBSD data + + FAQWhy is there no graphical user interface? + Why Matlab? + Which Matlab version and which toolboxes do I need? + I get crazy plots, empty plots, plot with wrong colors + I have crazy characters in my plots. What can I do? + How can I import my data + MTEX fails to import EBSD OSC files + + Compiling MTEXIntroduction + Pre-requisits + Compiling MTEX + Checking Your Installation + + + Function ReferenceClasses representing GeometrySpecimen Directions (The Class @vector3d)Class Description + SchmidTensor + abs + angle + angle_outer + arrow3d + calcDelaunay + calcQuadratureWeights + calcVoronoi + calcVoronoiArea + cat + char + circle + contour + contourf + cross + cross_outer + ctranspose + display + dot + dot_outer + double + end + eq + export + find + horzcat + interp + isPerp + isempty + kernelDensityEstimation + length + line + mean + minus + mtimes + ne + norm + normalize + orth + orthProj + pcolor + perp + plot + plot3d + plotCustom + plus + polar + project2FundamentalRegion + quiver + rdivide + refine + region + repmat + reshape + rotate + scatter + scatter3d + size + smooth + subSet + subsasgn + subsref + sum + surf + symmetrise + text + text3 + times + transpose + uminus + unique + + vertcat + + Crystal Directions (The Class @Miller)Class Description + + cat + char + display + dot + dot_outer + dspacing + project2FundamentalRegion + region + rotate + round + scatter + smooth + surf + symmetrise + text + transformReferenceFrame + unique + + Discretisation of 1-Sphere (The Class @S1Grid)GridLength + + coarser + delete + display + dist + dist_outer + double + eq + find + max + min + minus + plot + plus + refine + shift + subGrid + + Discretisation of 2 - Sphere (The Class @S2Grid)Class Description + + cat + copy + delete + display + find + getdata + polar + refine + subGrid + subsasgn + subsref + + Quaternions (The Class @quaternion)Class Description + Euler + Rodrigues + angle + angle_outer + axis + calcVoronoi + cat + char + cross + ctranspose + display + dot + dot_angle + dot_outer + double + end + eq + export + find + horzcat + inv + isempty + length + log + matrix + mean + mean_CS + minus + mldivide + mpower + mrdivide + mtimes + ndims + ne + norm + normalize + permute + pertube + perturbe + plot + plus + power + prod + project2EulerFR + project2FundamentalRegion + qmatrix + qq + + rdivide + real + repmat + reshape + scatter + setSubSet + size + subSet + subsasgn + subsref + sum + symmetrise + times + transpose + uminus + unique + vertcat + + Rotations (The Class @rotation)Class Description + cat + char + display + dot + dot_outer + getMinAxes + isImproper + matrix + mldivide + mtimes + permute + project2FundamentalRegion + repmat + reshape + + subSet + subsasgn + subsref + times + transpose + uminus + unique + + Crystal and Specimen Symmetries (The Class @symmetry)Class Description + Laue + LaueName + alignment + calcAngleDistribution + calcAxisDistribution + calcQuat + check + disjoint + ensureCS + eq + factor + fundamentalRegion + fundamentalRegionEuler + fundamentalSector + length + maxAngle + multiplicityPerpZ + multiplicityZ + nfold + plot + properGroup + properSubGroup + rotation_special + subsref + + union + + Crystal Orientations (The Class @orientation)Class Description + BCV + KLCV + LSCV + angle + axis + bingham_test + calcAngleDistribution + calcBinghamODF + calcFourierODF + calcKernel + calcKernelODF + calcMDF + calcMIndex + calcODF + calcTensor + crossCorrelation + display + dot + dot_outer + export_VPSC + fibreVolume + getFundamentalRegion + inv + isMisorientation + ldivide + mean + mldivide + mtimes + niceEuler + + plot + plotIPDF + plotPDF + plotSection + project2EulerFR + project2FundamentalRegion + qqplot + scatter + sphereVolume + symmetrise + times + transformReferenceFrame + unique + volume + + Discretisation of Orientation Space (The Class SO3Grid) + char + copy + delete + display + dot_outer + find + mtimes + spy + subGrid + subsasgn + subsref + + + Classes for Quantitative Texture AnalysisOrientation Density Functions (The Class @ODF)Class Description + FourierODF + + bandwidth + calcAngleDistribution + calcAxisDistribution + calcAxisVolume + calcError + calcFourier + calcMDF + calcMIndex + calcModes + calcOrientations + calcPDF + calcPoleFigure + calcTensor + calcpdf_special3 + centerSpecimen + concentration + conv + discreteSample + display + entropy + eval + export + export_VPSC + export_generic + export_mtex + fibreVolume + hist + isFourier + max + maxpdf + mean + minus + mrdivide + mtimes + neuralgas + norm + plot + plot3d + plotDiff + plotFibre + plotFourier + plotIPDF + plotPDF + plotSection + plus + quantile + rdivide + rotate + slope + smooth + textureindex + times + uminus + volume + + Standard ODFsBinghamODF + FourierODF + SantaFe + femODF + fibreODF + mix2 + uniformODF + unimodalODF + + ODF Shapes (The class @kernel)Class Description + K_symmetrised + RK_symmetrised + + plot + plotFourier + plotPDF + volume + + Pole Figure Data (The Class @PoleFigure)Class Description + + calcError + calcErrorPF + calcFEMODF + calcNormalization + calcODF + calcPoleFigure + cat + char + correct + display + export + findOutlier + isOutlier + isempty + max + mean + min + minus + mrdivide + mtimes + noisepf + normalize + plot + plotDiff + plot_zero_range + plus + rdivide + rotate + scale + select + subsasgn + subsref + times + uminus + union + unique + zeroRange + + Electron Backscatter Diffraction Data (The Class @EBSD)Class Description + + KAM + affinetrans + calcGrains + calcMisorientation + calcTensor + cat + char + display + export + export_h5 + extend + fill + fillByGrainId + findByLocation + findByOrientation + fliplr + flipud + inpolygon + mtimes + plot + reduce + rotate + shift + smooth + spatialProfile + subSet + subsasgn + subsref + + Material Tensors (The Class @tensor)ChristoffelTensor + EinsteinSum + Fourier + PoissonRatio + Voigt + YoungsModulus + calcShearStress + char + checkSymmetry + conj + ctranspose + directionalMagnitude + display + double + eig + eq + expm + horzcat + inv + length + linearCompressibility + logm + matrix + max + min + minus + mrdivide + mtimes + ne + numel + plot + plotS2Grid + plus + quadric + quiverGrid + rdivide + real + rotate + shearModulus + size + subsasgn + subsref + sum + symmetrise + + tensorSize + times + transform + transformReferenceFrame + transpose + velocity + vertcat + volumeCompressibility + + + Auxiliary FunctionsPlotting Tools + Geometry ToolsCSL + EulerAngleConvention + Miller2quat + axis2quat + axis2quat_outer + brassOrientation + checkEulerAngleConvention + cubeOrientation + equispacedS2Grid + equispacedSO3Grid + euler2quat + expquat + fibre2quat + gossOrientation + guessfibre + hr2quat + idRotation + idquaternion + inversion + loadCIF + loadPHL + localOrientationGrid + mat2quat + nanquaternion + plotS2Grid + plotSO3Grid + randq + randv + reflection + regularS2Grid + regularSO3Grid + rodrigues2quat + vec42quat + xvector + yvector + zvector + + Statisticsc_hat + discretesample + quantile + randp + range + + Plotting + + + Crystal GeometrySpecimen DirectionsCartesian Coordinates + Polar Coordinates + Calculating with Specimen Directions + Lists of vectors + Indexing lists of vectors + + RotationsEuler Angle Conventions + Other Ways of Defining a Rotation + Calculating with Rotations + Improper Rotations + Conversion into Euler Angles and Rodrigues Parametrisation + Plotting Rotations + + Crystal SymmetriesCrystallographic Space, Point and Laue Groups + The Crystal Coordinate System + Calculations + Plotting symmetries + + Crystal DirectionsDefinition + Trigonal and Hexagonal Convention + Symmetrically Equivalent Crystal Directions + Angles + Conversions + Calculations + + Crystal OrientationsDefining a Crystal Orientation + Rotating Crystal Directions onto Specimen Directions + Concatenating Rotations + Calculating Misorientations + Calculating with Orientations and Rotations + Conversion into Euler Angles and Rodrigues Parametrisation + Plotting Orientations + + MisorientationsMisorientations between grains + Coinsident lattice planes + Twinning misorientations + Highlight twinning boundaries + Phase transitions + + Antipodal SymmetryDirections vs. Axes + The Angle between Directions and Axes + Antipodal Symmetry in Experimental Pole Figures + Antipodal Symmetry in Recalculated Pole Figures + Antipodal Symmetry in Inverse Pole Figures + EBSD Colocoding + + Fundamental RegionsThe complete, symmetry free, orientation space + Crystal Symmetries + Change the center of the fundamental region + Fundamental regions of misorientations + Fundamental regions of misorientations with antipodal symmetry + Axis angle sections + + + ODFsThe SantaFe exampleSimulate pole figures + ODF Estimation with Ghost Correction + ODF Estimation without Ghost Correction + Error analysis + Plot estimated pole figures + Plot estimated ODF (Ghost Corrected) + Plot odf + Plot Fourier Coefficients + + Model ODFsIntroduction + The Uniform ODF + Unimodal ODFs + Fibre ODFs + ODFs given by Fourier coefficients + Bingham ODFs + Combining model ODFs + + Importing and Exporting ODF DataDefine an Model ODF + Save as .mat file + Export as an generic ASCII file + Export an ODF to an MTEX ASCII File + Export to VPSC format + Import ODF Data using the import wizard + Importing EBSD data using the method loadODF + + Simulating Pole Figure dataIntroduction + Simulate Pole Figure Data + ODF Estimation from Pole Figure Data + Exploration of the relationship between estimation error and number of single orientations + + Simulating EBSD dataSimulate EBSD Data + ODF Estimation from EBSD Data + Exploration of the relationship between estimation error and number of single orientations + + Characterizing ODFsModal Orientations + Texture Characteristics + Volume Portions + Fourier Coefficients + Pole Figures and Values at Specific Orientations + Extract Internal Representation + + Visualizing ODFsPole Figures + Inverse Pole Figures + ODF Sections + Plotting the ODF along a fibre + Fourier Coefficients + Axis / Angle Distribution + + Detecting sample symmetryA synthetic example + Reconstruct an ODF from simulated EBSD data + Detect the sample symmetry axis in the reconstructed ODF + Sample symmetry in an ODF computed from pole figure data + + Misorientation Distribution FunctionComputing a misorientation distribution function from EBSD data + Computing the uncorrelated misorientation function from two ODFs + Analyzing misorientation functions + + + Pole FiguresFirst StepsImport of Pole Figures + Plotting Pole Figure Data + Modify Pole Figure Data + Calculate an ODF from Pole Figure Data + Simulate Pole Figure Data + + Importing Pole Figure DataImporting pole figure data using the import wizard + Supported Data Formats + The Import Script + Writing your own interface + loadPoleFigure + loadPoleFigure_generic + loadPoleFigure_aachen + loadPoleFigure_beartex + + Modify Pole Figure DataImport diffraction data + Splitting and Reordering of Pole Figures + Correct pole figure data + Normalize pole figures + Modify certain pole figure values + Remove certain measurements from the data + Rotate pole figures + + ODF Estimation from Pole Figure DataODF Estimation + Error analyis + Discretization + Zero Range Method + Ghost Corrections + Theory + + Ambiguity of the Pole Figure to ODF Reconstruction ProblemThe ambiguity due to too few pole figures + The ambiguity due to too Fridel's law + The inherent ambiguity of the pole figure - ODF relationship + + Ghost Effect AnalysisIntroduction + Construct Model ODF + Simulate pole figures + ODF Estimation + Compare RP Errors + Compare Reconstruction Errors + Plot the ODFs + Calculate Fourier coefficients + Calculate Reconstruction Errors from Fourier Coefficients + Plot Fourier Coefficients + + Simulating Pole Figure dataIntroduction + Simulate Pole Figure Data + ODF Estimation from Pole Figure Data + Exploration of the relationship between estimation error and number of single orientations + + Plotting of Pole FiguresImport of Pole Figures + Visualize the Data + Contour Plots + Plotting Recalculated Pole Figures + + + EBSDShort EBSD Analysis TutorialData import + Visualize EBSD data + + Importing EBSD DataImporting EBSD data using the import wizard + Supported Data Formats + The Import Script + Writing your own interface + + Modify EBSD DataSelecting a certain phase + Restricting to a region of interest + Remove Inaccurate Orientation Measurements + + Smoothing of EBSD DataSmoothing a single grains + Interpolating Missing Data + + Analyze EBSD DataData import + Orientation plot + + Plotting Individual OrientationsScatter Pole Figure Plot + Scatter (Inverse) Pole Figure Plot + Scatter Plot in ODF Sections + Scatter Plot in Axis Angle or Rodrigues Space + Orientation plots for EBSD and grains + + ODF Estimation from EBSD dataODF Estimation + Automatic halfwidth selection + Effect of halfwidth selection + + Bingham distribution and EBSD dataBingham Distribution + The bipolar case and unimodal distribution + Prolate case and fibre distribution + Oblate case + + Plotting spatially indexed EBSD dataPhase Plots + Visualizing arbitrary properties + Visualizing orientations + Customizing the color + Combining different plots + + Visualizing EBSD data with sharp texturesSharpening the default colorcoding + + Simulating EBSD dataSimulate EBSD Data + ODF Estimation from EBSD Data + Exploration of the relationship between estimation error and number of single orientations + + + GrainsGrain ReconstructionBasic grain reconstruction + The grainId and how to select EBSD inside specific grains + Misorientation to mean orientation + Filling not indexed holes + Grain smoothing + Grain reconstruction by the multiscale clustering method + + Working with GrainsAccessing individual grains + Indexing by a Condition + Indexing by orientation or position + Grain-size Analysis + Spatial Dependencies + + Plotting grainsPlotting grains and combined plots + Visualizing grain boundaries + + Analyzing Individual GrainsConnection between grains and EBSD data + Visualize the misorientation within a grain + Testing on Bingham distribution for a single grain + Profiles through a single grain + + Misorientation AnalysisDefinition + The sample data set + Intragranular misorientations + Boundary misorientations + The angle distribution + The axis distribution + + + Grain BoundariesGrain BoundariesThe grain boundary + Visualizing special grain boundaries + + Twinning AnalysisData import and grain detection + Properties of grain boundaries + Merge twins along twin boundaries + Grain relationships + Calculate the twinned area + Setting Up the EBSD Data for the Merged Grains + + CSL BoundariesData import and grain detection + Detecting CSL Boundaries + Merging grains with common CSL(3) boundary + Colorizing misorientations + Misorientations in the 3d fundamental zone + Analyzing the misorientation distribution function + + Triple pointsCalculation of triple points + Index triple points by phase + Index triple points by grains + Index triple points by grain boundary + Boundary segments from triple points + + + TensorsTensor ArithmeticsDefining a Tensor + Importing a Tensor from a File + Visualization + Rotating a Tensor + The Inverse Tensor + Tensor Products + + Average Material TensorsImport EBSD Data + Data Correction + Define Elastic Stiffness Tensors for Glaucophane and Epidote + The Average Tensor from EBSD Data + ODF Estimation + The Average Tensor from an ODF + + The Elasticity TensorImport an Elasticity Tensor + Young's Modulus + Linear Compressibility + Christoffel Tensor + Elastic Wave Velocity + + Plastic DeformationSchmidt factor + The Schmid tensor + Finding the active slip system + Finding the active slip system + + The Piezoelectricity TensorPlotting the magnitude surface + Mean Tensor Calculation + + Seismic velocities and anisotropyCrystal Symmetry and definition of the elastic stiffness tensor + compute maximum and minimum velocities + Plotting section + AVS : Plot S-wave anisotropy percentage for each proppagation direction + S1 Polarization: Plot fastest S-wave (Vs1) polarization directions + Vs1 : Plot Vs1 velocities (km/s) + Vs2 : Plot Vs2 velocities (km/s) + dVs : Plot Velocity difference Vs1-Vs2 (km/s) plus Vs1 polarizations + Vp/Vs1 : Plot Vp/Vs1 ratio (no units) + Vp/Vs2 : Plot Vp/Vs2 ratio (no units) + + + PlottingPlotting OverviewPlotting in MTEX + Plot Types + Spherical Projections + Color Coding + Plot Annotations + Combined Plots + Exporting Plots + + AnnotationsColorbars + Annotating Directions, Orientations, Fibres + Legends + + Combinded PlotsGeneral Principle + Combine Different EBSD Data + Combine countoured pole figures (smooth ODF plots) with EBSD Data Scatter Plots + Add Miller Indices to an Inverse Pole Figure Plot + Combining different plots in one figure + + Plot TypesA Sample ODFs + Scatter Plots + Contour Plots + Filled Contour Plots + Smooth Interpolated Plots + Line Plots + + Spherical ProjectionsIntroduction + Alignment of the Hemishpheres + Alignment of the Coordinate Axes + Equal Area Projection (Schmidt Projection) + Equal Distance Projection + Stereographic Projection (Equal Angle Projection) + Plain Projection + Three Dimensional Plots + + Pole Figure Color CodingA sample ODFs and Simulated Pole Figure Data + Setting a Colormap + Tight Colorcoding + Equal Colorcoding + Setting an Explicite Colorrange + Setting the Contour Levels + Modifying the Color range After Plotting + Logarithmic Plots + + EBSD Color CodingSee also + Colorcoding of orientations + Assigning the Euler angles to the RGB values + Colorcoding according to inverse pole figure + + + Release NotesMTEX ChangelogMTEX 4.2 - 11/2015 + MTEX 4.1 - 09/2015 + MTEX 4.0.0 - 10/2014 + MTEX 3.5.0 - 12/2013 + MTEX 3.4.2 - 06/2013 + MTEX 3.4.1 - 04/2013 + MTEX 3.4.0 - 03/2013 + MTEX 3.3.2 - 01/2013 + MTEX 3.3.1 - 07/2012 + MTEX 3.3.0 - 06/2012 + MTEX 3.2.3 - 03/2012 + MTEX 3.2.1 - 11/2011 + MTEX 3.2 - 05/2011 + MTEX 3.1 - 03/2011 + MTEX 3.0 - 10/2010 + MTEX 2.0 - 10/2009 + MTEX 1.2 - 05/2009 + MTEX 1.1 - 12/2008 + MTEX 1.0 - 06/2008 + MTEX 0.4 - 04/2008 + MTEX 0.3 - 10/2007 + MTEX 0.2 - 07/2007 + MTEX 0.1 - 03/2007 + + List of Known BugsOpen Issues + + RoadmapAssigned to Next Minor Release + Planned for Next Minor Release + Assigned to Next Major Release + Future + Supported/Implemented since MTEX 3.3 + Supported/Implemented since MTEX 3.1 + Supported/Implemented since MTEX 3.* + + About MTEXAuthors + Website + Credits + + + + \ No newline at end of file diff --git a/info.xml b/info.xml index ea3415426..d848fe6aa 100644 --- a/info.xml +++ b/info.xml @@ -7,6 +7,6 @@ MTEX toolbox mtex_icon.gif -help/mtex +doc/html From 2941d670815f5fa9c7e551392f2da4669ac37f19 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 17:03:45 +0100 Subject: [PATCH 006/120] fix for matlab 2016a --- .gitignore | 3 ++- startup_mtex.m | 2 +- tools/misc_tools/check_installation.m | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a01e32d6b..d2a5affad 100644 --- a/.gitignore +++ b/.gitignore @@ -11,10 +11,11 @@ c/mex/win64/* c/mex/maci64/* c/mex/maci/* data/cif/* -examples/html +doc/html *.mat *~ *swp +*swo *.directory *.orig help/mtex/* diff --git a/startup_mtex.m b/startup_mtex.m index 1a1328f03..f11977c6d 100644 --- a/startup_mtex.m +++ b/startup_mtex.m @@ -10,7 +10,7 @@ function startup_mtex(varargin) % this is a bugfix for MATLAV having very high cpu load on idle if isunix && ~ismac try - com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType('HTMLRENDERER'); + %com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType('HTMLRENDERER'); % to revert: %com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType([]); end diff --git a/tools/misc_tools/check_installation.m b/tools/misc_tools/check_installation.m index 323bd91c0..a4236465e 100644 --- a/tools/misc_tools/check_installation.m +++ b/tools/misc_tools/check_installation.m @@ -190,7 +190,7 @@ % check for existence mex = {'quaternion_*','S1Grid_*','S2Grid_*','SO3Grid_*'}; for k=1:numel(mex) - cfile = dir(fullfile(mexpath,'..', [mex{k} '*.c'])); + cfile = dir(fullfile(mexpath,'..', [mex{k} '.c'])); for c=1:numel(cfile) [a,cname] = fileparts(cfile(c).name); mexfile = fullfile(mexpath, [cname,'.' mexext]); From 3f9dbf072901d1d222b8e5d42ab84245b60dba7d Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 21:43:29 +0100 Subject: [PATCH 007/120] docu --- doc/BoundaryAnalysis/TwinningAnalysis.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/BoundaryAnalysis/TwinningAnalysis.m b/doc/BoundaryAnalysis/TwinningAnalysis.m index ee003789f..b5a015c01 100644 --- a/doc/BoundaryAnalysis/TwinningAnalysis.m +++ b/doc/BoundaryAnalysis/TwinningAnalysis.m @@ -16,6 +16,11 @@ % segment grains [grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd('indexed'),'angle',5*degree) +% remove two pixel grains +ebsd(grains(grains.grainSize<=2)) = []; +[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd('indexed'),'angle',5*degree) + + % smooth them grains = grains.smooth From 12d2f4712c915b41c154744fbb3e0c625e61987a Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 21:44:46 +0100 Subject: [PATCH 008/120] fixes mtex-toolbox/mtex#136 update triple junctions after merging --- EBSDAnalysis/@grain2d/merge.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/EBSDAnalysis/@grain2d/merge.m b/EBSDAnalysis/@grain2d/merge.m index e080508e1..af00d620f 100644 --- a/EBSDAnalysis/@grain2d/merge.m +++ b/EBSDAnalysis/@grain2d/merge.m @@ -90,3 +90,6 @@ grains_merged.prop.meanRotation(newInd(i)) = rotation(... mean(orientation(grains.prop.meanRotation(ind),cs),'weights',grains.grainSize(ind))); end + +% update triple points +grains_merged.boundary.triplePoints = grains_merged.boundary.calcTriplePoints(grains_merged.phaseId); \ No newline at end of file From bd3c62cec7585704e36540355fa4d7b402177705 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 21:59:20 +0100 Subject: [PATCH 009/120] align fundamental sector by default with [100] to east some fixes to the fundamental sector --- geometry/@Miller/Miller.m | 16 +++--- geometry/@Miller/scatter.m | 4 +- geometry/@Miller/smooth.m | 8 +-- geometry/@Miller/surf.m | 4 +- geometry/@Miller/text.m | 2 +- geometry/@symmetry/fundamentalSector.m | 53 +++++++------------ plotting/tools/getCamera.m | 6 ++- plotting/tools/setCamera.m | 10 +++- .../HSVOrientationMapping.m | 16 +++--- 9 files changed, 62 insertions(+), 57 deletions(-) diff --git a/geometry/@Miller/Miller.m b/geometry/@Miller/Miller.m index b2af76fd2..cb581e9fa 100644 --- a/geometry/@Miller/Miller.m +++ b/geometry/@Miller/Miller.m @@ -356,13 +356,17 @@ m.dispStyle = 'UVTW'; end + + function opt = plotOptions(m) + % rotate the aAxis to the east + % but take only multiples of 90 degrees, + % since Matlab is not able to handle the values in between + rho = -round(m.CS.aAxis.rho / 90 / degree)*90*degree; + opt = {'xAxisDirection',rho,'zAxisDirection','outOfPlane'}; + end end - -methods (Static = true) - function opt = plotOptions - opt = {'xAxisDirection','east','zAxisDirection','outOfPlane'}; - end -end + + end diff --git a/geometry/@Miller/scatter.m b/geometry/@Miller/scatter.m index c7f1166c0..12e7d2a24 100644 --- a/geometry/@Miller/scatter.m +++ b/geometry/@Miller/scatter.m @@ -50,9 +50,9 @@ end if numel(varargin) > 0 && isnumeric(varargin{1}) - varargin = [varargin(1),Miller.plotOptions,varargin(2:end)]; + varargin = [varargin(1),m.plotOptions,varargin(2:end)]; else - varargin = [Miller.plotOptions,varargin]; + varargin = [m.plotOptions,varargin]; end % plot them all with the same color diff --git a/geometry/@Miller/smooth.m b/geometry/@Miller/smooth.m index 420dddf25..1810bf112 100644 --- a/geometry/@Miller/smooth.m +++ b/geometry/@Miller/smooth.m @@ -15,9 +15,9 @@ if isfield(m.opt,'plot') if ~isempty(varargin) && isnumeric(varargin{1}) - varargin = [varargin{1},Miller.plotOptions,varargin(2:end)]; + varargin = [varargin{1},m.plotOptions,varargin(2:end)]; else - varargin = [Miller.plotOptions,varargin]; + varargin = [m.plotOptions,varargin]; end else @@ -26,9 +26,9 @@ m = symmetrise(m,'skipAntipodal'); if ~isempty(varargin) && isnumeric(varargin{1}) - varargin = [{repmat(varargin{1}(:).',size(m,1),1)},Miller.plotOptions,varargin(2:end)]; + varargin = [{repmat(varargin{1}(:).',size(m,1),1)},m.plotOptions,varargin(2:end)]; else - varargin = [Miller.plotOptions,varargin]; + varargin = [m.plotOptions,varargin]; end m = m(:); diff --git a/geometry/@Miller/surf.m b/geometry/@Miller/surf.m index ba3c4e8cf..8be534f48 100644 --- a/geometry/@Miller/surf.m +++ b/geometry/@Miller/surf.m @@ -11,7 +11,7 @@ % See also % -h = surf@vector3d(m,cdata,... - 'xAxisDirection','east','zAxisDirection','outOfPlane',varargin{:}); +opt = m.plotOptions; +h = surf@vector3d(m,cdata,opt{:},varargin{:}); if nargout == 0, clear h; end diff --git a/geometry/@Miller/text.m b/geometry/@Miller/text.m index 830c7b6fa..14b8b917c 100644 --- a/geometry/@Miller/text.m +++ b/geometry/@Miller/text.m @@ -36,6 +36,6 @@ function text(m,varargin) end % ensure specific plot options -varargin = [varargin(1),Miller.plotOptions,varargin(2:end)]; +varargin = [varargin(1),m.plotOptions,varargin(2:end)]; text@vector3d(m,varargin{:}); diff --git a/geometry/@symmetry/fundamentalSector.m b/geometry/@symmetry/fundamentalSector.m index 617fd3762..ef7a48552 100644 --- a/geometry/@symmetry/fundamentalSector.m +++ b/geometry/@symmetry/fundamentalSector.m @@ -48,63 +48,49 @@ aAxis = xvector; end +% rotate fundamental sector such that it start with the aAxis +N = rotate(N,aAxis.rho); + % some special cases switch cs.id case 1 % 1 case 2 % -1 N = zvector; - case {3,6,9} % 2 + case {3,6,9} % 211, 121, 112 if isnull(dot(getMinAxes(cs),zvector)) - N = zvector; - else - ind = find(isnull(dot(getMinAxes(cs),cs.axes)),1); - N = cs.axes(ind); + N = zvector; end - case {4,7,10} % m + case {4,7,10} % m11, 1m1, mm1 N = getMinAxes(cs); case 5 % 2/m11 - N = rotate(N,-90*degree); - case {8,11} % 12/m1 112/m - case 12 % 222 + N = rotate(N,-90*degree); + case {8,11} % 12/m1 112/m + case 12 % 222 case {13,14,15} % 2mm, m2m, mm2 N = cs.subSet(cs.isImproper).axis; % take mirror planes - case 16 % mmm + case 16 % mmm case 17 % 3 - case 18 % 3, -3 - N = rotate(N,-mod(round(aAxis.rho./degree)+30,120)*degree); - case {19,20,21} % 32, 3m, -3m - N = rotate(N,-mod(round(aAxis.rho./degree)+30,120)*degree); - case {22,23,24} - N = rotate(N,-mod(round(aAxis.rho./degree),60)*degree); + case 18 % -3 + case {19,20,21} % 321, 3m1, -3m1 + N = rotate(N,-30*degree); + case {22,23,24} % 312, 31m, -31m case 30 %-42m N = rotate(N,-45*degree); case {33,34,35,36} % 6, 622 - N = rotate(N,-mod(round(aAxis.rho./degree+30),60)*degree); - case 38 % 62m - N = rotate(N,-mod(round(aAxis.rho./degree),60)*degree); + case 38 % -62m case 39 % 6m2 - N = rotate(N,-mod(round(aAxis.rho./degree+30),60)*degree); - case 41 % 23 - %N = [vector3d(0,-1,1),vector3d(-1,0,1),vector3d(1,0,1),yvector,zvector]; + N = rotate(N,-30*degree); + case 41 % 23 N = vector3d([1 1 0 0],[1 -1 1 -1],[0 0 1 1]); - case 42 % m-3 - N = [vector3d(0,-1,1),vector3d(-1,0,1),xvector,yvector,zvector]; - case 43 % 432 - N = [vector3d(1,-1,0),vector3d(0,-1,1),yvector]; + case {42,43} % m-3, 432 + N = [vector3d(0,-1,1),vector3d(-1,0,1),xvector,yvector,zvector]; case 44 % -43m N = [vector3d(1,-1,0),vector3d(1,1,0),vector3d(-1,0,1)]; case 45 % m-3m N = [vector3d(1,-1,0),vector3d(-1,0,1),yvector]; end -% correct for different x-Axis alignments -%x = (find(strcmp(NWSE,getMTEXpref('xAxisDirection')))-1)*90*degree; -%z = find(strcmp(UpDown,getMTEXpref('zAxisDirection')))-1; -%dOmega = (-1)^z * x; -%dOmega = z*90*degree + round(dOmega/pi*cs.multiplicityZ)*pi/cs.multiplicityZ; -%N = rotate(N,-dOmega); - % this will be restricted later anyway if check_option(varargin,{'upper','lower','maxTheta','minTheta'}) N(N.x==0 & N.y==0) = []; @@ -131,4 +117,3 @@ end sR = sR.cleanUp; - diff --git a/plotting/tools/getCamera.m b/plotting/tools/getCamera.m index e08994d5a..5e0c0cebb 100644 --- a/plotting/tools/getCamera.m +++ b/plotting/tools/getCamera.m @@ -20,4 +20,8 @@ end xDirs = {'east','north','west','south'}; -xDir = xDirs{1+mod(az/90,4)}; +try + xDir = xDirs{1+mod(az/90,4)}; +catch + xDir = -az * degree; +end diff --git a/plotting/tools/setCamera.m b/plotting/tools/setCamera.m index c6c710c83..76d4fb4db 100644 --- a/plotting/tools/setCamera.m +++ b/plotting/tools/setCamera.m @@ -23,7 +23,11 @@ function setCamera(varargin) zAxis = get_option(varargin,'zAxisDirection',zAxis); % set camera according to projection -el = (1-NWSE(xAxis))*90; +if ischar(xAxis) + el = (1-NWSE(xAxis))*90; +else + el = round(-xAxis / degree); +end az = 90; if strcmpi(zAxis,'intoPlane') el = -el; @@ -31,3 +35,7 @@ function setCamera(varargin) end view(ax,el,az); +%set(ax,'CameraTarget',[0,0,0]) +%set(ax,'CameraPosition',[0,0,10000]) +%set(ax,'CameraPositionMode','manual') +%set(ax,'CameraUpVector',[sin((-el)*degree),cos((-el)*degree),0]) \ No newline at end of file diff --git a/tools/orientationMappings/HSVOrientationMapping.m b/tools/orientationMappings/HSVOrientationMapping.m index 47263c0de..c48245d4a 100644 --- a/tools/orientationMappings/HSVOrientationMapping.m +++ b/tools/orientationMappings/HSVOrientationMapping.m @@ -24,7 +24,7 @@ sR = sphericalRegion end - properties (Access = private) + properties %(Access = private) refl = []; rot = rotation(idquaternion); alpha = 0; @@ -59,18 +59,22 @@ function updatesR(oM) case {3,6,9}, % 211, 121, 112 pm = 1-2*isPerp(cs.subSet(2).axis,zvector); oM.refl = rotate(oM.sR.N,rotation('axis',cs.subSet(2).axis,'angle',pm*90*degree)); - case {11,12}, oM.refl = rotate(oM.sR.N(2),-90*degree); % 222 + case {5,8,11,12}, oM.refl = rotate(oM.sR.N(2),-90*degree); % 222 case 17, oM.refl = -rotate(sum(oM.sR.N),90*degree); % 3 - case {18,19,22}, oM.refl = r30 .* oM.sR.N(end-1:end); % -3, 321, 312 + case {18,19,22} + oM.refl = r30 .* oM.sR.N(end-1:end); % -3, 321, 312 + if angle(oM.refl(1),oM.refl(2)) < 1*degree + oM.refl = inv(r30) .* oM.sR.N(end-1:end); + end case {21,24}, oM.refl = rotate(sum(oM.sR.N(2:3)),90*degree); % -31m, -3m1 case {25,27,28}, oM.refl = rotate(oM.sR.N(end),-45*degree); % 4,4/m,422 case 26, oM.refl = rotate(oM.sR.N(end),-90*degree); % -4 case 30, oM.refl = yvector; % -42m case 31, oM.refl = -rotate(oM.sR.N(2),45*degree); % -4m2 case {33,35,36}, oM.refl = rotate(oM.sR.N(end),-30*degree); % 6,6/m, 622, - case 34, oM.refl = r30 .* oM.sR.N(end-1:end); % -6 - case {41,43}, oM.refl = vector3d(-1,0,1); % 23, 432 - case 42, oM.refl = vector3d(1,-1,0); % m-3 + case 34, oM.refl = rotate(oM.sR.N(end),-60*degree); % -6 + case {41}, oM.refl = vector3d(-1,0,1); % 23, 432 + case {42,43}, oM.refl = vector3d(1,-1,0); % m-3 end % reduce fundamental sector by reflectors for black-white colorcoding From 01e6d4f2ccabf1d1f233edbe5fa143e52b6664d9 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 8 Jan 2016 22:02:09 +0100 Subject: [PATCH 010/120] minor fixes --- geometry/@sphericalRegion/cleanUp.m | 6 ++++-- geometry/@sphericalRegion/polarCoordinates.m | 1 + geometry/@vector3d/surf.m | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/geometry/@sphericalRegion/cleanUp.m b/geometry/@sphericalRegion/cleanUp.m index bdc12a381..1245ac65d 100644 --- a/geometry/@sphericalRegion/cleanUp.m +++ b/geometry/@sphericalRegion/cleanUp.m @@ -5,5 +5,7 @@ sR.N(ind) = []; sR.alpha(ind) = []; -[sR.N,ind] = unique(sR.N); -sR.alpha = sR.alpha(ind); \ No newline at end of file +[~,ind] = unique(sR.N); +ind =sort(ind); +sR.N = sR.N(ind); +sR.alpha = sR.alpha(ind); diff --git a/geometry/@sphericalRegion/polarCoordinates.m b/geometry/@sphericalRegion/polarCoordinates.m index 7b00386e8..1a2b2765f 100644 --- a/geometry/@sphericalRegion/polarCoordinates.m +++ b/geometry/@sphericalRegion/polarCoordinates.m @@ -13,6 +13,7 @@ % the radius % ------------------------------------------------------------------- +v = vector3d(v); center = center.normalize; vxcenter = normalize(cross(v,center)); diff --git a/geometry/@vector3d/surf.m b/geometry/@vector3d/surf.m index ea3a9a4da..393a0ad67 100644 --- a/geometry/@vector3d/surf.m +++ b/geometry/@vector3d/surf.m @@ -37,7 +37,8 @@ % set styles optiondraw(h(j),'LineStyle','none','Fill','on',varargin{:}); - + + uistack(sP(j).grid,'top') end if nargout == 0, clear h; end From 20b5789024e71cdbea5fb55ef6c9a1b7cc88e3b0 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 9 Jan 2016 11:10:38 +0100 Subject: [PATCH 011/120] docu --- PoleFigureAnalysis/@PoleFigure/calcODF.m | 6 ++++++ help/make_mtex_help.m | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/PoleFigureAnalysis/@PoleFigure/calcODF.m b/PoleFigureAnalysis/@PoleFigure/calcODF.m index 14dfded07..2c3e2639a 100644 --- a/PoleFigureAnalysis/@PoleFigure/calcODF.m +++ b/PoleFigureAnalysis/@PoleFigure/calcODF.m @@ -10,7 +10,13 @@ % The function *calcODF* has several options to control convergence, % resolution, smoothing, etc. See below for a complete description. % +% Syntax % +% odf = calcODF(pf) +% odf = calcODF(pf,'halfwidth',5*degree) +% odf = calcODF(pf,'ZERO_RANGE') +% odf = calcODF(pf,'resolution',2.5*degree) +% % Input % pf - @PoleFigure % diff --git a/help/make_mtex_help.m b/help/make_mtex_help.m index 76829b7a2..a0438c8bb 100644 --- a/help/make_mtex_help.m +++ b/help/make_mtex_help.m @@ -53,7 +53,7 @@ function make_mtex_help(varargin) DocFile(fullfile(mtex_path,'VERSION'))]; -outputDir = fullfile(mtex_path,'help','mtex'); +outputDir = fullfile(mtex_path,'doc','html'); tempDir = fullfile(mtex_path,'help','tmp'); From 9016967ffa2e45fccd19f4853b965dd15d991705 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 9 Jan 2016 15:07:41 +0100 Subject: [PATCH 012/120] fix issue reported at https://groups.google.com/forum/#!topic/mtexmail/NscY5kMlDwE --- geometry/plotAngleDistribution.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/geometry/plotAngleDistribution.m b/geometry/plotAngleDistribution.m index ad1d2a1b7..0ca52ec79 100644 --- a/geometry/plotAngleDistribution.m +++ b/geometry/plotAngleDistribution.m @@ -29,6 +29,7 @@ % seach for existing bar plots and adjust bar center h = findobj(mtexFig.gca,'type','bar','-or','type','hgGroup'); +h = flipud(h(:)); unit = '%'; if ~isempty(h) @@ -39,7 +40,7 @@ bins = (bins(1:end-1) + bins(2:end))/2; density = ensurecell(get(h,'YData')); density = cellfun(@(x) x(:),density,'UniformOutput',false); - density = fliplr(horzcat(density{:})); + density = horzcat(density{:}); lg = ensurecell(get(h,'DisplayName')); if strcmp(plotType,'bar') @@ -103,7 +104,7 @@ h = optiondraw(plot(omega/degree,faktor * max(0,density),... 'parent',mtexFig.gca),'LineWidth',2,varargin{:}); - + end % finish From 68369c722391b8dc229eed58c7e5a24a09eb7669 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 9 Jan 2016 22:29:05 +0100 Subject: [PATCH 013/120] bug fix: Miller plots are not labeled correctly --- geometry/@Miller/scatter.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry/@Miller/scatter.m b/geometry/@Miller/scatter.m index 12e7d2a24..fbaeb3cec 100644 --- a/geometry/@Miller/scatter.m +++ b/geometry/@Miller/scatter.m @@ -36,7 +36,7 @@ [m,l] = symmetrise(m,'removeAntipodal',varargin{:}); % symmetrise without repetition if check_option(varargin,'label') - label = get_option(varargin,'label'); + label = ensurecell(get_option(varargin,'label')); label = rep(label,l); varargin = set_option(varargin,'label',label); end From eb4514c934e9471e50560d056b40589f4f21ae61 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 12 Jan 2016 14:14:34 +0100 Subject: [PATCH 014/120] allow to specify contourf levels by the option contour, contourf --- geometry/@vector3d/smooth.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/geometry/@vector3d/smooth.m b/geometry/@vector3d/smooth.m index c9e1ac4b0..249bd29af 100644 --- a/geometry/@vector3d/smooth.m +++ b/geometry/@vector3d/smooth.m @@ -63,7 +63,8 @@ % number of contour lines contours = get_option(varargin,'contours',50); - + contours = get_option(varargin,{'contourf','contour'},contours,'double'); + % specify contourlines explicitely if length(contours) == 1 contours = linspace(colorRange(1),colorRange(2),contours); From dc7857ac2724d64ff4aa09e007aff033aac18004 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 12 Jan 2016 16:27:39 +0100 Subject: [PATCH 015/120] minor --- geometry/@Miller/Miller.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/geometry/@Miller/Miller.m b/geometry/@Miller/Miller.m index cb581e9fa..2d1458ad6 100644 --- a/geometry/@Miller/Miller.m +++ b/geometry/@Miller/Miller.m @@ -361,7 +361,8 @@ % rotate the aAxis to the east % but take only multiples of 90 degrees, % since Matlab is not able to handle the values in between - rho = -round(m.CS.aAxis.rho / 90 / degree)*90*degree; + %rho = -fix(m.CS.aAxis.rho / 90 / degree)*90*degree; + rho = -m.CS.aAxis.rho; opt = {'xAxisDirection',rho,'zAxisDirection','outOfPlane'}; end end From c8e0552a01e27bc30c774c3305acfcd483404a58 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 13 Jan 2016 17:53:24 +0100 Subject: [PATCH 016/120] mtex 4.2.2 --- Makefile | 2 +- VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 22f14079a..f1cf6899a 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ clean: # rule for making release -RNAME = mtex-4.2.1 +RNAME = mtex-4.2.2 RDIR = ../releases release: rm -rf $(RDIR)/$(RNAME)* diff --git a/VERSION b/VERSION index ac592c860..20f771c69 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -MTEX 4.2.1 +MTEX 4.2.2 From 41b823e0085a01bb392e4558f5a6bb9144d16bbf Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 23 Jan 2016 21:28:40 +0100 Subject: [PATCH 017/120] minor --- geometry/@symmetry/private/hms2point.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/geometry/@symmetry/private/hms2point.m b/geometry/@symmetry/private/hms2point.m index a0677dd54..fff551046 100644 --- a/geometry/@symmetry/private/hms2point.m +++ b/geometry/@symmetry/private/hms2point.m @@ -1,13 +1,13 @@ function s = hms2point(s) % convert Herman – Mauguin (International) Symbol to point group % -%% Input +% Input % s - Herman – Mauguin (International) space group symbol % -%% Output +% Output % s - international point group symbol % -%% See also +% See also % % ignore first letter From 4935716db58b268e0ca636cc025e0eb11914ed3d Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 23 Jan 2016 21:29:47 +0100 Subject: [PATCH 018/120] fix mtex-toolbox/mtex#147 --- ODFAnalysis/@unimodalComponent/calcFourier.m | 1 + 1 file changed, 1 insertion(+) diff --git a/ODFAnalysis/@unimodalComponent/calcFourier.m b/ODFAnalysis/@unimodalComponent/calcFourier.m index 4dd71b617..d930a447b 100644 --- a/ODFAnalysis/@unimodalComponent/calcFourier.m +++ b/ODFAnalysis/@unimodalComponent/calcFourier.m @@ -64,6 +64,7 @@ function c_hat = gcA2fourier(g,c,A) % run NFSOFT +if length(A)< 3, A = [A;0]; end f = call_extern('odf2fc','EXTERN',g,c,A); % extract result From 8670d75e5f08bf2f979d54a661ef7c868a9772a7 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 23 Jan 2016 21:39:01 +0100 Subject: [PATCH 019/120] fix mtex-toolbox/mtex#144 discreteSample does not work so well for specimen symmetry --- ODFAnalysis/@ODF/discreteSample.m | 14 ++++++++++---- ODFAnalysis/@ODFComponent/discreteSample.m | 5 ++++- ODFAnalysis/@unimodalComponent/discreteSample.m | 8 +------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ODFAnalysis/@ODF/discreteSample.m b/ODFAnalysis/@ODF/discreteSample.m index 0a08b62b0..693d836a3 100644 --- a/ODFAnalysis/@ODF/discreteSample.m +++ b/ODFAnalysis/@ODF/discreteSample.m @@ -3,11 +3,11 @@ % % -ori = orientation.id(npoints,1,odf.CS,odf.SS); +q = quaternion.id(npoints,1); % which component if numel(odf.weights) == 1 - icmp = ones(size(ori)); + icmp = ones(size(q)); else icmp = discretesample(odf.weights,npoints); end @@ -15,7 +15,13 @@ % compute discrete sample for each component seperately for ic = 1:length(odf.components) - ori(icmp == ic) = discreteSample(odf.components{ic},sum(icmp==ic),varargin{:}); + q(icmp == ic) = discreteSample(odf.components{ic},sum(icmp==ic),varargin{:}); end - \ No newline at end of file + +cs = odf.CS.properGroup; +ss = odf.SS.properGroup; +ics = discretesample(length(cs),npoints,1); +iss = discretesample(length(ss),npoints,1); + +ori = orientation(ss(iss(:)) .* q .* cs(ics(:)),odf.CS,odf.SS); \ No newline at end of file diff --git a/ODFAnalysis/@ODFComponent/discreteSample.m b/ODFAnalysis/@ODFComponent/discreteSample.m index fbcdc1b47..a8eeddd82 100644 --- a/ODFAnalysis/@ODFComponent/discreteSample.m +++ b/ODFAnalysis/@ODFComponent/discreteSample.m @@ -2,6 +2,9 @@ % draw a random sample % +% does not work with specimen symmetry other then triclinic +SS = component.SS; +component.SS = specimenSymmetry; res = get_option(varargin,'resolution',5*degree); % some local grid @@ -19,4 +22,4 @@ q1 = quaternion(S3G_global,discretesample(d,npoints)); % combine local and global -ori = orientation(q1(:) .* q2(:),component.CS,component.SS); +ori = orientation(q1(:) .* q2(:),component.CS,SS); diff --git a/ODFAnalysis/@unimodalComponent/discreteSample.m b/ODFAnalysis/@unimodalComponent/discreteSample.m index d708efa93..cbcc5af6a 100644 --- a/ODFAnalysis/@unimodalComponent/discreteSample.m +++ b/ODFAnalysis/@unimodalComponent/discreteSample.m @@ -24,13 +24,7 @@ [~,t] = histc(r,c); angle = 2 * acos(t ./ M); -cs = component.CS.properGroup; -ss = component.SS.properGroup; -ics = discretesample(length(cs),npoints,1); -iss = discretesample(length(ss),npoints,1); - -q = ss(iss(:)) .* quaternion(component.center(:),ic) .* ... - axis2quat(axis,angle) .* cs(ics(:)); +q = quaternion(component.center(:),ic) .* axis2quat(axis,angle); % set up orientations ori = orientation(q,component.CS,component.SS); From 1662394e0d66c53cdacb8487fe38f52c5d183314 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 26 Jan 2016 15:02:32 +0100 Subject: [PATCH 020/120] direct access to the harmonic power of Fourier ODFs. --- .../@FourierComponent/FourierComponent.m | 12 ++++++++++ ODFAnalysis/@ODF/plotFourier.m | 23 ++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ODFAnalysis/@FourierComponent/FourierComponent.m b/ODFAnalysis/@FourierComponent/FourierComponent.m index 2ca1465c0..14408505a 100644 --- a/ODFAnalysis/@FourierComponent/FourierComponent.m +++ b/ODFAnalysis/@FourierComponent/FourierComponent.m @@ -10,6 +10,7 @@ properties (Dependent=true) bandwidth % harmonic degree + power % harmonic power end methods @@ -29,6 +30,10 @@ else component.f_hat = f_hat; end + + % truncate zeros + component.bandwidth = find(component.power>1e-10,1,'last'); + end function L = get.bandwidth(component) @@ -45,6 +50,13 @@ end end + function pow = get.power(component) + fhat = abs(component.f_hat).^2; + pow = zeros(component.bandwidth+1,1); + for l = 0:length(pow)-1 + pow(l+1) = sum(fhat(deg2dim(l)+1:deg2dim(l+1))) ./ (2*l+1); + end + end end end diff --git a/ODFAnalysis/@ODF/plotFourier.m b/ODFAnalysis/@ODF/plotFourier.m index ee428eb3e..121df2b23 100644 --- a/ODFAnalysis/@ODF/plotFourier.m +++ b/ODFAnalysis/@ODF/plotFourier.m @@ -1,6 +1,11 @@ function plotFourier(odf,varargin) % plots Fourier coefficients of the odf % +% Syntax +% +% plotFourier(odf) +% plotFourier(odf,'bandwidth',32) +% % Input % odf - @ODF % @@ -13,20 +18,16 @@ function plotFourier(odf,varargin) [mtexFig,isNew] = newMtexFigure(varargin{:}); -if isFourier(odf) - L = odf.components{1}.bandwidth; -else - L = 32; -end -L = get_option(varargin,'bandwidth',L); +L = get_option(varargin,'bandwidth',32); -odf_hat = calcFourier(odf,'bandwidth',L,'l2-normalization'); +if ~isFourier(odf), odf = FourierODF(odf,L); end -for l = 0:L - f(l+1) = norm(odf_hat(deg2dim(l)+1:deg2dim(l+1))); -end +power = zeros(L+1,1); +LL = min(L,odf.bandwidth); +power(1:LL+1) = odf.components{1}.power(1:LL+1); -optionplot(0:L,f,'Marker','o','linestyle',':','parent',mtexFig.gca,varargin{:}); +optionplot(0:L,power,'Marker','o','linestyle',':',... + 'parent',mtexFig.gca,varargin{:}); if isNew xlim(mtexFig.gca,[0,L]) From 0bf3c155cbf1efda89d545a70c45cc9f39030876 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 26 Jan 2016 22:07:14 +0100 Subject: [PATCH 021/120] fix a rounding bug reported here: https://groups.google.com/forum/#!topic/mtexmail/4rHHyyt_Uvw --- geometry/@Miller/round.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry/@Miller/round.m b/geometry/@Miller/round.m index b2d4decb4..3fc8b58d4 100644 --- a/geometry/@Miller/round.m +++ b/geometry/@Miller/round.m @@ -29,7 +29,7 @@ mNew = mOld(:,im) / mMax(im) * (1:maxHKL); - e = 1e-7*round(1e7 * sum(mNew - round(mNew)).^2./sum(mNew.^2)); + e = 1e-7*round(1e7 * sum((mNew - round(mNew)).^2)./sum(mNew.^2)); [minE,n] = min(e); From b06297cb2a1a291520bfddddbea151fff0801bd5 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 29 Jan 2016 16:36:54 +0100 Subject: [PATCH 022/120] minor --- geometry/@orientationRegion/checkInside.m | 1 + interfaces/import_wizard/private/pageSS.m | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/geometry/@orientationRegion/checkInside.m b/geometry/@orientationRegion/checkInside.m index 1704ca292..b7c7cdccc 100644 --- a/geometry/@orientationRegion/checkInside.m +++ b/geometry/@orientationRegion/checkInside.m @@ -2,6 +2,7 @@ % check for points to be inside the orientation region if isempty(oR.N), inside = true(size(q)); return; end +if isempty(q), inside = false(size(q)); return; end % verify all conditions are satisfies inside1 = dot_outer(oR.N,q)<1e-6; diff --git a/interfaces/import_wizard/private/pageSS.m b/interfaces/import_wizard/private/pageSS.m index af80de2c2..d0722b080 100644 --- a/interfaces/import_wizard/private/pageSS.m +++ b/interfaces/import_wizard/private/pageSS.m @@ -61,7 +61,7 @@ function localUpdateGUI() set(gui.hEuler2Spatial,'visible',states{s(1)}); set(gui.hSpecimen,'visible',states{s(2)}); - [p(1) p(2) p(3)] = Euler(getSS('rotate'),'ZXZ'); + [p(1), p(2), p(3)] = Euler(getSS('rotate'),'ZXZ'); for k=1:3 set(gui.hRotAngle(k),'String',xnum2str((round(p(k)*1000/degree)/1000))) end From a230ab111aade725ced7f6e9191fba684f475f79 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sun, 31 Jan 2016 16:36:26 +0100 Subject: [PATCH 023/120] bug fixes --- .../@orientation/project2FundamentalRegion.m | 16 +++++++++++++--- geometry/@quaternion/project2FundamentalRegion.m | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/geometry/@orientation/project2FundamentalRegion.m b/geometry/@orientation/project2FundamentalRegion.m index 99729c31e..cee902553 100644 --- a/geometry/@orientation/project2FundamentalRegion.m +++ b/geometry/@orientation/project2FundamentalRegion.m @@ -13,7 +13,17 @@ % omega - rotational angle to reference rotation % -if ori.antipodal, ap = {'antipodal'}; else ap = {}; end -q = project2FundamentalRegion(quaternion(ori),ori.CS,ori.SS,ap{:},varargin{:}); +if length(ori.SS) == 1 + q = project2FundamentalRegion(quaternion(ori),ori.CS,varargin{:}); +else + if ori.antipodal, ap = {'antipodal'}; else ap = {}; end + q = project2FundamentalRegion(quaternion(ori),ori.CS,ori.SS,ap{:},varargin{:}); +end -ori = orientation(q,ori.CS,ori.SS,ap{:}); \ No newline at end of file +% set values +sa = size(ori.a); +ori.a = reshape(q.a,sa); +ori.b = reshape(q.b,sa); +ori.c = reshape(q.c,sa); +ori.d = reshape(q.d,sa); +%ori = orientation(q,ori.CS,ori.SS); \ No newline at end of file diff --git a/geometry/@quaternion/project2FundamentalRegion.m b/geometry/@quaternion/project2FundamentalRegion.m index 7f1b7b9cb..05371712f 100644 --- a/geometry/@quaternion/project2FundamentalRegion.m +++ b/geometry/@quaternion/project2FundamentalRegion.m @@ -24,7 +24,7 @@ else - if isa(CS2,'symmetry') + if isa(CS2,'symmetry') && length(CS2) > 1 if nargin > 3 && isa(varargin{1},'quaternion') @@ -37,7 +37,7 @@ end else - q = project2FR_ref(q,CS1,CS2); + q = project2FR_ref(q,CS1,quaternion(CS2)); end From 5623dd70cc178bbdb4b867d63ebd41f6b0417340 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sun, 31 Jan 2016 16:51:37 +0100 Subject: [PATCH 024/120] recompute bounds on demand --- plotting/sphericalPlot.m | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index f042118d0..12dfa9c1d 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -58,17 +58,13 @@ else % plot boundary - sP.boundary = sP.sphericalRegion.plot('parent',ax); - + sP.boundary = sP.sphericalRegion.plot('parent',ax); try sP.plotPolarGrid(varargin{:});end + + sP.updateBounds; set(ax,'XTick',[],'YTick',[]); - axis(ax,'off'); - - % compute bounding box - x = ensurecell(get(sP.boundary,'xData')); x = [x{:}]; - y = ensurecell(get(sP.boundary,'yData')); y = [y{:}]; - sP.bounds = [min(x(:)),min(y(:)),max(x(:)),max(y(:))]; + axis(ax,'off'); if ~check_option(varargin,'grid') set(sP.grid,'visible','off'); end @@ -186,7 +182,16 @@ function doGridInFront(sP) set(sP.ax,'Children',[childs(istext); sP.boundary(:); sP.grid(:);childs(~isgrid & ~istext)]); end - end + end + + + function updateBounds(sP) + % compute bounding box + x = ensurecell(get(sP.boundary,'xData')); x = [x{:}]; + y = ensurecell(get(sP.boundary,'yData')); y = [y{:}]; + sP.bounds = [min(x(:)),min(y(:)),max(x(:)),max(y(:))]; + end + end methods (Access = private) @@ -257,7 +262,7 @@ function circ(sP,theta,varargin) sP.grid(end+1) = line(dx,dy,'parent',sP.ax,... 'handlevisibility','off','color',[.8 .8 .8]); - end + end end end From aa9242e039d1fc84fbc2c372532fb1dec7e1dd77 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Thu, 4 Feb 2016 09:41:55 +0100 Subject: [PATCH 025/120] make PoleFigure/correct to work also with full correction pole figures that have a different raster by using interpolation --- PoleFigureAnalysis/@PoleFigure/correct.m | 8 ++++++-- geometry/@vector3d/interp.m | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PoleFigureAnalysis/@PoleFigure/correct.m b/PoleFigureAnalysis/@PoleFigure/correct.m index 5f3088a4b..2087a377b 100644 --- a/PoleFigureAnalysis/@PoleFigure/correct.m +++ b/PoleFigureAnalysis/@PoleFigure/correct.m @@ -67,8 +67,12 @@ % otherwise interpolate according to theta try for i = 1:pf.numPF - pf_orig.allI{i} = interp1(pf.allR{i}.theta,pf.allI{i},... - pf_orig.allR{i}.theta,'spline'); + if length(unique(pf.allR{i}.rho(:))) > 4 + pf_orig.allI{i} = interp(pf.allR{i},pf.allI{i},pf_orig.allR{i}); + else + pf_orig.allI{i} = interp1(pf.allR{i}.theta,pf.allI{i},... + pf_orig.allR{i}.theta,'spline'); + end end catch error([msg ' does not fit original pole figure data!']); diff --git a/geometry/@vector3d/interp.m b/geometry/@vector3d/interp.m index e6b12379a..719a09a41 100644 --- a/geometry/@vector3d/interp.m +++ b/geometry/@vector3d/interp.m @@ -13,7 +13,8 @@ res = v.resolution; psi = deLaValeePoussinKernel('halfwidth',res/2); - % take the 4 largest values out of each row + % take the 4 closest neighbours for each point + % TODO: this can be done better omega = angle_outer(vi,v,varargin{:}); [so,j] = sort(omega,2); From da5583db7ff0f4d03b8af4661d7a77a415a2e48d Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 12 Jan 2016 13:26:41 +0100 Subject: [PATCH 026/120] base alignement of axes on hgtransform --- geometry/@sphericalRegion/plot.m | 3 ++- geometry/@vector3d/scatter.m | 7 +++++-- geometry/@vector3d/smooth.m | 6 +++--- geometry/@vector3d/surf.m | 2 +- geometry/@vector3d/text.m | 3 ++- plotting/newMtexFigure.m | 7 ++++++- plotting/sphericalPlot.m | 25 +++++++++++++++++-------- plotting/tools/setCamera.m | 2 +- 8 files changed, 37 insertions(+), 18 deletions(-) diff --git a/geometry/@sphericalRegion/plot.m b/geometry/@sphericalRegion/plot.m index 980a447dd..647b8b957 100644 --- a/geometry/@sphericalRegion/plot.m +++ b/geometry/@sphericalRegion/plot.m @@ -34,7 +34,8 @@ x(~sR.checkInside(v))=NaN; % plot - h(i) = optiondraw(line('xdata',x,'ydata',y,'parent',sP(j).ax,... + varargin = delete_option(varargin,'parent'); + h(i) = optiondraw(line('xdata',x,'ydata',y,'parent',sP(j).hgt,... 'color',[0.2 0.2 0.2],'linewidth',1.5,'hitTest','off'),varargin{:}); % do not display in the legend diff --git a/geometry/@vector3d/scatter.m b/geometry/@vector3d/scatter.m index 4e6af1aa1..88ed95c92 100644 --- a/geometry/@vector3d/scatter.m +++ b/geometry/@vector3d/scatter.m @@ -48,7 +48,7 @@ end % default arguments - patchArgs = {'parent',sP(i).ax,... + patchArgs = {'parent',sP(i).hgt,... 'vertices',[x(:) y(:)],... 'faces',1:numel(x),... 'facecolor','none',... @@ -114,7 +114,7 @@ if check_option(varargin,'DisplayName') holdState = get(sP(i).ax,'nextPlot'); set(sP(i).ax,'nextPlot','add'); - optiondraw(scatter(0,0,'parent',sP(i).ax,'MarkerFaceColor',mfc,... + optiondraw(scatter(0,0,'parent',sP(i).hgt,'MarkerFaceColor',mfc,... 'MarkerEdgeColor',mec,'visible','off'),varargin{:}); set(sP(i).ax,'nextPlot',holdState); end @@ -182,6 +182,9 @@ function localResizeScatterCallback(h,e,hax) if isempty(u), return;end p = get(u(1),'parent'); +while ~isgraphics(p,'axes'), p = get(p,'parent'); end + + unit = get(p,'unit'); set(p,'unit','pixel') pos = get(p,'position'); diff --git a/geometry/@vector3d/smooth.m b/geometry/@vector3d/smooth.m index 249bd29af..1e463cd64 100644 --- a/geometry/@vector3d/smooth.m +++ b/geometry/@vector3d/smooth.m @@ -85,7 +85,7 @@ data = reshape(cdata,size(x)); % plot contours - h = [h,betterContourf(sP(j).ax,x,y,data,contours,varargin{:})]; + h = [h,betterContourf(sP(j).hgt,x,y,data,contours,varargin{:})]; hold(sP(j).ax,'off') @@ -139,7 +139,7 @@ end if check_option(varargin,'pcolor') - h = pcolor(ax,X,Y,data); + h = pcolor(X,Y,data,'parent',ax); % do not display in the legend set(get(get(h,'Annotation'),'LegendInformation'),'IconDisplayStyle','off'); @@ -154,7 +154,7 @@ set(gcf,'Renderer','painters'); end else - [CM,h] = contourf(ax,X,Y,data,contours); %#ok + [CM,h] = contourf(X,Y,data,contours,'parent',ax); %#ok % do not display in the legend set(get(get(h,'Annotation'),'LegendInformation'),'IconDisplayStyle','off'); diff --git a/geometry/@vector3d/surf.m b/geometry/@vector3d/surf.m index 393a0ad67..37977e50a 100644 --- a/geometry/@vector3d/surf.m +++ b/geometry/@vector3d/surf.m @@ -30,7 +30,7 @@ hold(sP(j).ax,'on') % plot surface - h(j) = surf(x,y,zeros(size(x)),real(data),'parent',sP(j).ax); %#ok + h(j) = surf(x,y,zeros(size(x)),real(data),'parent',sP(j).hgt); %#ok shading(sP(j).ax,'interp'); hold(sP(j).ax,'off') diff --git a/geometry/@vector3d/text.m b/geometry/@vector3d/text.m index c4f44f102..5d39fb20d 100644 --- a/geometry/@vector3d/text.m +++ b/geometry/@vector3d/text.m @@ -21,6 +21,7 @@ h = []; interpreter = getMTEXpref('textInterpreter'); fs = getMTEXpref('FontSize'); +varargin = delete_option(varargin,'parent'); if check_option(varargin,'textAboveMarker') aboveBelow = -5; @@ -76,7 +77,7 @@ h = [h,optiondraw(text(x(i),y(i),s,'interpreter',interpreter,... 'HorizontalAlignment','center','VerticalAlignment','middle',... - tag{:},'margin',0.001,'parent',sP(j).ax),'FontSize',fs,varargin{2:end})]; %#ok + tag{:},'margin',0.001,'parent',sP(j).hgt),'FontSize',fs,varargin{2:end})]; %#ok end diff --git a/plotting/newMtexFigure.m b/plotting/newMtexFigure.m index b5d168436..5ae5d0600 100644 --- a/plotting/newMtexFigure.m +++ b/plotting/newMtexFigure.m @@ -65,7 +65,12 @@ % set current axis if check_option(varargin,'parent') - mtexFig.currentAxes = get_option(varargin,'parent'); + p = get_option(varargin,'parent'); + if isgraphics(p,'axes') + mtexFig.currentAxes = p; + else + mtexFig.currentAxes = get(p,'parent'); + end else mtexFig.currentId = 1; end diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index 12dfa9c1d..71b534ce3 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -7,7 +7,8 @@ bounds % grid % ticks % - ax % + ax % axis + hgt % hgtransform parent % the figure that contains the spherical plot TL % TR % @@ -36,6 +37,8 @@ end sP.ax = ax; + sP.hgt = hgtransform('parent',ax); + set(sP.hgt,'Matrix',makehgtform('zrotate',30*degree)); sP.parent = get(ax,'parent'); sP.proj = proj; sP.dispMinMax = check_option(varargin,'minmax'); @@ -64,7 +67,8 @@ sP.updateBounds; set(ax,'XTick',[],'YTick',[]); - axis(ax,'off'); + axis(ax,'off'); + if ~check_option(varargin,'grid') set(sP.grid,'visible','off'); end @@ -86,6 +90,7 @@ % set view point setCamera(ax,'default',varargin{:}); + end function updateMinMax(sP,data) @@ -175,21 +180,25 @@ function plotAnnotate(sP,varargin) function doGridInFront(sP) if ~isempty(sP.grid) - childs = allchild(sP.ax); + childs = allchild(sP.hgt); isgrid = ismember(childs,[sP.grid(:);sP.boundary(:)]); istext = strcmp(get(childs,'type'),'text'); - set(sP.ax,'Children',[childs(istext); sP.boundary(:); sP.grid(:);childs(~isgrid & ~istext)]); + set(sP.hgt,'Children',[childs(istext); sP.boundary(:); sP.grid(:);childs(~isgrid & ~istext)]); end end - function updateBounds(sP) + function updateBounds(sP) % compute bounding box + x = ensurecell(get(sP.boundary,'xData')); x = [x{:}]; y = ensurecell(get(sP.boundary,'yData')); y = [y{:}]; - sP.bounds = [min(x(:)),min(y(:)),max(x(:)),max(y(:))]; + M = get(sP.hgt,'Matrix'); + xy = M(1:2,1:2) * [x;y]; + sP.bounds = [min(xy(1,:)),min(xy(2,:)),max(xy(1,:)),max(xy(2,:))]; + end end @@ -245,7 +254,7 @@ function plotMeridians(sP,rho,varargin) [x,y] = project(sP.proj,v.'); % grid - sP.grid = [sP.grid(:);line(x,y,'parent',sP.ax,... + sP.grid = [sP.grid(:);line(x,y,'parent',sP.hgt,... 'handlevisibility','off','color',[.8 .8 .8])]; end @@ -259,7 +268,7 @@ function circ(sP,theta,varargin) [dx,dy] = sP.proj.project(v); % plot - sP.grid(end+1) = line(dx,dy,'parent',sP.ax,... + sP.grid(end+1) = line(dx,dy,'parent',sP.hgt,... 'handlevisibility','off','color',[.8 .8 .8]); end diff --git a/plotting/tools/setCamera.m b/plotting/tools/setCamera.m index 76d4fb4db..129522742 100644 --- a/plotting/tools/setCamera.m +++ b/plotting/tools/setCamera.m @@ -34,7 +34,7 @@ function setCamera(varargin) az = -az; end -view(ax,el,az); +%view(ax,el,az); %set(ax,'CameraTarget',[0,0,0]) %set(ax,'CameraPosition',[0,0,10000]) %set(ax,'CameraPositionMode','manual') From 2434add37edc0f4c4636be3d4445e5eb9c020ccd Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 13 Jan 2016 17:50:03 +0100 Subject: [PATCH 027/120] align text correctly with rotated data --- geometry/@vector3d/text.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/geometry/@vector3d/text.m b/geometry/@vector3d/text.m index 5d39fb20d..18f41f51a 100644 --- a/geometry/@vector3d/text.m +++ b/geometry/@vector3d/text.m @@ -50,6 +50,9 @@ end end + + % + M = get(sP(j).hgt,'matrix'); % print labels for i = 1:length(strings) @@ -64,9 +67,13 @@ end if check_option(varargin,'addMarkerSpacing'), - tag = {'UserData',[x(i),y(i)],'tag'}; - if y(i) > mean(sP(j).bounds([2 4])) + 0.1 + aboveBelow + xy = [x(i),y(i)]; + tag = {'UserData',xy,'tag'}; + + xy = M(1:2,1:2) * xy.'; + + if xy(2) > mean(sP(j).bounds([2 4])) + 0.1 + aboveBelow tag = [tag,'setAboveMarker']; else tag = [tag,'setBelowMarker']; From 1840c7fa4cd7d310a8aa95622d4b97392f1350bb Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 13 Jan 2016 17:51:17 +0100 Subject: [PATCH 028/120] work on --- geometry/@Miller/Miller.m | 2 +- plotting/@mtexFigure/getDataCursorPos.m | 6 +++++ plotting/sphericalPlot.m | 11 +++++----- plotting/tools/getCamera.m | 29 ++++++++++++++++++++----- plotting/tools/setCamera.m | 28 +++++++++++++++--------- 5 files changed, 54 insertions(+), 22 deletions(-) diff --git a/geometry/@Miller/Miller.m b/geometry/@Miller/Miller.m index 2d1458ad6..3d6923494 100644 --- a/geometry/@Miller/Miller.m +++ b/geometry/@Miller/Miller.m @@ -361,7 +361,7 @@ % rotate the aAxis to the east % but take only multiples of 90 degrees, % since Matlab is not able to handle the values in between - %rho = -fix(m.CS.aAxis.rho / 90 / degree)*90*degree; + %rho = -round(m.CS.aAxis.rho / 90 / degree)*90*degree; rho = -m.CS.aAxis.rho; opt = {'xAxisDirection',rho,'zAxisDirection','outOfPlane'}; end diff --git a/plotting/@mtexFigure/getDataCursorPos.m b/plotting/@mtexFigure/getDataCursorPos.m index 5bdc14899..d921f28f2 100644 --- a/plotting/@mtexFigure/getDataCursorPos.m +++ b/plotting/@mtexFigure/getDataCursorPos.m @@ -21,6 +21,12 @@ % convert pos to vector3d for spherical plots ax = get(target,'Parent'); +if ~isgraphics(ax,'axes') + M = get(ax,'matrix'); + pos = M(1:2,1:2) * pos(1:2).'; + ax = get(ax,'parent'); +end + % get value zd = get(target,'zdata'); xd = get(target,'xdata'); diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index 71b534ce3..56f315d00 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -38,7 +38,10 @@ sP.ax = ax; sP.hgt = hgtransform('parent',ax); - set(sP.hgt,'Matrix',makehgtform('zrotate',30*degree)); + + % set view point + setCamera(sP.hgt,'default',varargin{:}); + sP.parent = get(ax,'parent'); sP.proj = proj; sP.dispMinMax = check_option(varargin,'minmax'); @@ -86,11 +89,7 @@ set(ax,'DataAspectRatio',[1 1 1],'XLim',... sP.bounds([1,3]),'YLim',sP.bounds([2,4])); - - % set view point - setCamera(ax,'default',varargin{:}); - - + end function updateMinMax(sP,data) diff --git a/plotting/tools/getCamera.m b/plotting/tools/getCamera.m index 5e0c0cebb..c96185c9d 100644 --- a/plotting/tools/getCamera.m +++ b/plotting/tools/getCamera.m @@ -10,14 +10,33 @@ ax = gca; end -[az,el] = view(ax); +if isgraphics(ax,'axes') && isappdata(ax,'sphericalPlot') + sP = getappdata(ax,'sphericalPlot'); + ax = sP.hgt; +end + +if isgraphics(ax,'axes') + + [az,el] = view(ax); -if el<0 - zDir = 'intoPlane'; + if el<0 + zDir = 'intoPlane'; + else + zDir = 'outOfPlane'; + az = -az; + end else - zDir = 'outOfPlane'; - az = -az; + + M = get(ax,'matrix'); + az = atan2(M(2),M(1)) ./ degree; + if M(3,3)>0 + zDir = 'outOfPlane'; + az = -az; + else + zDir = 'intoPlane'; + end end + xDirs = {'east','north','west','south'}; try diff --git a/plotting/tools/setCamera.m b/plotting/tools/setCamera.m index 129522742..a73be6c7a 100644 --- a/plotting/tools/setCamera.m +++ b/plotting/tools/setCamera.m @@ -1,9 +1,7 @@ function setCamera(varargin) % set Camera according to xAxis and zAxis position -% get xaxis and zaxis directions - -% +% get current xaxis and zaxis directions if nargin > 0 && ~isempty(varargin{1}) && ... numel(varargin{1})==1 && all(ishandle(varargin{1})) ax = varargin{1}; @@ -14,11 +12,11 @@ function setCamera(varargin) if check_option(varargin,'default') xAxis = getMTEXpref('xAxisDirection'); zAxis = getMTEXpref('zAxisDirection'); -else +elseif isgraphics(ax,'axes') [xAxis,zAxis] = getCamera(ax); end -% exract x- and z-axis direction +% extract x- and z-axis direction xAxis = get_option(varargin,'xAxisDirection',xAxis); zAxis = get_option(varargin,'zAxisDirection',zAxis); @@ -34,8 +32,18 @@ function setCamera(varargin) az = -az; end -%view(ax,el,az); -%set(ax,'CameraTarget',[0,0,0]) -%set(ax,'CameraPosition',[0,0,10000]) -%set(ax,'CameraPositionMode','manual') -%set(ax,'CameraUpVector',[sin((-el)*degree),cos((-el)*degree),0]) \ No newline at end of file +if isgraphics(ax,'axes') && isappdata(ax,'sphericalPlot') + sP = getappdata(ax,'sphericalPlot'); + ax = sP.hgt; +end + +if isgraphics(ax,'axes') + view(ax,el,az); + %set(ax,'CameraTarget',[0,0,0]) + %set(ax,'CameraPosition',[0,0,10000]) + %set(ax,'CameraPositionMode','manual') + %set(ax,'CameraUpVector',[sin((-el)*degree),cos((-el)*degree),0]) +else + set(ax,'Matrix',... + makehgtform('xrotate',pi/2-az*degree,'zrotate',-el*degree)); +end From 73a048dc70a8fdaad5299d8b2271489b3de39b30 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 2 Feb 2016 10:20:11 +0100 Subject: [PATCH 029/120] handle also plain projection correctly --- geometry/@vector3d/scatter.m | 1 + plotting/@mtexFigure/private/MTEXFigureMenu.m | 2 +- plotting/sphericalPlot.m | 60 +++++++++++-------- plotting/tools/getCamera.m | 2 +- plotting/tools/setCamera.m | 5 +- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/geometry/@vector3d/scatter.m b/geometry/@vector3d/scatter.m index 88ed95c92..3a02ef8d6 100644 --- a/geometry/@vector3d/scatter.m +++ b/geometry/@vector3d/scatter.m @@ -26,6 +26,7 @@ % initialize spherical plots sP = newSphericalPlot(v,varargin{:}); +varargin = delete_option(varargin,'parent'); h = []; diff --git a/plotting/@mtexFigure/private/MTEXFigureMenu.m b/plotting/@mtexFigure/private/MTEXFigureMenu.m index f829d4847..49c721df5 100644 --- a/plotting/@mtexFigure/private/MTEXFigureMenu.m +++ b/plotting/@mtexFigure/private/MTEXFigureMenu.m @@ -168,7 +168,7 @@ function setVisible(obj,event,varargin) if isempty(sP.grid) set(ax(a),'XGrid',onoff,'YGrid',onoff); else - set(sP.(element),'visible',onoff); + set(sP.(char(element)),'visible',onoff); end else end diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index 56f315d00..77c0170d6 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -36,12 +36,7 @@ return end - sP.ax = ax; - sP.hgt = hgtransform('parent',ax); - - % set view point - setCamera(sP.hgt,'default',varargin{:}); - + sP.ax = ax; sP.parent = get(ax,'parent'); sP.proj = proj; sP.dispMinMax = check_option(varargin,'minmax'); @@ -51,23 +46,26 @@ washold = getHoldState(ax); if isa(sP.proj,'plainProjection') - + % boundary - sP.bounds = sP.sphericalRegion.polarRange / degree; - sP.bounds(3:4) = fliplr(sP.bounds(3:4)); + sP.hgt = ax; + sP.updateBounds; axis(ax,'on'); set(ax,'box','on'); % grid sP.plotPlainGrid(varargin{:}); + % set view point + setCamera(sP.ax,'default',varargin{:}); + else + sP.hgt = hgtransform('parent',ax); + % plot boundary - sP.boundary = sP.sphericalRegion.plot('parent',ax); + sP.boundary = sP.sphericalRegion.plot('parent',sP.ax); try sP.plotPolarGrid(varargin{:});end - - sP.updateBounds; set(ax,'XTick',[],'YTick',[]); axis(ax,'off'); @@ -75,20 +73,18 @@ if ~check_option(varargin,'grid') set(sP.grid,'visible','off'); end + + % set view point + setCamera(sP.ax,'default',varargin{:}); end plotAnnotate(sP,varargin{:}); + + % revert old hold status hold(ax,washold); - - % set bounds to axes - delta = min(sP.bounds(3:4) - sP.bounds(1:2))*0.02; - sP.bounds = sP.bounds + [-1 -1 1 1] * delta; - - set(ax,'DataAspectRatio',[1 1 1],'XLim',... - sP.bounds([1,3]),'YLim',sP.bounds([2,4])); end @@ -192,12 +188,28 @@ function doGridInFront(sP) function updateBounds(sP) % compute bounding box - x = ensurecell(get(sP.boundary,'xData')); x = [x{:}]; - y = ensurecell(get(sP.boundary,'yData')); y = [y{:}]; - M = get(sP.hgt,'Matrix'); - xy = M(1:2,1:2) * [x;y]; - sP.bounds = [min(xy(1,:)),min(xy(2,:)),max(xy(1,:)),max(xy(2,:))]; + if isa(sP.proj,'plainProjection') + + sP.bounds = sP.sphericalRegion.polarRange / degree; + sP.bounds(3:4) = fliplr(sP.bounds(3:4)); + + else + + x = ensurecell(get(sP.boundary,'xData')); x = [x{:}]; + y = ensurecell(get(sP.boundary,'yData')); y = [y{:}]; + M = get(sP.hgt,'Matrix'); + xy = M(1:2,1:2) * [x;y]; + sP.bounds = [min(xy(1,:)),min(xy(2,:)),max(xy(1,:)),max(xy(2,:))]; + end + + % set bounds to axes + delta = min(sP.bounds(3:4) - sP.bounds(1:2))*0.02; + sP.bounds = sP.bounds + [-1 -1 1 1] * delta; + + set(sP.ax,'DataAspectRatio',[1 1 1],'XLim',... + sP.bounds([1,3]),'YLim',sP.bounds([2,4])); + end end diff --git a/plotting/tools/getCamera.m b/plotting/tools/getCamera.m index c96185c9d..ec884b8d8 100644 --- a/plotting/tools/getCamera.m +++ b/plotting/tools/getCamera.m @@ -12,7 +12,7 @@ if isgraphics(ax,'axes') && isappdata(ax,'sphericalPlot') sP = getappdata(ax,'sphericalPlot'); - ax = sP.hgt; + if ~isempty(sP.hgt), ax = sP.hgt; end end if isgraphics(ax,'axes') diff --git a/plotting/tools/setCamera.m b/plotting/tools/setCamera.m index a73be6c7a..c1f2fd8d3 100644 --- a/plotting/tools/setCamera.m +++ b/plotting/tools/setCamera.m @@ -45,5 +45,8 @@ function setCamera(varargin) %set(ax,'CameraUpVector',[sin((-el)*degree),cos((-el)*degree),0]) else set(ax,'Matrix',... - makehgtform('xrotate',pi/2-az*degree,'zrotate',-el*degree)); + makehgtform('xrotate',pi/2-az*degree,'zrotate',-el*degree)); + sP.updateBounds; end + + From 2c15f326e928b0db88400148a1d7c8205ebdaa73 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:34:32 +0100 Subject: [PATCH 030/120] minor, allow also fundamentalSector as keyword for restricting the plot region --- geometry/@Miller/region.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/geometry/@Miller/region.m b/geometry/@Miller/region.m index 7ef9f6f77..b10e2f8b1 100644 --- a/geometry/@Miller/region.m +++ b/geometry/@Miller/region.m @@ -1,7 +1,8 @@ function sR = region(m,varargin) % return spherical region associated to a set of crystal directions -if check_option(varargin,'fundamentalRegion') && ~check_option(varargin,'complete') +if check_option(varargin,{'fundamentalRegion','fundamentalSector'}) ... + && ~check_option(varargin,'complete') sR = m.CS.fundamentalSector(varargin{:}); else sR = region@vector3d(m,varargin{:}); From bdc8d382e35932639a376f84c8227866eae5a7a9 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:35:35 +0100 Subject: [PATCH 031/120] Miller/text may also return a handle --- geometry/@Miller/text.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/geometry/@Miller/text.m b/geometry/@Miller/text.m index 14b8b917c..3455a7b26 100644 --- a/geometry/@Miller/text.m +++ b/geometry/@Miller/text.m @@ -39,3 +39,5 @@ function text(m,varargin) varargin = [varargin(1),m.plotOptions,varargin(2:end)]; text@vector3d(m,varargin{:}); + +if nargout == 0, clear h; end From dcc633157c9798ca67c9ad63e2f3b675c3461b21 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:36:50 +0100 Subject: [PATCH 032/120] ensure crystal coordinate systems to be orthogonal --- geometry/@crystalSymmetry/private/calcAxis.m | 16 +++++++++------- geometry/@symmetry/alignment.m | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/geometry/@crystalSymmetry/private/calcAxis.m b/geometry/@crystalSymmetry/private/calcAxis.m index 0afbe67f2..fc48a58d0 100644 --- a/geometry/@crystalSymmetry/private/calcAxis.m +++ b/geometry/@crystalSymmetry/private/calcAxis.m @@ -2,13 +2,13 @@ % calculate the axis a, b, c of the crystal coordinate system with respect % to the euclidean reference frame % -%% Input +% Input % % -%% Output +% Output % -%% get axis length +% get axis length if axisLength(3) == 0, axisLength(3) = max(axisLength);end if axisLength(3) == 0, axisLength(3) = 1;end @@ -19,7 +19,7 @@ axisLength(1) = axisLength(3); end -%% get angles +% get angles if angle(1) == 0 if angle(2) == 0, angle(2) = pi/2;end angle(1) = pi - angle(2); @@ -27,7 +27,7 @@ if angle(2) == 0, angle(2) = pi - angle(1);end if angle(3) == 0, angle(3) = pi/2;end -%% start be defining a reference coordinate system +% start be defining a reference coordinate system % which uses the convention % * X || a % * Z || c* @@ -37,14 +37,14 @@ (cos(angle(1)) - cos(angle(2)) * cos(angle(3)))/sin(angle(3)) * yvector +... sqrt(1+2*prod(cos(angle)) - sum(cos(angle).^2))/sin(angle(3)) * zvector; -%% compute a* b* c* +% compute a* b* c* astar = normalize(cross(b,c)); bstar = normalize(cross(c,a)); cstar = normalize(cross(a,b)); -%% extract alignment options +% extract alignment options % restrict to strings varargin = varargin(cellfun(@(s) ischar(s),varargin)); @@ -122,5 +122,7 @@ error('Bad alignment options! Non Euclidean reference frame!') end +if det(M) < 0, M(2,:) = -M(2,:);end + % now compute the new a, b, c axes abc = vector3d((M * reshape(double(normalize([a,b,c])),3,3).')) .* axisLength(:).'; diff --git a/geometry/@symmetry/alignment.m b/geometry/@symmetry/alignment.m index 903ab3072..607bb5b67 100644 --- a/geometry/@symmetry/alignment.m +++ b/geometry/@symmetry/alignment.m @@ -8,7 +8,7 @@ abcStar = normalize(cs.axesDual); [uabc,ind] = unique([abc,abcStar]); - [y,x] = find(isappr(dot_outer(uabc,[xvector,yvector,zvector]),1)); + [y,x] = find(isappr(abs(dot_outer(uabc,[xvector,yvector,zvector])),1)); abcLabel = {'a','b','c','a*','b*','c*'}; abcLabel = abcLabel(ind); From 21b5383624789e3d60475533981ef08681892a5e Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:38:43 +0100 Subject: [PATCH 033/120] minor --- geometry/@vector3d/angle_outer.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/geometry/@vector3d/angle_outer.m b/geometry/@vector3d/angle_outer.m index 62c4aec2f..717475f03 100644 --- a/geometry/@vector3d/angle_outer.m +++ b/geometry/@vector3d/angle_outer.m @@ -1,12 +1,12 @@ function a = angle_outer(v1,v2,varargin) % angle between two vectors -%% Input +% Input % v1, v2 - @vector3d % -%% Output +% Output % angle - double % -%% Options +% Options % antipodal - include [[AxialDirectional.html,antipodal symmetry]] a = dot_outer(v1./norm(v1),v2./norm(v2),varargin{:}); From 5dbab0b8bcca053bd8a46ed0cf52dc79ffac8607 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:47:20 +0100 Subject: [PATCH 034/120] crystal plotOptions are not longer bound to Miller but to crystalSymmetry --- geometry/@Miller/Miller.m | 11 +---------- geometry/@Miller/scatter.m | 4 ++-- geometry/@Miller/smooth.m | 8 ++++---- geometry/@Miller/surf.m | 4 ++-- geometry/@Miller/text.m | 2 +- geometry/@crystalSymmetry/crystalSymmetry.m | 10 ++++++++++ geometry/@symmetry/plot.m | 2 +- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/geometry/@Miller/Miller.m b/geometry/@Miller/Miller.m index 3d6923494..52e22001a 100644 --- a/geometry/@Miller/Miller.m +++ b/geometry/@Miller/Miller.m @@ -355,16 +355,7 @@ % set default display style m.dispStyle = 'UVTW'; - end - - function opt = plotOptions(m) - % rotate the aAxis to the east - % but take only multiples of 90 degrees, - % since Matlab is not able to handle the values in between - %rho = -round(m.CS.aAxis.rho / 90 / degree)*90*degree; - rho = -m.CS.aAxis.rho; - opt = {'xAxisDirection',rho,'zAxisDirection','outOfPlane'}; - end + end end diff --git a/geometry/@Miller/scatter.m b/geometry/@Miller/scatter.m index fbaeb3cec..d7b14c334 100644 --- a/geometry/@Miller/scatter.m +++ b/geometry/@Miller/scatter.m @@ -50,9 +50,9 @@ end if numel(varargin) > 0 && isnumeric(varargin{1}) - varargin = [varargin(1),m.plotOptions,varargin(2:end)]; + varargin = [varargin(1),m.CS.plotOptions,varargin(2:end)]; else - varargin = [m.plotOptions,varargin]; + varargin = [m.CS.plotOptions,varargin]; end % plot them all with the same color diff --git a/geometry/@Miller/smooth.m b/geometry/@Miller/smooth.m index 1810bf112..a3639cd74 100644 --- a/geometry/@Miller/smooth.m +++ b/geometry/@Miller/smooth.m @@ -15,9 +15,9 @@ if isfield(m.opt,'plot') if ~isempty(varargin) && isnumeric(varargin{1}) - varargin = [varargin{1},m.plotOptions,varargin(2:end)]; + varargin = [varargin{1},m.CS.plotOptions,varargin(2:end)]; else - varargin = [m.plotOptions,varargin]; + varargin = [m.CS.plotOptions,varargin]; end else @@ -26,9 +26,9 @@ m = symmetrise(m,'skipAntipodal'); if ~isempty(varargin) && isnumeric(varargin{1}) - varargin = [{repmat(varargin{1}(:).',size(m,1),1)},m.plotOptions,varargin(2:end)]; + varargin = [{repmat(varargin{1}(:).',size(m,1),1)},m.CS.plotOptions,varargin(2:end)]; else - varargin = [m.plotOptions,varargin]; + varargin = [m.CS.plotOptions,varargin]; end m = m(:); diff --git a/geometry/@Miller/surf.m b/geometry/@Miller/surf.m index 8be534f48..689ef47b5 100644 --- a/geometry/@Miller/surf.m +++ b/geometry/@Miller/surf.m @@ -11,7 +11,7 @@ % See also % -opt = m.plotOptions; -h = surf@vector3d(m,cdata,opt{:},varargin{:}); +varargin = [m.CS.plotOptions,varargin]; +h = surf@vector3d(m,cdata,varargin{:},m.CS); if nargout == 0, clear h; end diff --git a/geometry/@Miller/text.m b/geometry/@Miller/text.m index 3455a7b26..03775dba4 100644 --- a/geometry/@Miller/text.m +++ b/geometry/@Miller/text.m @@ -36,7 +36,7 @@ function text(m,varargin) end % ensure specific plot options -varargin = [varargin(1),m.plotOptions,varargin(2:end)]; +varargin = [varargin(1),m.CS.plotOptions,varargin(2:end)]; text@vector3d(m,varargin{:}); diff --git a/geometry/@crystalSymmetry/crystalSymmetry.m b/geometry/@crystalSymmetry/crystalSymmetry.m index 5672a0e27..5927b36a6 100644 --- a/geometry/@crystalSymmetry/crystalSymmetry.m +++ b/geometry/@crystalSymmetry/crystalSymmetry.m @@ -72,6 +72,7 @@ aAxisRec % a*-axis reciprocal coordinate system bAxisRec % b*-axis reciprocal coordinate system cAxisRec % c*-axis reciprocal coordinate system + plotOptions end methods @@ -159,6 +160,15 @@ function gamma = get.gamma(cs) gamma = angle(cs.axes(1),cs.axes(2)); end + + function opt = get.plotOptions(cs) + % rotate the aAxis to the east + % but take only multiples of 90 degrees, + % since Matlab is not able to handle the values in between + %rho = -round(m.CS.aAxis.rho / 90 / degree)*90*degree; + rho = -cs.aAxis.rho; + opt = {'xAxisDirection',rho,'zAxisDirection','outOfPlane'}; + end end diff --git a/geometry/@symmetry/plot.m b/geometry/@symmetry/plot.m index ec30f8f0d..10a847376 100644 --- a/geometry/@symmetry/plot.m +++ b/geometry/@symmetry/plot.m @@ -20,7 +20,7 @@ function plot(s,varargin) [uaxis, ~, id] = unique(axis,'antipodal'); % initalize plot -newSphericalPlot([zvector,-zvector],varargin{:}); +newSphericalPlot([zvector,-zvector],varargin{:},s.plotOptions{:}); hold on % plot mirror planes From f61c4a60888ad3afa4a73bb86e6c47ac50fa5165 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:48:10 +0100 Subject: [PATCH 035/120] Miller/text may also return a handle --- geometry/@Miller/text.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geometry/@Miller/text.m b/geometry/@Miller/text.m index 03775dba4..8e5ed69d8 100644 --- a/geometry/@Miller/text.m +++ b/geometry/@Miller/text.m @@ -1,4 +1,4 @@ -function text(m,varargin) +function h = text(m,varargin) % plot Miller indece % % Input @@ -38,6 +38,6 @@ function text(m,varargin) % ensure specific plot options varargin = [varargin(1),m.CS.plotOptions,varargin(2:end)]; -text@vector3d(m,varargin{:}); +h = text@vector3d(m,varargin{:}); if nargout == 0, clear h; end From 5b2e6c3b2f29b33e9fcc98de9fa322bcfb081382 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:53:34 +0100 Subject: [PATCH 036/120] surf plots may also have labels to bring in front --- geometry/@vector3d/surf.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/geometry/@vector3d/surf.m b/geometry/@vector3d/surf.m index 37977e50a..655333571 100644 --- a/geometry/@vector3d/surf.m +++ b/geometry/@vector3d/surf.m @@ -38,7 +38,8 @@ % set styles optiondraw(h(j),'LineStyle','none','Fill','on',varargin{:}); - uistack(sP(j).grid,'top') + % bring grid in front + sP(j).doGridInFront; end if nargout == 0, clear h; end From e13e009afaa1fbb52983db04a4f293d38cc97d53 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:54:06 +0100 Subject: [PATCH 037/120] bug fix --- geometry/@sphericalRegion/plot.m | 1 + 1 file changed, 1 insertion(+) diff --git a/geometry/@sphericalRegion/plot.m b/geometry/@sphericalRegion/plot.m index 647b8b957..21d67019c 100644 --- a/geometry/@sphericalRegion/plot.m +++ b/geometry/@sphericalRegion/plot.m @@ -17,6 +17,7 @@ %if all(sR.checkInside(sP(j).sphericalRegion.N)) && ~isempty(sP(j).boundary) if ~isempty(sP(j).boundary) && sR == sP(j).sphericalRegion + varargin = delete_option(varargin,'parent'); h = optiondraw(sP(j).boundary,varargin{:}); continue; end From 6d2bc8da3ae189281c52a11d494cfadf1088285b Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:57:30 +0100 Subject: [PATCH 038/120] label crystal plots by default --- plotting/@mtexFigure/private/MTEXFigureMenu.m | 10 ++++--- plotting/sphericalPlot.m | 27 +++++++++++++++++++ .../ipdfOrientationMapping.m | 20 -------------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/plotting/@mtexFigure/private/MTEXFigureMenu.m b/plotting/@mtexFigure/private/MTEXFigureMenu.m index 49c721df5..2a1b3b446 100644 --- a/plotting/@mtexFigure/private/MTEXFigureMenu.m +++ b/plotting/@mtexFigure/private/MTEXFigureMenu.m @@ -53,7 +53,7 @@ function MTEXFigureMenu(mtexFig,varargin) an = uimenu(m,'label','Annotations'); uimenu(an,'label','Min/Max','checked',isVisible('minmax'),'callback',{@setVisible,'minmax'}); -uimenu(an,'label','Axes Labels','checked',isVisible('labels'),'callback',{@setVisible,'labels'}); +uimenu(an,'label','Labels','checked',isVisible('labels'),'callback',{@setVisible,'labels'}); uimenu(an,'label','Coordinates','checked',isVisible('ticks'),'callback',{@setVisible,'ticks'}); uimenu(an,'label','Grid','checked','off','callback',{@setVisible,'grid'}); uimenu(an,'label','Micronbar','checked','on','callback',{@setVisible,'micronBar'}); @@ -77,9 +77,6 @@ function MTEXFigureMenu(mtexFig,varargin) uimenu(fs,'label','20 points','callback',{@setFontSize,20}); - - - function [cm,cmd] = getColormaps fnd = dir([mtex_path filesep 'tools' filesep 'colormaps' filesep '*ColorMap.m']); @@ -151,6 +148,11 @@ function setVisible(obj,event,varargin) findobj(ax(a),'tag','axesLabels')]; set(la,'visible',onoff); + sP = getappdata(ax(a),'sphericalPlot'); + if ~isempty(sP) && ~isempty(sP.labels) + set(sP.labels,'visible',onoff); + end + case 'ticks' if strcmp(onoff,'on') diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index 77c0170d6..8fff737cb 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -7,6 +7,7 @@ bounds % grid % ticks % + labels % ax % axis hgt % hgtransform parent % the figure that contains the spherical plot @@ -45,6 +46,8 @@ % store hold status washold = getHoldState(ax); + CS = getClass(varargin,'symmetry',[]); + if isa(sP.proj,'plainProjection') % boundary @@ -66,6 +69,7 @@ % plot boundary sP.boundary = sP.sphericalRegion.plot('parent',sP.ax); try sP.plotPolarGrid(varargin{:});end + sP.plotLabels(CS,varargin{:}); set(ax,'XTick',[],'YTick',[]); axis(ax,'off'); @@ -284,6 +288,29 @@ function circ(sP,theta,varargin) end + function plotLabels(sP,CS,varargin) + + if check_option(varargin,'noLabel'), return; end + + sR = sP.sphericalRegion; + h = sR.vertices; + + if ~isempty(CS) + h = Miller(unique(h),CS); + switch CS.lattice + case {'hexagonal','trigonal'} + h.dispStyle = 'UVTW'; + otherwise + h.dispStyle = 'uvw'; + end + h = round(h); +end + + sP.labels = [sP.labels,scatter(unique(h),'MarkerFaceColor','k',... + 'labeled','Marker','none',... + 'symmetrised','backgroundcolor','w','autoAlignText','parent',sP.ax)]; + + end end end diff --git a/tools/orientationMappings/ipdfOrientationMapping.m b/tools/orientationMappings/ipdfOrientationMapping.m index f1578cd72..b82487aa4 100644 --- a/tools/orientationMappings/ipdfOrientationMapping.m +++ b/tools/orientationMappings/ipdfOrientationMapping.m @@ -65,26 +65,6 @@ function plot(oM,varargin) end if isNew, fcw; end - else - if ~check_option(varargin,'noLabel') - h = sR.vertices; - if length(unique(h,'antipodal')) <=2 - sRu = sR.restrict2Upper; - h = [h,sRu.vertices,zvector]; - else - varargin = ['Marker','none',varargin]; - end - h = Miller(unique(h),oM.CS1); - switch oM.CS1.lattice - case {'hexagonal','trigonal'} - h.dispStyle = 'UVTW'; - otherwise - h.dispStyle = 'uvw'; - end - varargin = delete_option(varargin,'position'); - annotate(unique(round(h)),'MarkerFaceColor','k','labeled',... - 'symmetrised','backgroundcolor','w','autoAlignText',varargin{:}); - end mtexFig.drawNow('figSize',getMTEXpref('figSize'),varargin{:}); end From 573f30c46eb8c3fed6e229ff555af1977b1e9663 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:58:36 +0100 Subject: [PATCH 039/120] allow for tooltip in Miller plots --- geometry/@Miller/smooth.m | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/geometry/@Miller/smooth.m b/geometry/@Miller/smooth.m index a3639cd74..c7fbc4a8a 100644 --- a/geometry/@Miller/smooth.m +++ b/geometry/@Miller/smooth.m @@ -9,6 +9,9 @@ % See also % vector3d/smooth +% create a new figure if needed +[mtexFig,isNew] = newMtexFigure('datacursormode',@tooltip,varargin{:}); + % get plotting region sR = region(m,varargin{:}); @@ -35,4 +38,18 @@ end % use vector3d/smooth for output -[varargout{1:nargout}] = smooth@vector3d(m,varargin{:},sR); +%[varargout{1:nargout}] = smooth@vector3d(m,varargin{:},sR,m.CS); +[varargout{1:nargout}] = smooth@vector3d(m,varargin{:},sR,m.CS); + +function txt = tooltip(varargin) + +[h_local,value] = getDataCursorPos(mtexFig); + +h_local = Miller(h_local,m.CS,'uvw'); +h_local = round(h_local,'tolerance',3*degree); +txt = [xnum2str(value) ' at ' char(h_local)]; + +end + +end + From 56277d3d0267e403282a09c7f45a7837f8b3584f Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 3 Feb 2016 17:58:49 +0100 Subject: [PATCH 040/120] bug fix --- plotting/sphericalPlot.m | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index 8fff737cb..edda42462 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -45,7 +45,7 @@ % store hold status washold = getHoldState(ax); - + CS = getClass(varargin,'symmetry',[]); if isa(sP.proj,'plainProjection') @@ -68,9 +68,14 @@ % plot boundary sP.boundary = sP.sphericalRegion.plot('parent',sP.ax); + + % set view point + setCamera(sP.ax,'default',varargin{:}); + + % plot grid, labels, .. try sP.plotPolarGrid(varargin{:});end sP.plotLabels(CS,varargin{:}); - + set(ax,'XTick',[],'YTick',[]); axis(ax,'off'); @@ -78,15 +83,12 @@ set(sP.grid,'visible','off'); end - % set view point - setCamera(sP.ax,'default',varargin{:}); + end plotAnnotate(sP,varargin{:}); - - - + % revert old hold status hold(ax,washold); @@ -302,10 +304,10 @@ function plotLabels(sP,CS,varargin) h.dispStyle = 'UVTW'; otherwise h.dispStyle = 'uvw'; - end + end h = round(h); -end - + end + sP.labels = [sP.labels,scatter(unique(h),'MarkerFaceColor','k',... 'labeled','Marker','none',... 'symmetrised','backgroundcolor','w','autoAlignText','parent',sP.ax)]; From 699e1bd1948e0455ea1857f945268f04cec74ece Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Thu, 4 Feb 2016 07:35:52 +0100 Subject: [PATCH 041/120] plot labels only for the vertics --- plotting/sphericalPlot.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index edda42462..7ef1129a7 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -308,9 +308,9 @@ function plotLabels(sP,CS,varargin) h = round(h); end - sP.labels = [sP.labels,scatter(unique(h),'MarkerFaceColor','k',... + sP.labels = [sP.labels,scatter(h,'MarkerFaceColor','k',... 'labeled','Marker','none',... - 'symmetrised','backgroundcolor','w','autoAlignText','parent',sP.ax)]; + 'backgroundcolor','w','autoAlignText','parent',sP.ax)]; end end From f3a7e3b0e2ff15a1a49922713d29d5e83128ce5c Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 9 Feb 2016 16:43:06 +0100 Subject: [PATCH 042/120] docu --- doc/EBSDAnalysis/EBSDBingham.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/EBSDAnalysis/EBSDBingham.m b/doc/EBSDAnalysis/EBSDBingham.m index 9ad9969ce..c2e78629c 100644 --- a/doc/EBSDAnalysis/EBSDBingham.m +++ b/doc/EBSDAnalysis/EBSDBingham.m @@ -63,6 +63,7 @@ % axis/angle plot in which the simulated data looks like a sphere ori_spherical = calcOrientations(odf_spherical,1000); +close all scatter(ori_spherical) %% @@ -111,6 +112,7 @@ % shape in a axis/angle scatter plot reminds of a cigar ori_prolate = calcOrientations(odf_prolate,1000); +close all scatter(ori_prolate) %% @@ -154,6 +156,7 @@ % The oblate cases in axis/angle space reminds on a disk ori_oblate = calcOrientations(odf_oblate,1000); +close all scatter(ori_oblate) %% From ed80b4b6cc33348fa9c99821979459d955df99fd Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 9 Feb 2016 16:43:46 +0100 Subject: [PATCH 043/120] vector3d.rand vector3d.load --- geometry/@vector3d/vector3d.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/geometry/@vector3d/vector3d.m b/geometry/@vector3d/vector3d.m index a4250bff6..80c6cec1c 100644 --- a/geometry/@vector3d/vector3d.m +++ b/geometry/@vector3d/vector3d.m @@ -196,6 +196,25 @@ v = vector3d(0,0,x); end + function v = rand( varargin ) + % vector of random vector3d + + if nargin < 2, varargin = [varargin 1]; end + + theta = acos(2*(rand(varargin{:})-0.5)); + rho = 2*pi*rand(varargin{:}); + + v = vector3d('theta',theta,'rho',rho); + + end + + function varargout = load(fname,varargin) + % load vectors from file + + [varargout{1:nargout}] = loadVector3d(fname,varargin{:}); + + end + %function v = polar(polarAngle,azimuthAngle) % % Syntax % % From 9b5ed50e312cce2361890da6b5ec1c4fb7b8c7fa Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 9 Feb 2016 16:44:15 +0100 Subject: [PATCH 044/120] minor --- geometry/@symmetry/plot.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geometry/@symmetry/plot.m b/geometry/@symmetry/plot.m index 10a847376..c588bca95 100644 --- a/geometry/@symmetry/plot.m +++ b/geometry/@symmetry/plot.m @@ -68,8 +68,8 @@ function plot(s,varargin) mtexFig = newMtexFigure; for ax = mtexFig.children(:).' - set(ax,'xlim',1.1*get(ax,'xlim')); - set(ax,'ylim',1.1*get(ax,'ylim')); + set(ax,'xlim',1.075*get(ax,'xlim')); + set(ax,'ylim',1.075*get(ax,'ylim')); end mtexFig.drawNow('figSize',getMTEXpref('figSize'),varargin{:}); From d9210e4af343c675e46a337d40e8de7cec305a2a Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 9 Feb 2016 16:45:58 +0100 Subject: [PATCH 045/120] some fixes on ipf keys --- geometry/@sphericalRegion/polarCoordinates.m | 4 ++-- geometry/@symmetry/fundamentalSector.m | 2 ++ .../HSVOrientationMapping.m | 24 ++++++++++++------- .../TSLOrientationMapping.m | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/geometry/@sphericalRegion/polarCoordinates.m b/geometry/@sphericalRegion/polarCoordinates.m index 1a2b2765f..fec61354b 100644 --- a/geometry/@sphericalRegion/polarCoordinates.m +++ b/geometry/@sphericalRegion/polarCoordinates.m @@ -1,4 +1,4 @@ -function [r,rho] = polarCoordinates(sR,v,center,varargin) +function [r,rho] = polarCoordinates(sR,v,center,ref,varargin) % compute polar coordinates of with respect to a spherical region % % Input @@ -36,7 +36,7 @@ % a reference direction for rho = 0 if center == zvector - rx = xvector - center; + rx = ref - center; else rx = zvector - center; end diff --git a/geometry/@symmetry/fundamentalSector.m b/geometry/@symmetry/fundamentalSector.m index ef7a48552..d95d694e8 100644 --- a/geometry/@symmetry/fundamentalSector.m +++ b/geometry/@symmetry/fundamentalSector.m @@ -74,6 +74,8 @@ case 18 % -3 case {19,20,21} % 321, 3m1, -3m1 N = rotate(N,-30*degree); + case 22 + N = rotate(N,-30*degree); case {22,23,24} % 312, 31m, -31m case 30 %-42m N = rotate(N,-45*degree); diff --git a/tools/orientationMappings/HSVOrientationMapping.m b/tools/orientationMappings/HSVOrientationMapping.m index c48245d4a..251394242 100644 --- a/tools/orientationMappings/HSVOrientationMapping.m +++ b/tools/orientationMappings/HSVOrientationMapping.m @@ -56,17 +56,22 @@ function updatesR(oM) % symmetry dependent settings switch cs.id case 1, oM.refl = cs.axes(2); % 1 - case {3,6,9}, % 211, 121, 112 - pm = 1-2*isPerp(cs.subSet(2).axis,zvector); - oM.refl = rotate(oM.sR.N,rotation('axis',cs.subSet(2).axis,'angle',pm*90*degree)); - case {5,8,11,12}, oM.refl = rotate(oM.sR.N(2),-90*degree); % 222 - case 17, oM.refl = -rotate(sum(oM.sR.N),90*degree); % 3 - case {18,19,22} - oM.refl = r30 .* oM.sR.N(end-1:end); % -3, 321, 312 + case {3,9} % 211, 112 + oM.refl = -rotate(oM.sR.N,rotation('axis',cs.subSet(2).axis,'angle',90*degree)); + case 6, % 121 + oM.refl = rotate(oM.sR.N,rotation('axis',cs.subSet(2).axis,'angle',90*degree)); + case {5}, oM.refl = rotate(oM.sR.N(2),90*degree); % 222 + case {8,11,12}, oM.refl = rotate(oM.sR.N(2),-90*degree); % 222 + case 17, oM.refl = -rotate(sum(oM.sR.N),90*degree); % 3 + case 18, oM.refl = -rotate(sum(oM.sR.N(2:3)),90*degree); % -3 + case 19 + oM.refl = r30 .* oM.sR.N(end-1:end); % 321 if angle(oM.refl(1),oM.refl(2)) < 1*degree oM.refl = inv(r30) .* oM.sR.N(end-1:end); end - case {21,24}, oM.refl = rotate(sum(oM.sR.N(2:3)),90*degree); % -31m, -3m1 + case 21, oM.refl = rotate(sum(oM.sR.N(2:3)),90*degree); % -31m, -3m1 + case 22, oM.refl = -rotate(sum(oM.sR.N(2:3)),90*degree); % 312 + case 24, oM.refl = -rotate(sum(oM.sR.N(2:3)),90*degree); % -31m, -3m1 case {25,27,28}, oM.refl = rotate(oM.sR.N(end),-45*degree); % 4,4/m,422 case 26, oM.refl = rotate(oM.sR.N(end),-90*degree); % -4 case 30, oM.refl = yvector; % -42m @@ -108,7 +113,8 @@ function updatesR(oM) % compute angle of the points "sh" relative to the center point "center" % this should be between 0 and 1 - [radius,rho] = polarCoordinates(oM.sR,h_sR,wC,'maxAngle',oM.maxAngle); + ref = -vector3d(oM.CS1.bAxisRec); + [radius,rho] = polarCoordinates(oM.sR,h_sR,wC,ref,'maxAngle',oM.maxAngle); if oM.maxAngle < inf radius = max(0,1 - angle(h_sR(:),wC) ./ oM.maxAngle); diff --git a/tools/orientationMappings/TSLOrientationMapping.m b/tools/orientationMappings/TSLOrientationMapping.m index 8433c6db0..5cb6998e2 100644 --- a/tools/orientationMappings/TSLOrientationMapping.m +++ b/tools/orientationMappings/TSLOrientationMapping.m @@ -32,7 +32,7 @@ % compute angle of the points "sh" relative to the center point "center" % this should be between 0 and 1 - [radius,rho] = polarCoordinates(sR,h,center); + [radius,rho] = polarCoordinates(sR,h,center,xvector); % white center radius = 0.5+radius./2; From de55e872a16a416f3bbb1539fc7e3bd62876c82a Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 9 Feb 2016 16:46:10 +0100 Subject: [PATCH 046/120] minor fix --- tools/orientationMappings/ipdfOrientationMapping.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/orientationMappings/ipdfOrientationMapping.m b/tools/orientationMappings/ipdfOrientationMapping.m index b82487aa4..9b008b889 100644 --- a/tools/orientationMappings/ipdfOrientationMapping.m +++ b/tools/orientationMappings/ipdfOrientationMapping.m @@ -63,10 +63,9 @@ function plot(oM,varargin) text3(Miller(0,0,1,'uvw',oM.CS1),'c','verticalAlignment','bottom') hold off end - if isNew, fcw; end - - mtexFig.drawNow('figSize',getMTEXpref('figSize'),varargin{:}); + if isNew, fcw; end end + mtexFig.drawNow('figSize',getMTEXpref('figSize'),varargin{:}); end From 2a46684d1a9c9ffd1f07c68925ad366df9860b79 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 15 Feb 2016 16:49:46 +0100 Subject: [PATCH 047/120] bug fix --- tools/orientationMappings/TSLOrientationMapping.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/orientationMappings/TSLOrientationMapping.m b/tools/orientationMappings/TSLOrientationMapping.m index 5cb6998e2..f473bdaa1 100644 --- a/tools/orientationMappings/TSLOrientationMapping.m +++ b/tools/orientationMappings/TSLOrientationMapping.m @@ -5,6 +5,8 @@ function oM =TSLOrientationMapping(varargin) oM = oM@ipdfHSVOrientationMapping(varargin{:}); oM.CS1 = oM.CS1.Laue; + oM.sR = oM.CS1.fundamentalSector; + end end From aabdde721da025f362d8b5bba29d1cd2c24015fc Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 15 Feb 2016 16:50:38 +0100 Subject: [PATCH 048/120] fix mtex-toolbox/mtex#145 --- EBSDAnalysis/phaseList.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/EBSDAnalysis/phaseList.m b/EBSDAnalysis/phaseList.m index 49c53ad7a..4cfaa9125 100644 --- a/EBSDAnalysis/phaseList.m +++ b/EBSDAnalysis/phaseList.m @@ -57,10 +57,21 @@ % the data first = isa(pL.CSList{1},'symmetry'); - - if ~first + max(pL.phaseMap) <= numel(pL.CSList) + + % if everything is indexed but phase is 0 + if (max(pL.phaseMap) == 0) && ~first + + pL.phaseMap = [-1;pL.phaseMap(:)]; + pL.phaseId = 1 + pL.phaseId; + + % the normal case: there are simply some phases missing + % all we have to do is to extend the phaseMap + elseif ~first + max(pL.phaseMap) <= numel(pL.CSList) + % pL.phaseId = ~first + pL.phaseMap(pL.phaseId); + + % extend phaseMap pL.phaseMap = first + (0:numel(pL.CSList)-1); else From cdc62c204ff89f444587019a4b753182bd152729 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 15 Feb 2016 16:53:14 +0100 Subject: [PATCH 049/120] different alignment for symmetry 1 --- tools/orientationMappings/HSVOrientationMapping.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/orientationMappings/HSVOrientationMapping.m b/tools/orientationMappings/HSVOrientationMapping.m index 251394242..6d21a38ff 100644 --- a/tools/orientationMappings/HSVOrientationMapping.m +++ b/tools/orientationMappings/HSVOrientationMapping.m @@ -55,7 +55,7 @@ function updatesR(oM) % symmetry dependent settings switch cs.id - case 1, oM.refl = cs.axes(2); % 1 + case 1, oM.refl = cs.axes(3); % 1 case {3,9} % 211, 112 oM.refl = -rotate(oM.sR.N,rotation('axis',cs.subSet(2).axis,'angle',90*degree)); case 6, % 121 From 395e9ad18404fca1a62a7f95825345a02888bf9e Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 15 Feb 2016 16:55:22 +0100 Subject: [PATCH 050/120] function for computing grain paris --- EBSDAnalysis/@grain2d/calcParis.m | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 EBSDAnalysis/@grain2d/calcParis.m diff --git a/EBSDAnalysis/@grain2d/calcParis.m b/EBSDAnalysis/@grain2d/calcParis.m new file mode 100644 index 000000000..0486a4bac --- /dev/null +++ b/EBSDAnalysis/@grain2d/calcParis.m @@ -0,0 +1,57 @@ +function paris = calcParis(grains) +% Percentile Average Relative Indented Surface +% +% the paris is a grain boundary curvature function for convexity +% +% Syntax +% paris = calcParis(grains) +% +% Input +% grains - @grain2d +% +% Output +% paris - double +% + +paris = zeros(size(grains)); + +% store this in local variables for speed reasons +X = grains.V(:,1); +Y = grains.V(:,2); + +poly = grains.poly; +% remove inclusions +incl = grains.inclusionId; +for i = find(incl>0).' + poly{i} = poly{i}(1:end-incl(i)); +end + +% compute convex hull perimeters +for id = 1:length(grains) + + % for small grains there is no difference + if length(poly{id}) <= 7, continue; end + + % extract coordinates + xGrain = X(poly{id}); + yGrain = Y(poly{id}); + + % compute perimeter + perimeterGrain = sum(sqrt(... + (xGrain(1:end-1) - xGrain(2:end)).^2 + ... + (yGrain(1:end-1) - yGrain(2:end)).^2)); + + % compute convex hull + ixy = convhull(xGrain,yGrain); + + % compute perimenter + perimeterHull = sum(sqrt(... + (xGrain(ixy(1:end-1)) - xGrain(ixy(2:end))).^2 + ... + (yGrain(ixy(1:end-1)) - yGrain(ixy(2:end))).^2)); + + % paris is the relative difference between convex hull perimenter and true + % perimeter + paris(id) = 200*(perimeterGrain - perimeterHull)./perimeterHull; + +end + From 969b5021b907472be9e07a5329f8855ed8527f4b Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 15 Feb 2016 17:57:33 +0100 Subject: [PATCH 051/120] meanDirection + quiver plot at boundaries --- .../@grainBoundary/calcMeanDirection.m | 27 +++++++++++++++++++ EBSDAnalysis/@grainBoundary/quiver.m | 22 +++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 EBSDAnalysis/@grainBoundary/calcMeanDirection.m create mode 100644 EBSDAnalysis/@grainBoundary/quiver.m diff --git a/EBSDAnalysis/@grainBoundary/calcMeanDirection.m b/EBSDAnalysis/@grainBoundary/calcMeanDirection.m new file mode 100644 index 000000000..7b13acca9 --- /dev/null +++ b/EBSDAnalysis/@grainBoundary/calcMeanDirection.m @@ -0,0 +1,27 @@ +function dir = calcMeanDirection(gB,n) +% compute a smoothed direction that ignores staircasing +% +% + +if nargin == 1, n = 1; end + +% adjecents matrix vertices - vertices +I_VF = gB.I_VF; %#ok<*PROP> +A_V = I_VF * I_VF.'; + +% find for each vertex the neigbouring vertices +[u,v] = find(A_V^n); + +% X, Y values of the neighbouring vertices +X = sparse(u,v,gB.V(v,1),size(A_V,1),size(A_V,1)); +Y = sparse(u,v,gB.V(v,2),size(A_V,1),size(A_V,1)); + +% take the mean +X = full(sum(X,2)) ./ sum(A_V ~= 0,2); +Y = full(sum(Y,2)) ./ sum(A_V ~= 0,2); + +% compute the direction +dir = normalize(vector3d(X(gB.F(:,1)) - X(gB.F(:,2)),... + Y(gB.F(:,1)) - Y(gB.F(:,2)), zeros(length(gB),1),'antipodal')); + +end \ No newline at end of file diff --git a/EBSDAnalysis/@grainBoundary/quiver.m b/EBSDAnalysis/@grainBoundary/quiver.m new file mode 100644 index 000000000..a8b33bb97 --- /dev/null +++ b/EBSDAnalysis/@grainBoundary/quiver.m @@ -0,0 +1,22 @@ +function h = quiver(gB,dir,varargin) +% plot directions at grain boundaries +% +% Syntax +% quiver(gB,gB.direction,'linecolor','r') +% +% Example +% mtexdata fo +% grains = calcGrains(ebsd('indexed')) +% quiver(grains(1437).boundary,grains(1437).boundary.calcMeanDirection,'color','r') + + +varargin = [{'MaxHeadSize',0,'linewidth',2,'autoScaleFactor',0.15},varargin]; + +xy = [gB.midPoint;gB.midPoint]; +dir = [dir(:);-dir(:)]; + +h = optiondraw(quiver(xy(:,1),xy(:,2),dir.x,dir.y),varargin{:}); + +if nargout == 0, clear h; end + +end From 2929c2db75486a87760e1bcfb1881f017e817f78 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 16 Feb 2016 13:08:19 +0100 Subject: [PATCH 052/120] fix mtex-toolbox/mtex#151 --- geometry/@quaternion/project2FundamentalRegion.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry/@quaternion/project2FundamentalRegion.m b/geometry/@quaternion/project2FundamentalRegion.m index 05371712f..b09f5951f 100644 --- a/geometry/@quaternion/project2FundamentalRegion.m +++ b/geometry/@quaternion/project2FundamentalRegion.m @@ -20,7 +20,7 @@ % distingish different cases if nargin == 2 - q = project2FR(q,CS1,idquaternion); + q = project2FR_ref(q,CS1,idquaternion); else From 9a14c50acba1ecc4630a335fa84100f1f6ca1484 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 17 Feb 2016 07:01:48 +0100 Subject: [PATCH 053/120] fix mtex-toolbox/mtex#153 --- geometry/@Miller/scatter.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/geometry/@Miller/scatter.m b/geometry/@Miller/scatter.m index d7b14c334..0acd10d90 100644 --- a/geometry/@Miller/scatter.m +++ b/geometry/@Miller/scatter.m @@ -50,10 +50,10 @@ end if numel(varargin) > 0 && isnumeric(varargin{1}) - varargin = [varargin(1),m.CS.plotOptions,varargin(2:end)]; + varargin = [varargin(1),m.CS.plotOptions,varargin(2:end)]; else - varargin = [m.CS.plotOptions,varargin]; + varargin = [m.CS.plotOptions,varargin]; end % plot them all with the same color -[varargout{1:nargout}] = scatter@vector3d(m,varargin{:}); +[varargout{1:nargout}] = scatter@vector3d(m,varargin{:},m.CS); From 36d1fd435eb28b089d33ab390f5adeb2ab2c4bab Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 17 Feb 2016 23:52:39 +0100 Subject: [PATCH 054/120] fix mtex-toolbox/mtex#154 --- EBSDAnalysis/phaseList.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/EBSDAnalysis/phaseList.m b/EBSDAnalysis/phaseList.m index 4cfaa9125..c75ce59b2 100644 --- a/EBSDAnalysis/phaseList.m +++ b/EBSDAnalysis/phaseList.m @@ -16,7 +16,6 @@ indexedPhasesId % id's of all non empty indexed phase color % color of one specific phase end - methods @@ -185,6 +184,16 @@ else error('Assignment should be of type symmetry'); end + + % set CSList also to all children + for fn = fieldnames(pL).' + try %#ok + if isfield(pL.(char(fn)),'CSList') + pL.(char(fn)).CSList = pL.CSList; + end + end + end + end function mineral = get.mineral(pL) From fa5e47f10294ee67d042e184a2351dcbadb268fd Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Wed, 17 Feb 2016 23:53:45 +0100 Subject: [PATCH 055/120] bug fix --- geometry/@vector3d/plotCustom.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry/@vector3d/plotCustom.m b/geometry/@vector3d/plotCustom.m index 2731b2150..7dc8c8791 100644 --- a/geometry/@vector3d/plotCustom.m +++ b/geometry/@vector3d/plotCustom.m @@ -22,5 +22,5 @@ function plotCustom(v,pcmd,varargin) [x,y] = project(sP(j).proj,v,varargin{:}); % plot custom - for i = 1:length(x), pcmd{1}(sP(j).ax,x(i),y(i)); end + for i = 1:length(x), pcmd{1}(sP(j).hgt,x(i),y(i)); end end From 1101af438fd5b0c0acd5e38685944b073b849d01 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Thu, 18 Feb 2016 06:44:26 +0100 Subject: [PATCH 056/120] fix mtex-toolbox/mtex#154 --- EBSDAnalysis/@grain2d/subsasgn.m | 6 ++++++ EBSDAnalysis/phaseList.m | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/EBSDAnalysis/@grain2d/subsasgn.m b/EBSDAnalysis/@grain2d/subsasgn.m index c4e94a6bf..0c734175a 100644 --- a/EBSDAnalysis/@grain2d/subsasgn.m +++ b/EBSDAnalysis/@grain2d/subsasgn.m @@ -32,7 +32,13 @@ grains.poly = subsasgn(grains.poly,s(1),b.poly); grains.inclusionId = subsasgn(grains.inclusionId,s(1),b.inclusionId); grains.CSList = b.CSList; + grains.boundary.CSList = b.CSList; + grains.innerBoundary.CSList = b.CSList; + grains.triplePoints.CSList = b.CSList; grains.phaseMap = b.phaseMap; + grains.boundary.phaseMap = b.phaseMap; + grains.innerBoundary.phaseMap = b.phaseMap; + grains.triplePoints.phaseMap = b.phaseMap; end diff --git a/EBSDAnalysis/phaseList.m b/EBSDAnalysis/phaseList.m index c75ce59b2..cb6b57b81 100644 --- a/EBSDAnalysis/phaseList.m +++ b/EBSDAnalysis/phaseList.m @@ -188,7 +188,7 @@ % set CSList also to all children for fn = fieldnames(pL).' try %#ok - if isfield(pL.(char(fn)),'CSList') + if isa(pL.(char(fn)),'phaseList') pL.(char(fn)).CSList = pL.CSList; end end From b51602c45ea6717171f6e6af2e0855009c263f22 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 20 Feb 2016 10:24:55 +0100 Subject: [PATCH 057/120] bug fix that avoids the warning in surface plots --- geometry/@vector3d/surf.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/geometry/@vector3d/surf.m b/geometry/@vector3d/surf.m index 655333571..ac77fb74a 100644 --- a/geometry/@vector3d/surf.m +++ b/geometry/@vector3d/surf.m @@ -30,9 +30,9 @@ hold(sP(j).ax,'on') % plot surface - h(j) = surf(x,y,zeros(size(x)),real(data),'parent',sP(j).hgt); %#ok - shading(sP(j).ax,'interp'); - + h(j) = surf(x,y,zeros(size(x)),real(data),'parent',sP(j).hgt,... + 'edgeColor','none'); %#ok + hold(sP(j).ax,'off') % set styles From ab1ace8398819a74806ad46ce4b64cc3d0457cfb Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 20 Feb 2016 10:26:49 +0100 Subject: [PATCH 058/120] docu --- EBSDAnalysis/@grain2d/aspectRatio.m | 2 +- EBSDAnalysis/@grain2d/boundarySize.m | 2 +- doc/GrainAnalysis/GrainAnalysis.toc | 1 + doc/GrainAnalysis/GrainReconstructionDemo.m | 151 +++++++++++++------- geometry/geometry_tools/CSL.m | 2 +- 5 files changed, 103 insertions(+), 55 deletions(-) diff --git a/EBSDAnalysis/@grain2d/aspectRatio.m b/EBSDAnalysis/@grain2d/aspectRatio.m index 6442d080c..1b3598405 100644 --- a/EBSDAnalysis/@grain2d/aspectRatio.m +++ b/EBSDAnalysis/@grain2d/aspectRatio.m @@ -1,5 +1,5 @@ function asp = aspectRatio(grains,varargin) -% calculates the aspectratio of grain +% aspectratio = length / width % % the aspect ratio is the ratio between the two % of a grain diff --git a/EBSDAnalysis/@grain2d/boundarySize.m b/EBSDAnalysis/@grain2d/boundarySize.m index d8c5deac0..953800d93 100644 --- a/EBSDAnalysis/@grain2d/boundarySize.m +++ b/EBSDAnalysis/@grain2d/boundarySize.m @@ -5,7 +5,7 @@ % grains - @grain2d % % Output -% bS - number of boundary segment +% bS - number of boundary segments % % Syntax % peri = grains.boundarySize diff --git a/doc/GrainAnalysis/GrainAnalysis.toc b/doc/GrainAnalysis/GrainAnalysis.toc index 616b07747..9928479b5 100644 --- a/doc/GrainAnalysis/GrainAnalysis.toc +++ b/doc/GrainAnalysis/GrainAnalysis.toc @@ -1,3 +1,4 @@ +GrainReconstructionDemo GrainReconstruction GrainStatistics GrainSpatialPlots diff --git a/doc/GrainAnalysis/GrainReconstructionDemo.m b/doc/GrainAnalysis/GrainReconstructionDemo.m index 4bd9a1bc2..03a32a310 100644 --- a/doc/GrainAnalysis/GrainReconstructionDemo.m +++ b/doc/GrainAnalysis/GrainReconstructionDemo.m @@ -1,93 +1,140 @@ -%% - - -%% Import some EBSD data +%% First Steps and Function Overview +% Get in touch with grains. +% +%% Grain reconstruction from EBSD data +% +% So far grains can exclusevly computed from EBSD data using the command +% . In order to demonstrate grain +% reconstruction we import some EBSD data mtexdata forsterite plotx2east -plot(ebsd) - -%% First attempt on grain reconstruction +% plot the Forsterite phase colorized according to orientation +plot(ebsd('fo'),ebsd('fo').orientations) -[grains,ebsd.grainId] = calcGrains(ebsd,'angle',5*degree); -plot(grains) +%% +% When reconstructing grain there are two basic ways how to deal with not +% indexed measurements. The simplest way is to keep the not indexed pixels +% seperately, i.e., do not assign them to any indexed grain. +[grains, ebsd.grainId] = calcGrains(ebsd,'angle',5*degree) %% -% The resulting grains contain a lot of holes and one pixel grains due to -% misindexing. A good measure for regions where indexing went wrong is the -% band contrast +% We observe that there are not only grains of specific phases but also not +% indexed grains. Let add the grain boundaries to the previous plot. -plot(ebsd,ebsd.bc) +hold on +plot(grains.boundary) +hold off %% -% We see its quite low at the grain boundaries and, e.g., in the top left -% rectangle. Lets set the phase of measurements with bandcontrast -% smaller then a certain threshold to notIndexed +% The resulting grains contain a lot of holes and one pixel grains. The +% second way is to assign not indexed pixels to surounding grains. In MTEX +% this is done if the not indexed data are removed from the measurements, +% i.e. -condition = ebsd.bc < 80; - -% setting the phase to zero means notIndexed -ebsd(condition).phase = 0 -plot(ebsd) +ebsd = ebsd('indexed') % this removes all not indexed data +[grains, ebsd.grainId] = calcGrains(ebsd,'angle',5*degree) %% +% Now, there are no not indexed grains computed. Lets visualize the result -[grains,ebsd.grainId] = calcGrains(ebsd,'angle',5*degree); - -plot(grains) +% plot the orientation data of the Forsterite phase +plot(ebsd('fo'),ebsd('fo').orientations) +% plot the grain boundary on top of it +hold on +plot(grains.boundary) +hold off %% +% A more detailed discussion on grain reconstruction in MTEX can be found +% -plot(grains,log(grains.grainSize ./ grains.boundarySize)) -mtexColorbar -%% -% remove +%% Smoothing grain boundaries +% +% Due to the measurement grid the grain boundaries often show a typical +% stair case effect. This effect can be reduced by smoothing the grain +% boundaries. Using the command . + +% smooth the grains +grains = smooth(grains); -ind = ~grains.isIndexed & log(grains.grainSize ./ grains.boundarySize) < -0.4; +% plot the orientation data of the Forsterite phase +plot(ebsd('fo'),ebsd('fo').orientations) -plot(ebsd) +% plot the grain boundary on top of it hold on -plot(grains(ind),'faceColor',[0 0 0],'DisplayName','fill this') +plot(grains.boundary) hold off -% remove marked measurements -ebsd(grains(ind)) = [] +%% Grain properties +% +% Grains are stored as a long list with several properties. Please find +% below a table of most of the properties that are stored or can be +% computed for grains +% +% || || grain area in square || +% || || grain length / grain width || +% || || list of boundary segments|| +% || || number of boundary segments || +% || || area difference between grain and its convex hull|| +% || || x,y coordinates of the barycenter of the grain || +% || *grains.CS* || crystal symmetry (single phase only)|| +% || || diameter in || +% || || perimeter of fitted ellipse || +% || || radius of fitted ellipse || +% || *grains.GOS* || grain orientation spread|| +% || *grains.grainSize* || number of measurements per grain|| +% || || check for inclusions || +% || *grains.id* || grain id|| +% || || list of inner boundary segments|| +% || *grains.meanOrientation* || meanOrientation (single phase only)|| +% || *grains.mineral* || mineral name (single phase only)|| +% || || number and ids of neighbouring grains || +% || *grains.phase* || phase identifier|| +% || || perimeter in || +% || || length and widht of fitted ellipse || +% || || qotient perimeter / perimeter of fitted ellipse|| +% || || list of triple points|| +% || *grains.x* || x coordintes of the vertices|| +% || *grains.y* || y coordintes of the vertices|| %% +% Those grain properties can be used for colorization. E.g. we may colorize +% grains according to their area. -[grains,ebsd.grainId] = calcGrains(ebsd,'angle',5*degree); - -plot(grains) +plot(grains,grains.area) %% -% fill grains that are to small - -ind = grains.grainSize < 5; - -hold on -plot(grains(ind),'faceColor',[0 0 0],'DisplayName','fill this') -hold off +% or a little bit more advanced according to the log quotient between +% grain size and boundary size. -% remove marked measurements -ebsd(grains(ind)) = [] +plot(grains,log(grains.grainSize ./ grains.boundarySize)) +mtexColorbar %% -% +% Note that some properties are available for single phase lists of grains, +% e.g. -[grains,ebsd.grainId] = calcGrains(ebsd,'angle',5*degree); +% colorize the Forsterite Phase according to its mean orientation +plot(grains('Fo'),grains('Fo').meanOrientation) -plot(grains) +%% Changing lists of grains +% +% As with any list in MTEX one can single out specific grains by conditions +% using the syntax +% this gives all grains with more the 1000 pixels +largeGrains = grains(grains.grainSize > 1000) -%% Smooth grains - -grains = smooth(grains,2); +hold on +% mark only large Forsterite grains +plot(largeGrains('Fo').boundary,'linewidth',2,'lincecolor','k') +hold off -plot(grains) diff --git a/geometry/geometry_tools/CSL.m b/geometry/geometry_tools/CSL.m index f610820bc..82c291272 100644 --- a/geometry/geometry_tools/CSL.m +++ b/geometry/geometry_tools/CSL.m @@ -17,7 +17,7 @@ % if nargin < 2 || ~isa(CS,'crystalSymmetry') - error('Starting with MTEX 4.2 the second argument to CSL should by crystal symmetry.') + error('Starting with MTEX 4.2 the second argument to CSL should be crystal symmetry.') end csl = generateCubicCSL(varargin{:}); From d11be9d673dc40428ad7e8266c878c87c9b0176e Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 20 Feb 2016 10:27:17 +0100 Subject: [PATCH 059/120] allow to display arrows of different length --- geometry/@vector3d/arrow3d.m | 37 +++++++++++++++++++++--------------- geometry/@vector3d/text3.m | 6 +++--- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/geometry/@vector3d/arrow3d.m b/geometry/@vector3d/arrow3d.m index 6d53ef133..dabc3f95f 100644 --- a/geometry/@vector3d/arrow3d.m +++ b/geometry/@vector3d/arrow3d.m @@ -1,4 +1,4 @@ -function h = arrow3d(v,varargin) +function h = arrow3d(vec,varargin) % plot three dimensional arrows % % Syntax @@ -20,26 +20,33 @@ cax = caxis(ax); % length of the arrows -v = 1.2.*v.normalize; +vec = 1.2.*vec; lengthTail = 0.9; radiHead = 0.05; radiTail = 0.02; -% the center line of the arrow -c = [vector3d(0,0,0),vector3d(0,0,0),v.*lengthTail,v.*lengthTail,v]; -% the radii -r = [0,radiTail,radiTail,radiHead,0]; +for i = 1:length(vec) + + v = vec.subSet(i); + + % the center line of the arrow + c = [vector3d(0,0,0),vector3d(0,0,0),v.*lengthTail,v.*lengthTail,v]; -% a normal vector -n = rotate(v.orth,rotation('axis',v,'angle',linspace(0,2*pi,50))); + % the radii + r = [0,radiTail,radiTail,radiHead,0] .* norm(v); -% the hull of the arrow -hull = repmat(c,length(n),1) + n * r; + % a normal vector + n = rotate(v.orth,rotation('axis',v,'angle',linspace(0,2*pi,50))); -% plot as surface plot -h = optiondraw(surf(hull.x,hull.y,hull.z,'parent',ax,... - 'facecolor','k','edgecolor','none'),varargin{:}); + % the hull of the arrow + hull = repmat(c,length(n),1) + n * r; + + % plot as surface plot + h(i) = optiondraw(surf(hull.x,hull.y,hull.z,'parent',ax,... + 'facecolor','k','edgecolor','none'),varargin{:}); + +end % set caxis back caxis(ax,cax); @@ -48,7 +55,7 @@ axis(ax,'equal','vis3d','off'); % st box limits -set(ax,'XDir','rev','YDir','rev',... -'XLim',[-1.2,1.2],'YLim',[-1.2,1.2],'ZLim',[-1.2,1.2]); +bounds = [-1 1] * max(norm(vec(:))); +set(ax,'XDir','rev','YDir','rev','XLim',bounds,'YLim',bounds,'ZLim',bounds); if nargout == 0, clear h;end diff --git a/geometry/@vector3d/text3.m b/geometry/@vector3d/text3.m index 0dc21b45e..9dfe3de92 100644 --- a/geometry/@vector3d/text3.m +++ b/geometry/@vector3d/text3.m @@ -16,7 +16,7 @@ ax = gca; end -v = 1.2.*v.normalize; +v = 1.2.*v; h = optiondraw(text(v.x,v.y,v.z,string,'FontSize',15,'parent',ax),... 'horizontalAlignment','center','verticalAlignment','middle',varargin{:}); @@ -25,7 +25,7 @@ axis(ax,'equal','vis3d','off'); % st box limits -set(ax,'XDir','rev','YDir','rev',... -'XLim',[-1.2,1.2],'YLim',[-1.2,1.2],'ZLim',[-1.2,1.2]); +bounds = [-1.2,1.2] * max(norm(v(:))); +set(ax,'XDir','rev','YDir','rev','XLim',bounds,'YLim',bounds,'ZLim',bounds); if nargout == 0, clear h;end From a48e5cf66cbca3dad6a00effbfac7633f740d8b5 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 20 Feb 2016 10:28:40 +0100 Subject: [PATCH 060/120] new option to ignore common symmetries when computing the orientation region --- geometry/@symmetry/fundamentalRegion.m | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/geometry/@symmetry/fundamentalRegion.m b/geometry/@symmetry/fundamentalRegion.m index ee175ba60..8e440517a 100644 --- a/geometry/@symmetry/fundamentalRegion.m +++ b/geometry/@symmetry/fundamentalRegion.m @@ -16,16 +16,19 @@ % q = unique(quaternion(cs),'antipodal'); +N0 = quaternion; if nargin >= 2 && isa(varargin{1},'symmetry') q = unique(q * quaternion(varargin{1}),'antipodal'); - dcs = disjoint(cs.properGroup,varargin{1}.properGroup); - if check_option(varargin,'antipodal') - dcs = dcs.Laue; + + if ~check_option(varargin,'ignoreCommonSymmetries') + dcs = disjoint(cs.properGroup,varargin{1}.properGroup); + if check_option(varargin,'antipodal') + dcs = dcs.Laue; + end + sR = dcs.fundamentalSector(varargin{:}); + N0 = rotation('axis',sR.N,'angle',pi-1e-5); end - sR = dcs.fundamentalSector(varargin{:}); - N0 = rotation('axis',sR.N,'angle',pi-1e-5); -else - N0 = quaternion; +else dcs = cs.properGroup; if check_option(varargin,'antipodal'), dcs = dcs.Laue; end end From 926c8f41d29252e5555e045365c6cda21354dd53 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 20 Feb 2016 10:29:15 +0100 Subject: [PATCH 061/120] new option to avoid duplication when symmetrising misorientations --- geometry/@orientation/symmetrise.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/geometry/@orientation/symmetrise.m b/geometry/@orientation/symmetrise.m index 8d47ea85a..3e33b9386 100644 --- a/geometry/@orientation/symmetrise.m +++ b/geometry/@orientation/symmetrise.m @@ -12,3 +12,8 @@ if o.antipodal o = [o;inv(o)]; end + +if check_option(varargin,'unique') + [~,ind] = unique(rotation(o)); + o = subSet(o,ind); +end \ No newline at end of file From 6518caca2b9f7bf654195e15cab527d20c9846c1 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 17 Nov 2015 12:37:13 +0100 Subject: [PATCH 062/120] gradients for orientation maps --- EBSDAnalysis/@EBSD/EBSD.m | 48 +++++++++++++++++++++++++++++++++++-- geometry/@orientation/log.m | 20 ++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 geometry/@orientation/log.m diff --git a/EBSDAnalysis/@EBSD/EBSD.m b/EBSDAnalysis/@EBSD/EBSD.m index 1f4887565..0ad9d666c 100644 --- a/EBSDAnalysis/@EBSD/EBSD.m +++ b/EBSDAnalysis/@EBSD/EBSD.m @@ -39,7 +39,11 @@ orientations % rotation including symmetry weights % grainId % id of the grain to which the EBSD measurement belongs to - mis2mean % misorientation to the mean orientation of the corresponding grain + mis2mean % misorientation to the mean orientation of the corresponding grain + dx % step size in x + dy % step size in y + gradientX % orientation gradient in x + gradientY % orientation gradient in y end methods @@ -59,7 +63,11 @@ ebsd.prop = get_option(varargin,'options',struct); % get unit cell - ebsd.unitCell = get_option(varargin,'unitCell',[]); + if check_option(varargin,'uniCell') + ebsd.unitCell = get_option(varargin,'unitCell',[]); + else + ebsd.unitCell = calcUnitCell([ebsd.prop.x(:),ebsd.prop.y(:)]); + end % remove ignore phases if check_option(varargin,'ignorePhase') @@ -142,6 +150,42 @@ ebsd.prop.weights = weights; end + function dx = get.dx(ebsd) + uc = ebsd.unitCell; + if size(uc,1) == 4 + dx = max(uc(:,1)) - min(uc(:,1)); + elseif size(uc,1) == 6 + dx = max(uc(:,1)) - min(uc(:,1)); + else + dx = inf; + end + end + + function dy = get.dy(ebsd) + uc = ebsd.unitCell; + if size(uc,1) == 4 + dy = max(uc(:,2)) - min(uc(:,2)); + elseif size(uc,1) == 6 + dy = max(uc(:,2)) - min(uc(:,2)); + else + dy = inf; + end + end + + function gX = get.gradientX(ebsd) + ori = ebsd.orientations; + if min(size(ori)) <= 1 + error('Gradient determination requires a regular grid') + end + + ori_ref = ori([2:end end-1],:); + gX = log(ori,ori_ref) ./ dx; + gX(end,:) = - gX(end,:); + end + + function gx = get.gradientY(ebsd) + end + end end diff --git a/geometry/@orientation/log.m b/geometry/@orientation/log.m new file mode 100644 index 000000000..dec421052 --- /dev/null +++ b/geometry/@orientation/log.m @@ -0,0 +1,20 @@ +function v = log(ori,ori_ref) +% +% +% Syntax +% v = log(ori) +% v = log(ori,ori_ref) +% +% Input +% ori - @orientation +% ori_ref - @orientation +% +% Output +% v - @vector3d +% +% See also +% + +ori = project2FundamentalRegion(ori,ori_ref); + +v = log(quaternion(ori),quaternion(ori_ref)); From ad96b06caf0e9f4e408e8320d88952e74ba02005 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 23 Jan 2016 15:54:06 +0100 Subject: [PATCH 063/120] subSet of EBSDsquare may not be EBSDsquare anymore --- EBSDAnalysis/@EBSD/subSet.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/EBSDAnalysis/@EBSD/subSet.m b/EBSDAnalysis/@EBSD/subSet.m index 76c4a6ab8..54761dfca 100644 --- a/EBSDAnalysis/@EBSD/subSet.m +++ b/EBSDAnalysis/@EBSD/subSet.m @@ -10,4 +10,8 @@ ebsd.phaseId = reshape(ebsd.phaseId(ind),[],1); ebsd.id = ebsd.id(ind); %if ~isempty(ebsd.grainId), ebsd.grainId = ebsd.grainId(ind); end -if ~isempty(ebsd.A_D), ebsd.A_D = ebsd.A_D(ind,ind); end +if ~isempty(ebsd.A_D), ebsd.A_D = ebsd.A_D(ind(:),ind(:)); end + +if islogical(ind) || min(size(ind))==1 + ebsd = EBSD(ebsd); +end \ No newline at end of file From 3ae22585747771bc20258904cf819e9c7797a552 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 23 Jan 2016 15:55:12 +0100 Subject: [PATCH 064/120] new EBSD class for square raster --- EBSDAnalysis/@EBSDsquare/EBSDsquare.m | 74 +++++++++++++++++++ EBSDAnalysis/@EBSDsquare/fill.m | 51 +++++++++++++ EBSDAnalysis/@EBSDsquare/smooth.m | 100 ++++++++++++++++++++++++++ EBSDAnalysis/@EBSDsquare/subsind.m | 15 ++++ 4 files changed, 240 insertions(+) create mode 100644 EBSDAnalysis/@EBSDsquare/EBSDsquare.m create mode 100644 EBSDAnalysis/@EBSDsquare/fill.m create mode 100644 EBSDAnalysis/@EBSDsquare/smooth.m create mode 100644 EBSDAnalysis/@EBSDsquare/subsind.m diff --git a/EBSDAnalysis/@EBSDsquare/EBSDsquare.m b/EBSDAnalysis/@EBSDsquare/EBSDsquare.m new file mode 100644 index 000000000..7d7a09ade --- /dev/null +++ b/EBSDAnalysis/@EBSDsquare/EBSDsquare.m @@ -0,0 +1,74 @@ +classdef EBSDsquare < EBSD + % EBSD data on a rectangular grid. In contrast to arbitrary EBSD data the + % values are stored in a matrix. + + % properties with as many rows as data + properties + end + + % general properties + properties + dx + dy + end + + properties (Dependent = true) + gradientX % orientation gradient in x + gradientY % orientation gradient in y + end + + methods + + function ebsd = EBSDsquare(rot,phaseId,phaseMap,CSList,dxy,varargin) + % generate a rectangular EBSD object + % + % Syntax + % EBSD(rot,phases,CSList) + + if nargin == 0, return; end + + sGrid = size(rot); + ebsd.rotations = rotation(rot); + ebsd.phaseId = phaseId; + ebsd.phaseMap = phaseMap; + ebsd.CSList = CSList; + ebsd.id = reshape(1:prod(sGrid),sGrid); + + % extract additional properties + ebsd.prop = get_option(varargin,'options',struct); + + % get unit cell + ebsd.dx = dxy(1); + ebsd.dy = dxy(2); + if check_option(varargin,'uniCell') + ebsd.unitCell = get_option(varargin,'unitCell',[]); + else + ebsd.unitCell = 0.5 * [dxy(1) * [1;1;-1;-1],dxy(1) * [1;-1;-1;1]]; + end + end + + % -------------------------------------------------------------- + + function varargout = size(ebsd,varargin) + [varargout{1:nargout}] = size(ebsd.id,varargin{:}); + end + + function gX = get.gradientX(ebsd) + ori = ebsd.orientations; + + ori_ref = ori(:,[2:end end-1]); + gX = log(ori,ori_ref);% ./ ebsd.dx; + gX(:,end) = - gX(:,end); + end + + function gY = get.gradientY(ebsd) + ori = ebsd.orientations; + + ori_ref = ori([2:end end-1],:); + gY = log(ori,ori_ref);% ./ ebsd.dy; + gY(end,:) = - gY(end,:); + end + + end + +end diff --git a/EBSDAnalysis/@EBSDsquare/fill.m b/EBSDAnalysis/@EBSDsquare/fill.m new file mode 100644 index 000000000..eb42f5eb3 --- /dev/null +++ b/EBSDAnalysis/@EBSDsquare/fill.m @@ -0,0 +1,51 @@ +function ebsd = fill(ebsd,varargin) +% fill spatial EBSD data +% +% The function |fill| changes the values of phaseId and graindId from NaN +% to a the value of its nearest neighbours. In case an grain object is +% specified as a second argument, only pixels that are entirely inside a +% grains will to associated to this grain. +% +% Syntax +% +% ebsd = fill(ebsd) +% ebsd = fill(ebsd,grains) +% +% Input +% ebsd - @EBSD +% +% Example + +grains = getClass(varargin,'grain2d',[]); +if isempty(grains) + + % the values to be filled + nanId = isnan(ebsd.phaseId); + + F = TriScatteredInterp([ebsd.prop.x(~nanId),ebsd.prop.y(~nanId)],... + find(~nanId),'nearest'); %#ok + newId = fix(F(ebsd.prop.x(nanId),ebsd.prop.y(nanId))); + + % interpolate phaseId + ebsd.phaseId(nanId) = ebsd.phaseId(newId); + + % interpolate grainId + try + ebsd.prop.grainId(nanId) = ebsd.prop.grainId(newId); + end + +else % check for whether the pixels are within certain grains + + % the values to be filled + nanId = find(isnan(ebsd.phaseId)); + + isInside = grains.checkInside(ebsd.subSet(nanId)); + + [ebsdId,hostId] = find(isInside); + + ebsd.grainId(nanId(ebsdId)) = grains.id(hostId); + ebsd.phaseId(nanId(ebsdId)) = grains.phaseId(hostId); + +end + +end diff --git a/EBSDAnalysis/@EBSDsquare/smooth.m b/EBSDAnalysis/@EBSDsquare/smooth.m new file mode 100644 index 000000000..6500a0536 --- /dev/null +++ b/EBSDAnalysis/@EBSDsquare/smooth.m @@ -0,0 +1,100 @@ +function [ebsd,filter] = smooth(ebsd,varargin) +% smooth spatial EBSD data +% +% Input +% ebsd - @EBSD +% +% Example +% mtexdata forsterite +% ebsd = ebsd('indexed'); +% % segment grains +% [grains,ebsd.grainId] = calcGrains(ebsd) +% +% % find largest grains +% largeGrains = grains(grains.grainSize>800) +% ebsd = ebsd(largeGrains(1)) +% +% figure +% plot(largeGrains(1).boundary,'linewidth',2) +% hold on +% oM = ipdfHSVOrientationMapping(ebsd); +% oM.inversePoleFigureDirection = mean(ebsd.orientations) * oM.whiteCenter; +% oM.maxAngle = 1.5*degree; +% plot(ebsd,oM.orientation2color(ebsd.orientations)) +% hold off +% +% ebsd_smoothed = smooth(ebsd.gridify) +% plot(ebsd_smoothed('indexed'),oM.orientation2color(ebsd_smoothed('indexed').orientations)) +% hold on +% plot(largeGrains(1).boundary,'linewidth',2) +% hold off + +% read input +filter = getClass(varargin,'EBSDFilter',splineFilter); + +% if possible smooth each grain seperately +% otherwise each phase seperately +try + grainId = ebsd.grainId; +catch + grainId = ebsd.phaseId; +end + +% extract some locale variables +CSList = ebsd.CSList; +rot = ebsd.rotations; + +[grainIds,pos] = unique(grainId(:)); +pos = pos(~isnan(grainIds)); +grainIds = grainIds(~isnan(grainIds)); +phaseIds = ebsd.phaseId(pos).'; +grainIds = grainIds.'; +progress(0,length(grainIds)); + +% find the largest grain +[~,m] = max(histc(grainId(:),0.5:1:max(grainId)+0.5)); + +% and sort it first +if m>1 + phaseIds = [phaseIds(grainIds==m),phaseIds(grainIds~=m)]; + grainIds = [m,grainIds(grainIds~=m)]; +end + +% loop through all grains or phases +for id = 1:length(grainIds) + + progress(id,length(grainIds)); + + % the values to be smoothed + ind = grainId == grainIds(id); + + % maybe there is nothing to do + if ~any(ind(:)), continue; end + + % local coordinates in a local rectangular grid + [irow,icol] = find(ind); + minCol = min(icol); nCol = 1 + max(icol) - minCol; + minRow = min(irow); nRow = 1 + max(irow) - minRow; + indLocal = sub2ind([nRow,nCol],irow - minRow + 1,icol - minCol + 1); + + % skip small grains + if nnz(ind)<5 || nRow < 2 || nCol < 2 || all(isnan(rot.a(ind))) + continue, + end + + % generate orientation grid + ori = orientation.nan(nRow,nCol,CSList{phaseIds(id)}); + ori(indLocal) = rot(ind); + + % perform smoothing + ori = filter.smooth(ori); + + % store as rotations + rot(ind) = ori(indLocal); + +end + +% store to EBSD variable +ebsd.rotations = rot; + +end diff --git a/EBSDAnalysis/@EBSDsquare/subsind.m b/EBSDAnalysis/@EBSDsquare/subsind.m new file mode 100644 index 000000000..117f4f944 --- /dev/null +++ b/EBSDAnalysis/@EBSDsquare/subsind.m @@ -0,0 +1,15 @@ +function ind = subsind(ebsd,subs) +% subindexing of EBSD data +% + +% ordinary indexing by id +if (ischar(subs{1}) && subs{1}(1) == ':') || ... + (isnumeric(subs{1}) && ~islogical(subs{1})) + ind = reshape(1:length(ebsd),size(ebsd)); + + ind = subsref(ind,struct('type','()','subs',{subs})); + return + +end + +ind = subsind@EBSD(ebsd,subs); From 5353b46c684b73edafcb5f2cc5df22aae924d4ac Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 23 Jan 2016 15:55:39 +0100 Subject: [PATCH 065/120] convert ordinary EBSD to raster EBSD --- EBSDAnalysis/@EBSD/gridify.m | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 EBSDAnalysis/@EBSD/gridify.m diff --git a/EBSDAnalysis/@EBSD/gridify.m b/EBSDAnalysis/@EBSD/gridify.m new file mode 100644 index 000000000..f559a9c02 --- /dev/null +++ b/EBSDAnalysis/@EBSD/gridify.m @@ -0,0 +1,51 @@ +function [ebsdGrid,newId] = gridify(ebsd,varargin) +% extend EBSD data to an grid +% +% Syntax +% [ebsdGrid,newId] = gridify(ebsd) +% +% Input +% +% Output +% ebsdGrid - +% newId - + +% generate regular grid +prop = ebsd.prop; +ext = ebsd.extend; +dx = max(ebsd.unitCell(:,1))-min(ebsd.unitCell(:,1)); +dy = max(ebsd.unitCell(:,2))-min(ebsd.unitCell(:,2)); +[prop.x,prop.y] = meshgrid(linspace(ext(1),ext(2),1+round((ext(2)-ext(1))/dx)),... + linspace(ext(3),ext(4),1+round((ext(4)-ext(3))/dy))); % ygrid runs first +sGrid = size(prop.x); + +% detect position within grid +newId = sub2ind(sGrid, 1 + round((ebsd.prop.y - ext(3))/dy), ... + 1 + round((ebsd.prop.x - ext(1))/dx)); + +% set phaseId to notIndexed at all empty grid points +phaseId = nan(sGrid); +phaseId(newId) = ebsd.phaseId; + +% update rotations +a = nan(sGrid); b = a; c = a; d = a; +a(newId) = ebsd.rotations.a; +b(newId) = ebsd.rotations.b; +c(newId) = ebsd.rotations.c; +d(newId) = ebsd.rotations.d; + +% update all other properties +for fn = fieldnames(ebsd.prop).' + if any(strcmp(char(fn),{'x','y','z'})), continue;end + if isnumeric(prop.(char(fn))) + prop.(char(fn)) = nan(sGrid); + else + prop.(char(fn)) = prop.(char(fn)).nan(sGrid); + end + prop.(char(fn))(newId) = ebsd.prop.(char(fn)); +end + +ebsdGrid = EBSDsquare(rotation(quaternion(a,b,c,d)),phaseId(:),... + ebsd.phaseMap,ebsd.CSList,[dx,dy],'options',prop); + +end \ No newline at end of file From e555e3c30f6f5a19f4ac1403dbc31f74a77ef42c Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 23 Jan 2016 16:22:37 +0100 Subject: [PATCH 066/120] adaption needed for EBSDsquare --- EBSDAnalysis/@EBSD/EBSD.m | 79 +++++---- EBSDAnalysis/@EBSD/calcGrains.m | 4 +- EBSDAnalysis/@EBSD/display.m | 5 + EBSDAnalysis/@EBSD/plot.m | 6 +- EBSDAnalysis/@EBSD/private/plotUnitCells.m | 4 +- EBSDAnalysis/@EBSD/smooth.m | 164 +----------------- EBSDAnalysis/@EBSD/{private => }/subsind.m | 12 +- EBSDAnalysis/@grainBoundary/plot.m | 2 +- EBSDAnalysis/phaseList.m | 4 +- doc/EBSDAnalysis/EBSDSmoothing.m | 24 ++- geometry/@orientation/dot_outer.m | 2 +- geometry/@quaternion/private/project2FR_ref.m | 1 + interfaces/loadEBSD.m | 4 + tools/math_tools/smoothn.m | 2 +- 14 files changed, 100 insertions(+), 213 deletions(-) rename EBSDAnalysis/@EBSD/{private => }/subsind.m (85%) diff --git a/EBSDAnalysis/@EBSD/EBSD.m b/EBSDAnalysis/@EBSD/EBSD.m index 0ad9d666c..c12ab777d 100644 --- a/EBSDAnalysis/@EBSD/EBSD.m +++ b/EBSDAnalysis/@EBSD/EBSD.m @@ -40,10 +40,8 @@ weights % grainId % id of the grain to which the EBSD measurement belongs to mis2mean % misorientation to the mean orientation of the corresponding grain - dx % step size in x - dy % step size in y - gradientX % orientation gradient in x - gradientY % orientation gradient in y +% dx % step size in x +% dy % step size in y end methods @@ -55,6 +53,21 @@ if nargin == 0, return; end + % copy constructor + if isa(rot,'EBSD') + ebsd.id = rot.id; + ebsd.rotations = rot.rotations; + ebsd.phaseId = rot.phaseId; + ebsd.phaseMap = rot.phaseMap; + ebsd.CSList = rot.CSList; + ebsd.unitCell = rot.unitCell; + ebsd.scanUnit = rot.scanUnit; + ebsd.A_D = rot.A_D; + ebsd.prop = rot.prop; + return + end + + ebsd.rotations = rotation(rot); ebsd = ebsd.init(phases,CSList); ebsd.id = (1:numel(phases)).'; @@ -116,7 +129,7 @@ function ebsd = set.grainId(ebsd,grainId) if numel(grainId) == length(ebsd) - ebsd.prop.grainId = grainId(:); + ebsd.prop.grainId = reshape(grainId,size(ebsd.id)); elseif numel(grainId) == nnz(ebsd.isIndexed) ebsd.prop.grainId = zeros(length(ebsd),1); ebsd.prop.grainId(ebsd.isIndexed) = grainId; @@ -150,41 +163,27 @@ ebsd.prop.weights = weights; end - function dx = get.dx(ebsd) - uc = ebsd.unitCell; - if size(uc,1) == 4 - dx = max(uc(:,1)) - min(uc(:,1)); - elseif size(uc,1) == 6 - dx = max(uc(:,1)) - min(uc(:,1)); - else - dx = inf; - end - end - - function dy = get.dy(ebsd) - uc = ebsd.unitCell; - if size(uc,1) == 4 - dy = max(uc(:,2)) - min(uc(:,2)); - elseif size(uc,1) == 6 - dy = max(uc(:,2)) - min(uc(:,2)); - else - dy = inf; - end - end - - function gX = get.gradientX(ebsd) - ori = ebsd.orientations; - if min(size(ori)) <= 1 - error('Gradient determination requires a regular grid') - end - - ori_ref = ori([2:end end-1],:); - gX = log(ori,ori_ref) ./ dx; - gX(end,:) = - gX(end,:); - end - - function gx = get.gradientY(ebsd) - end +% function dx = get.dx(ebsd) +% uc = ebsd.unitCell; +% if size(uc,1) == 4 +% dx = max(uc(:,1)) - min(uc(:,1)); +% elseif size(uc,1) == 6 +% dx = max(uc(:,1)) - min(uc(:,1)); +% else +% dx = inf; +% end +% end +% +% function dy = get.dy(ebsd) +% uc = ebsd.unitCell; +% if size(uc,1) == 4 +% dy = max(uc(:,2)) - min(uc(:,2)); +% elseif size(uc,1) == 6 +% dy = max(uc(:,2)) - min(uc(:,2)); +% else +% dy = inf; +% end +% end end diff --git a/EBSDAnalysis/@EBSD/calcGrains.m b/EBSDAnalysis/@EBSD/calcGrains.m index 58beb9487..d4431b7ee 100644 --- a/EBSDAnalysis/@EBSD/calcGrains.m +++ b/EBSDAnalysis/@EBSD/calcGrains.m @@ -75,8 +75,8 @@ % save grains.prop.GOS = GOS; -grains.prop.meanRotation = meanRotation; -mis2mean = inv(rotation(q(:))) .* meanRotation(grainId(:)); +grains.prop.meanRotation = reshape(meanRotation,[],1); +mis2mean = inv(rotation(q(:))) .* grains.prop.meanRotation(grainId(:)); end diff --git a/EBSDAnalysis/@EBSD/display.m b/EBSDAnalysis/@EBSD/display.m index 5c348cbe6..792f7608c 100644 --- a/EBSDAnalysis/@EBSD/display.m +++ b/EBSDAnalysis/@EBSD/display.m @@ -67,4 +67,9 @@ function display(ebsd,varargin) disp(char(dynProp(ebsd.prop),'Id',ebsd.id,'Phase',ebsd.phase,... 'orientation',ebsd.rotations)); disp([' Scan unit : ',ebsd.scanUnit]); + +if min(ebsd.size) > 1 + disp([' Grid size : ',size2str(ebsd)]); +end + disp(' '); diff --git a/EBSDAnalysis/@EBSD/plot.m b/EBSDAnalysis/@EBSD/plot.m index 3e526176e..3b01db25e 100644 --- a/EBSDAnalysis/@EBSD/plot.m +++ b/EBSDAnalysis/@EBSD/plot.m @@ -49,11 +49,11 @@ if nargin>1 && isnumeric(varargin{1}) property = varargin{1}; - + assert(any(numel(property) == length(ebsd) * [1,3]),... 'The number of values should match the number of ebsd data!') - h = plotUnitCells([ebsd.prop.x, ebsd.prop.y],... + h = plotUnitCells([ebsd.prop.x(:), ebsd.prop.y(:)],... property, ebsd.unitCell, 'parent', mP.ax, varargin{:}); else % phase plot @@ -81,7 +81,7 @@ % this is needed for the zoom: TODO maybe this can be done better %if isNew, ; end % TODO set axis tight removes all the plot try axis(mP.ax,'tight'); end -set(mP.ax,'zlim',[0,1]); +%set(mP.ax,'zlim',[0,1.1]); mP.extend(1) = min(mP.extend(1),min(ebsd.prop.x(:))); mP.extend(2) = max(mP.extend(2),max(ebsd.prop.x(:))); mP.extend(3) = min(mP.extend(3),min(ebsd.prop.y(:))); diff --git a/EBSDAnalysis/@EBSD/private/plotUnitCells.m b/EBSDAnalysis/@EBSD/private/plotUnitCells.m index 7fa100f8b..9c8ff60ee 100644 --- a/EBSDAnalysis/@EBSD/private/plotUnitCells.m +++ b/EBSDAnalysis/@EBSD/private/plotUnitCells.m @@ -12,7 +12,7 @@ end -if length(d) == size(xy,1) +if numel(d) == size(xy,1) || numel(d) == 3*size(xy,1) obj.FaceVertexCData = reshape(d,size(xy,1),[]); %if size(d,2) == 3, set(get(ax,'parent'),'renderer','opengl');end @@ -54,8 +54,6 @@ end - - h = optiondraw(patch(obj,'parent',ax),varargin{:}); if ~check_option(varargin,'DisplayName') diff --git a/EBSDAnalysis/@EBSD/smooth.m b/EBSDAnalysis/@EBSD/smooth.m index fd45f84ea..c08a60a46 100644 --- a/EBSDAnalysis/@EBSD/smooth.m +++ b/EBSDAnalysis/@EBSD/smooth.m @@ -1,4 +1,4 @@ -function [ebsd,filter,filledId] = smooth(ebsd,varargin) +function [ebsd,filter] = smooth(ebsd,varargin) % smooth spatial EBSD % % Input @@ -29,162 +29,14 @@ % plot(largeGrains(1).boundary,'linewidth',2) % hold off +% make a gridded ebsd data set +ebsd = ebsd.gridify(varargin{:}); -% generate regular grid -ext = ebsd.extend; -dx = max(ebsd.unitCell(:,1))-min(ebsd.unitCell(:,1)); -dy = max(ebsd.unitCell(:,2))-min(ebsd.unitCell(:,2)); -[xgrid,ygrid] = meshgrid(linspace(ext(1),ext(2),1+round((ext(2)-ext(1))/dx)),... - linspace(ext(3),ext(4),1+round((ext(4)-ext(3))/dy))); % ygrid runs first -sGrid = size(xgrid); +% fill holes if needed +if check_option(varargin,'fill'), ebsd = fill(ebsd,varargin{:}); end -% detect position within grid -ind = sub2ind(sGrid, 1 + round((ebsd.prop.y - ext(3))/dy), ... - 1 + round((ebsd.prop.x - ext(1))/dx)); +[ebsd,filter] = smooth(ebsd,varargin{:}); -% some interpolation -if check_option(varargin,'fill') - F = TriScatteredInterp([ebsd.prop.x(:),ebsd.prop.y(:)],(1:length(ebsd.prop.x)).','nearest'); %#ok - idOld = fix(F(xgrid(:),ygrid(:))); +% remove nan data used to generate the grid +ebsd = ebsd.subSet(~isnan(ebsd.phaseId)); - filledId = true(sGrid); - filledId(ind) = false; - - % interpolate phaseId - ebsd.phaseId = reshape(ebsd.phaseId(idOld),[],1); - - % interpolate grainId - if isfield(ebsd.prop,'grainId') - grainId = reshape(ebsd.prop.grainId(idOld),sGrid); - ebsd.prop.grainId = grainId(:); - else - grainId = ebsd.phaseId(idOld); - end -else - % set phaseId to notIndexed at all empty grid points - phaseId = ones(sGrid); - phaseId(ind) = ebsd.phaseId; - ebsd.phaseId = phaseId(:); - - if isfield(ebsd.prop,'grainId') - grainId = zeros(sGrid); - grainId(ind) = ebsd.grainId; - ebsd.prop.grainId = grainId(:); - else - grainId = phaseId; - end - - clear phaseId -end - -% update spatial coordiantes -ebsd.prop.x = xgrid(:); -ebsd.prop.y = ygrid(:); -ebsd.id = (1:numel(xgrid)).'; -clear xgrid ygrid - -% update rotations -a = nan(sGrid); b = a; c = a; d = a; -a(ind) = ebsd.rotations.a; -b(ind) = ebsd.rotations.b; -c(ind) = ebsd.rotations.c; -d(ind) = ebsd.rotations.d; -ebsd.rotations = reshape(rotation(quaternion(a,b,c,d)),[],1); -clear a b c d - -% delete all other properties -for fn = fieldnames(ebsd.prop).' - if any(strcmp(char(fn),{'x','y','z','grainId'})), continue;end - ebsd.prop = rmfield(ebsd.prop,fn); -end - - -% extract data for speed reasons -rot = reshape(ebsd.rotations,sGrid); -rot.a(~ebsd.isIndexed) = NaN; -rot.b(~ebsd.isIndexed) = NaN; -rot.c(~ebsd.isIndexed) = NaN; -rot.d(~ebsd.isIndexed) = NaN; - -CSList = ebsd.CSList; - -% loop through all grains -[grainIds,pos] = unique(grainId); -phaseIds = ebsd.phaseId(pos).'; -grainIds = grainIds.'; -progress(0,length(grainIds)); - -% find the largest grain -[~,m] = max(histc(grainId(:),0.5:1:max(grainId)+0.5)); - -% and sort it first -if m>1 - phaseIds = [phaseIds(grainIds==m),phaseIds(grainIds~=m)]; - grainIds = [m,grainIds(grainIds~=m)]; -end - -filter = getClass(varargin,'EBSDFilter',splineFilter); - -for id = 1:length(grainIds) - - progress(id,length(grainIds)); - - % the values to be smoothed - ind = grainId == grainIds(id); - - if ~any(ind(:)), continue; end - % check all the vertices are inside the grain - % checkNaN = ind & isnan(rot.a); - - % local coordinates in a local rectangular grid - [irow,icol] = find(ind); - minCol = min(icol); nCol = 1 + max(icol) - minCol; - minRow = min(irow); nRow = 1 + max(irow) - minRow; - indLocal = sub2ind([nRow,nCol],irow - minRow + 1,icol - minCol + 1); - - % skip small grains - if nnz(ind)<5 || nRow < 2 || nCol < 2 || all(isnan(rot(ind).a)), continue, end - %if all(isnan(rot(ind).a)), continue, end - - %phaseId = ebsd.phaseId(ind); - %if ischar(CSList{phaseId(1)}), continue; end - - ori = orientation(nanquaternion(nRow,nCol),CSList{phaseIds(id)}); - ori(indLocal) = rot(ind); - - % perform smoothing - ori = filter.smooth(ori); - - % rotate back - rot(ind) = ori(indLocal); - -end - -% store to EBSD variable -ebsd.rotations = rot(:); - -end - -%mtexdata forsterite -%ebsd = ebsd(inpolygon(ebsd,[5 2 10 5]*10^3)); -%[grains,ebsd.grainId,ebsd.mis2mean] = calcGrains(ebsd('indexed')) -%grains = smooth(grains) -%oM = ipdfHSVOrientationMapping(ebsd('fo').CS.properGroup) -%oM.inversePoleFigureDirection = Miller(oM.whiteCenter,ebsd('fo').CS.properGroup); -%oM.colorStretching = 7; -%plot(ebsd('fo'),oM.orientation2color(ebsd('fo').mis2mean)) -%hold on -%plot(grains.boundary) -%hold off -%figure -%plot(oM) -%ebsd_smoothed = smooth(ebsd) - -% [~,id] = max(grains.area) -% ebsd = ebsd(grains(id)) -% oM = ipdfHSVOrientationMapping(ebsd('fo').CS.properGroup) -% oM.inversePoleFigureDirection = grains(id).meanOrientation*oM.whiteCenter; -% oM.colorStretching = 7; -% plot(ebsd,oM.orientation2color(ebsd.orientations)) -% ebsd_smoothed = smooth(ebsd) -% plot(ebsd_smoothed,oM.orientation2color(ebsd_smoothed.orientations)) diff --git a/EBSDAnalysis/@EBSD/private/subsind.m b/EBSDAnalysis/@EBSD/subsind.m similarity index 85% rename from EBSDAnalysis/@EBSD/private/subsind.m rename to EBSDAnalysis/@EBSD/subsind.m index 018647b86..f6f7fffb6 100644 --- a/EBSDAnalysis/@EBSD/private/subsind.m +++ b/EBSDAnalysis/@EBSD/subsind.m @@ -37,7 +37,11 @@ end end - ind = ind & phases(ebsd.phaseId(:)); + phaseId = ebsd.phaseId; + phaseId(isnan(phaseId)) = 1+numel(phases); + phases(end+1) = false; + + ind = ind & phases(phaseId(:)); elseif isa(subs{i},'symmetry') @@ -57,13 +61,13 @@ 'You should compute grains by the command'],... ' [grains,ebsd.grainId] = calcGrains(ebsd)'); end - ind = ind & ismember(ebsd.prop.grainId,subs{i}.id); + ind = ind & ismember(ebsd.prop.grainId(:),subs{i}.id); elseif isa(subs{i},'logical') - sub = any(subs{i}, find(size(subs{i}')==max(size(ind)),1)); + %sub = any(subs{i}, find(size(subs{i}')==max(size(ind)),1)); - ind = ind & sub(:); + ind = ind & subs{i}(:); elseif isnumeric(subs{i}) diff --git a/EBSDAnalysis/@grainBoundary/plot.m b/EBSDAnalysis/@grainBoundary/plot.m index bb8ec01bc..21db17a50 100644 --- a/EBSDAnalysis/@grainBoundary/plot.m +++ b/EBSDAnalysis/@grainBoundary/plot.m @@ -61,7 +61,7 @@ warning('on','MATLAB:legend:PlotEmpty'); try axis(mP.ax,'tight'); end -set(mP.ax,'zlim',[0,1]); +set(mP.ax,'zlim',[0,1.1]); mP.micronBar.setOnTop if nargout == 0, clear h; end diff --git a/EBSDAnalysis/phaseList.m b/EBSDAnalysis/phaseList.m index cb6b57b81..b08e661a3 100644 --- a/EBSDAnalysis/phaseList.m +++ b/EBSDAnalysis/phaseList.m @@ -273,7 +273,9 @@ function id = checkSinglePhase(pL) % ensure single phase - id = unique(pL.phaseId,'rows'); + phaseId = pL.phaseId; %#ok<*PROP> + phaseId = phaseId(~any(isnan(pL.phaseId),2),:); + id = unique(phaseId,'rows'); if numel(id)>size(pL.phaseId,2) diff --git a/doc/EBSDAnalysis/EBSDSmoothing.m b/doc/EBSDAnalysis/EBSDSmoothing.m index 4289de2e8..af037654a 100644 --- a/doc/EBSDAnalysis/EBSDSmoothing.m +++ b/doc/EBSDAnalysis/EBSDSmoothing.m @@ -213,9 +213,14 @@ hold off %% +% Using the option |fill| the command |smooth| fills the holes inside the +% grains. Note that the notindexed pixels at the grain boundaries kept +% untouched. In order to allow MTEX to decide wheter a pixel is inside a +% grain or not the |grain| variable has to be passed as additional +% argument. F = splineFilter; -ebsd_smoothed = smooth(ebsd('indexed'),F,'fill'); +ebsd_smoothed = smooth(ebsd('indexed'),F,'fill',grains); plot(ebsd_smoothed('Fo'),ebsd_smoothed('Fo').orientations) hold on @@ -254,3 +259,20 @@ % plot boundary plot(grains.boundary,'linewidth',1.5) hold off + +%% +% If no |grain| variable is passed to the smoothing command the not indexed +% pixels are assigned to the nearest neighbour. + +ebsd_smoothed = smooth(ebsd('indexed'),F,'fill'); + +plot(ebsd_smoothed('Fo'),ebsd_smoothed('Fo').orientations) +hold on +plot(ebsd_smoothed('En'),ebsd_smoothed('En').orientations) +plot(ebsd_smoothed('Di'),ebsd_smoothed('Di').orientations) + +% plot the boundary of all grains +plot(grains.boundary,'linewidth',1.5) + +% stop overide mode +hold off diff --git a/geometry/@orientation/dot_outer.m b/geometry/@orientation/dot_outer.m index fef7a945e..676e10ddc 100644 --- a/geometry/@orientation/dot_outer.m +++ b/geometry/@orientation/dot_outer.m @@ -27,7 +27,7 @@ % maybe we can shrink down everything to quaternion if cs.isLaue || ss.isLaue || (cs.isProper && ss.isProper ... - && all(o1.i == o1.i(1)) && all(o2.i == o1.i(1))) + && all(o1.i(:) == o1.i(1)) && all(o2.i(:) == o1.i(1))) cs = cs.properGroup; ss = ss.properGroup; diff --git a/geometry/@quaternion/private/project2FR_ref.m b/geometry/@quaternion/private/project2FR_ref.m index 7ae0fb35e..446775fba 100644 --- a/geometry/@quaternion/private/project2FR_ref.m +++ b/geometry/@quaternion/private/project2FR_ref.m @@ -15,6 +15,7 @@ % q = reshape(q,[],1); +q_ref = reshape(q_ref,[],1); % compute distance to reference orientation co2 = abs(dot(q,q_ref)); diff --git a/interfaces/loadEBSD.m b/interfaces/loadEBSD.m index 229ed6eb7..a5c1e8c52 100644 --- a/interfaces/loadEBSD.m +++ b/interfaces/loadEBSD.m @@ -71,3 +71,7 @@ ebsd.unitCell = calcUnitCell([ebsd.x(:),ebsd.y(:),ebsd.z(:)],varargin{:}); close(hw) end + +if length(ebsd.unitCell) == 4 + ebsd = ebsd.gridify; +end diff --git a/tools/math_tools/smoothn.m b/tools/math_tools/smoothn.m index 2450b9ea5..ce8cebf3f 100644 --- a/tools/math_tools/smoothn.m +++ b/tools/math_tools/smoothn.m @@ -226,7 +226,7 @@ % href="matlab:web('http://www.biomecardio.com')">www.BiomeCardio.com %% Check input arguments -error(nargchk(1,5,nargin)); +%error(nargchk(1,5,nargin)); OPTIONS = struct; NArgIn = nargin; if isstruct(varargin{end}) % SMOOTHN(...,OPTIONS) From 4bb6e9ce9abcb473fe1fbae5f53ac293be397b9c Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 29 Jan 2016 17:03:10 +0100 Subject: [PATCH 067/120] bug fix --- EBSDAnalysis/@grain2d/checkInside.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/EBSDAnalysis/@grain2d/checkInside.m b/EBSDAnalysis/@grain2d/checkInside.m index c79d7a01e..c40a12b20 100644 --- a/EBSDAnalysis/@grain2d/checkInside.m +++ b/EBSDAnalysis/@grain2d/checkInside.m @@ -13,8 +13,11 @@ % % Output % isInside - numInclusionGrains x numHostGrains matrix +% isInside - numEBSD x numHostGrains matrix +% isInside - numXY x numHostGrains matrix % -% Options +% Note, for an EBSD pixel to be inside a grain it has to be completely +% inside the grain. Pixels at the boundary may belong to no grain. % % Example % mtexdata small @@ -50,7 +53,7 @@ for i = 2:size(uc,1) isInside = isInside & grains.checkInside(xy+repmat(uc(i,:),size(xy,1),1)); end - isInside = any(isInside,2); + return end From 387eea84dafc3de76915a7c95b97f57b8725e4e1 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Thu, 4 Feb 2016 12:00:40 +0100 Subject: [PATCH 068/120] initial implementation of calcGND --- EBSDAnalysis/@EBSDsquare/calcGND.m | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 EBSDAnalysis/@EBSDsquare/calcGND.m diff --git a/EBSDAnalysis/@EBSDsquare/calcGND.m b/EBSDAnalysis/@EBSDsquare/calcGND.m new file mode 100644 index 000000000..555a0fa5a --- /dev/null +++ b/EBSDAnalysis/@EBSDsquare/calcGND.m @@ -0,0 +1,38 @@ +function gnd = calcGND(ebsd,varargin) +% compute the geometrically necessary dislocation +% +% Formulae are taken from the paper +% Resolving the geometrically necessary dislocation content by +% conventional electron backscattering diffraction +% authors: Pantleon +% Scripta Materialia, 2008 +% +% Syntax +% gnd = calcGND(ebsd) +% +% Input +% ebsd - @EBSDSquare +% +% Output + +% compute the gradients +gX = double(ebsd.gradientX(:)); +gY = double(ebsd.gradientY(:)); + +% initialize an empty matrix for the dislocation tensor +kappa = zeros(3,3); + +% initalize the ouput +gnd = nan(size(ebsd)); + +% compute the GND +for i = 1:length(ebsd) + + kappa(1,:) = gX(i,:); + kappa(2,:) = gY(i,:); + + alpha = kappa - trace(kappa)*eye(3); + + gnd(i) = norm(alpha,2); + +end From 1907e2807d426fd79c649f358a06228665543821 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Thu, 4 Feb 2016 12:17:20 +0100 Subject: [PATCH 069/120] mtex-4.3.beta1 --- Makefile | 2 +- VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f1cf6899a..dd44eb85f 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ clean: # rule for making release -RNAME = mtex-4.2.2 +RNAME = mtex-4.3.beta1 RDIR = ../releases release: rm -rf $(RDIR)/$(RNAME)* diff --git a/VERSION b/VERSION index 20f771c69..7891cc674 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -MTEX 4.2.2 +MTEX 4.3.beta1 From bab4df00f4f1c2121bf0368783aa9b2098374767 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 9 Feb 2016 16:41:27 +0100 Subject: [PATCH 070/120] do not gridify by default --- interfaces/loadEBSD.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/loadEBSD.m b/interfaces/loadEBSD.m index a5c1e8c52..ead88c6ab 100644 --- a/interfaces/loadEBSD.m +++ b/interfaces/loadEBSD.m @@ -72,6 +72,6 @@ close(hw) end -if length(ebsd.unitCell) == 4 - ebsd = ebsd.gridify; +if length(ebsd.unitCell) == 4, + %ebsd = ebsd.gridify; end From e5a8354839c143269bbc4388269eed8fea13bcd9 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 9 Feb 2016 16:42:25 +0100 Subject: [PATCH 071/120] do not set zlim --- EBSDAnalysis/@grainBoundary/plot.m | 1 - 1 file changed, 1 deletion(-) diff --git a/EBSDAnalysis/@grainBoundary/plot.m b/EBSDAnalysis/@grainBoundary/plot.m index 21db17a50..90642bbf2 100644 --- a/EBSDAnalysis/@grainBoundary/plot.m +++ b/EBSDAnalysis/@grainBoundary/plot.m @@ -61,7 +61,6 @@ warning('on','MATLAB:legend:PlotEmpty'); try axis(mP.ax,'tight'); end -set(mP.ax,'zlim',[0,1.1]); mP.micronBar.setOnTop if nargout == 0, clear h; end From 0ab1f9ab8d593d663b892759517ff5b28bad6b20 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 15 Feb 2016 16:47:24 +0100 Subject: [PATCH 072/120] this seem to be not required anymore --- EBSDAnalysis/@grain2d/plot.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EBSDAnalysis/@grain2d/plot.m b/EBSDAnalysis/@grain2d/plot.m index e962e9c66..89e198837 100644 --- a/EBSDAnalysis/@grain2d/plot.m +++ b/EBSDAnalysis/@grain2d/plot.m @@ -89,7 +89,7 @@ % keep track of the extend of the graphics % this is needed for the zoom: TODO maybe this can be done better -axis(mP.ax,'tight'); set(mP.ax,'zlim',[0,1]); +axis(mP.ax,'tight'); if nargout == 0, clear h;end From 7a8cc8ddb9825aa51cdb6fc53daeac6cfad5eac5 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 15 Feb 2016 16:48:37 +0100 Subject: [PATCH 073/120] make gradient spacing aware --- EBSDAnalysis/@EBSDsquare/EBSDsquare.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EBSDAnalysis/@EBSDsquare/EBSDsquare.m b/EBSDAnalysis/@EBSDsquare/EBSDsquare.m index 7d7a09ade..4579b7e35 100644 --- a/EBSDAnalysis/@EBSDsquare/EBSDsquare.m +++ b/EBSDAnalysis/@EBSDsquare/EBSDsquare.m @@ -57,7 +57,7 @@ ori = ebsd.orientations; ori_ref = ori(:,[2:end end-1]); - gX = log(ori,ori_ref);% ./ ebsd.dx; + gX = log(ori,ori_ref) ./ ebsd.dx; gX(:,end) = - gX(:,end); end @@ -65,7 +65,7 @@ ori = ebsd.orientations; ori_ref = ori([2:end end-1],:); - gY = log(ori,ori_ref);% ./ ebsd.dy; + gY = log(ori,ori_ref) ./ ebsd.dy; gY(end,:) = - gY(end,:); end From 2dcbe808f452ddbbfe09e97f5717495d441b8c0e Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 22 Feb 2016 07:48:46 +0100 Subject: [PATCH 074/120] important bug fix --- geometry/@orientation/angle.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry/@orientation/angle.m b/geometry/@orientation/angle.m index 37e178ab0..6a6d74e33 100644 --- a/geometry/@orientation/angle.m +++ b/geometry/@orientation/angle.m @@ -38,6 +38,6 @@ % compute all distances to the symmetric equivalent orientations % and take the minimum - omega(notInside) = 2 * real(acos(max(abs(dot_outer(q.subSet(notInside),inv(qs))),[],2))); + omega(notInside) = 2 * real(acos(max(abs(dot_outer(q.subSet(notInside),qs)),[],2))); end From 92afc6fab1d4b0cfac3c2d15aadb5bd73060d226 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 22 Feb 2016 07:49:05 +0100 Subject: [PATCH 075/120] do not show label in plotSection --- plotting/ODFSections/axisAngleSections.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plotting/ODFSections/axisAngleSections.m b/plotting/ODFSections/axisAngleSections.m index 1910c1cb5..74ab40475 100644 --- a/plotting/ODFSections/axisAngleSections.m +++ b/plotting/ODFSections/axisAngleSections.m @@ -76,7 +76,8 @@ if isempty(findall(ax,'tag','outerBoundary')) plot(fundamentalSector(oS.jointCS,varargin{:}),'parent',ax,... 'TR',['\omega = ' int2str(oS.angles(sec)./degree),'^\circ'],'color',[0.8 0.8 0.8],... - 'doNotDraw','tag','outerBoundary','xAxisDirection','east','zAxisDirection','outOfPlane','hitTest','off'); + 'doNotDraw','tag','outerBoundary','noLabel',... + 'xAxisDirection','east','zAxisDirection','outOfPlane','hitTest','off'); end % rescale the axes according to actual volume From 101eea57859af4c25b34c2dc6f0b8c7cfecef247 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 22 Feb 2016 07:49:27 +0100 Subject: [PATCH 076/120] proper checkInside --- geometry/@orientationRegion/checkInside.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/geometry/@orientationRegion/checkInside.m b/geometry/@orientationRegion/checkInside.m index b7c7cdccc..90e137b05 100644 --- a/geometry/@orientationRegion/checkInside.m +++ b/geometry/@orientationRegion/checkInside.m @@ -1,6 +1,9 @@ function inside = checkInside(oR,q,varargin) % check for points to be inside the orientation region +% avoid q beeing orientation +q = quaternion(q); + if isempty(oR.N), inside = true(size(q)); return; end if isempty(q), inside = false(size(q)); return; end From cbba88c11db8f7eef9b1bd836cbf400c5b0a3d75 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 22 Feb 2016 07:49:45 +0100 Subject: [PATCH 077/120] allow colorbar position to be set --- plotting/@mtexFigure/colorbar.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plotting/@mtexFigure/colorbar.m b/plotting/@mtexFigure/colorbar.m index 34bf38a16..bce57a227 100644 --- a/plotting/@mtexFigure/colorbar.m +++ b/plotting/@mtexFigure/colorbar.m @@ -42,8 +42,10 @@ set(peer,'CLim',[0,c(2)]); end - fs = getMTEXpref('FontSize'); - h = optiondraw(colorbar('peer',peer,'eastoutside','units','pixel',... + fs = getMTEXpref('FontSize'); + location = ['eastoutside',extract_option(varargin,{'eastoutside','southoutside',... + 'northoutside','westoutside'})]; + h = optiondraw(colorbar('peer',peer,location{end},'units','pixel',... 'FontSize',fs),varargin{:}); if check_option(varargin,'title') From d1cf5e72cb91a01040315c699430b9b3051fbb85 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 22 Feb 2016 07:49:57 +0100 Subject: [PATCH 078/120] minor --- EBSDAnalysis/@EBSD/plot.m | 2 ++ ODFAnalysis/@FourierComponent/display.m | 2 +- doc/GrainAnalysis/GrainReconstructionDemo.m | 28 ++++++++++----------- tools/misc_tools/docmethods.m | 8 +----- tools/option_tools/extractOptions.m | 2 +- 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/EBSDAnalysis/@EBSD/plot.m b/EBSDAnalysis/@EBSD/plot.m index 3b01db25e..b33d4a6a4 100644 --- a/EBSDAnalysis/@EBSD/plot.m +++ b/EBSDAnalysis/@EBSD/plot.m @@ -91,6 +91,8 @@ if isNew mtexFig.drawNow('figSize',getMTEXpref('figSize'),varargin{:}); +else + mP.micronBar.setOnTop end mtexFig.keepAspectRatio = false; diff --git a/ODFAnalysis/@FourierComponent/display.m b/ODFAnalysis/@FourierComponent/display.m index 2881f8f21..c1ca1cd81 100644 --- a/ODFAnalysis/@FourierComponent/display.m +++ b/ODFAnalysis/@FourierComponent/display.m @@ -1,7 +1,7 @@ function display(component,varargin) % called by standard output -disp(' Portion specified by Fourier coefficients:'); +disp(' Harmonic portion:'); disp([' degree: ',int2str(dim2deg(length(component.f_hat)))]); end diff --git a/doc/GrainAnalysis/GrainReconstructionDemo.m b/doc/GrainAnalysis/GrainReconstructionDemo.m index 03a32a310..559d3fc74 100644 --- a/doc/GrainAnalysis/GrainReconstructionDemo.m +++ b/doc/GrainAnalysis/GrainReconstructionDemo.m @@ -59,7 +59,7 @@ % % Due to the measurement grid the grain boundaries often show a typical % stair case effect. This effect can be reduced by smoothing the grain -% boundaries. Using the command . +% boundaries. Using the command . % smooth the grains grains = smooth(grains); @@ -78,28 +78,28 @@ % below a table of most of the properties that are stored or can be % computed for grains % -% || || grain area in square || -% || || grain length / grain width || +% || || grain area in square || +% || || grain length / grain width || % || || list of boundary segments|| -% || || number of boundary segments || -% || || area difference between grain and its convex hull|| -% || || x,y coordinates of the barycenter of the grain || +% || || number of boundary segments || +% || || area difference between grain and its convex hull|| +% || || x,y coordinates of the barycenter of the grain || % || *grains.CS* || crystal symmetry (single phase only)|| -% || || diameter in || -% || || perimeter of fitted ellipse || -% || || radius of fitted ellipse || +% || || diameter in || +% || || perimeter of fitted ellipse || +% || || radius of fitted ellipse || % || *grains.GOS* || grain orientation spread|| % || *grains.grainSize* || number of measurements per grain|| -% || || check for inclusions || +% || || check for inclusions || % || *grains.id* || grain id|| % || || list of inner boundary segments|| % || *grains.meanOrientation* || meanOrientation (single phase only)|| % || *grains.mineral* || mineral name (single phase only)|| -% || || number and ids of neighbouring grains || +% || || number and ids of neighbouring grains || % || *grains.phase* || phase identifier|| -% || || perimeter in || -% || || length and widht of fitted ellipse || -% || || qotient perimeter / perimeter of fitted ellipse|| +% || || perimeter in || +% || || length and widht of fitted ellipse || +% || || qotient perimeter / perimeter of fitted ellipse|| % || || list of triple points|| % || *grains.x* || x coordintes of the vertices|| % || *grains.y* || y coordintes of the vertices|| diff --git a/tools/misc_tools/docmethods.m b/tools/misc_tools/docmethods.m index d87868b57..a9ffdbacc 100644 --- a/tools/misc_tools/docmethods.m +++ b/tools/misc_tools/docmethods.m @@ -1,11 +1,5 @@ function varargout = docmethods(obj) -% for octave skip this -if isOctave - varargout{1} = ''; - return; -end - % if nargout > 0 && ischar(obj) @@ -24,7 +18,7 @@ else - [fun in] = methods(obj,'-full'); + [fun, in] = methods(obj,'-full'); if ischar(obj) classname = obj; diff --git a/tools/option_tools/extractOptions.m b/tools/option_tools/extractOptions.m index f922e44eb..b9d1da518 100644 --- a/tools/option_tools/extractOptions.m +++ b/tools/option_tools/extractOptions.m @@ -8,7 +8,7 @@ % Output % opt - struct % -%% See also +% See also % getOption setOption addOption fnames = fieldnames(opt); From 2936666921e083155f841a046db91917c32bdbf8 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 22 Feb 2016 07:51:00 +0100 Subject: [PATCH 079/120] fix empty plot --- EBSDAnalysis/@triplePointList/plot.m | 1 - 1 file changed, 1 deletion(-) diff --git a/EBSDAnalysis/@triplePointList/plot.m b/EBSDAnalysis/@triplePointList/plot.m index 8e82b5f75..8b35519a2 100644 --- a/EBSDAnalysis/@triplePointList/plot.m +++ b/EBSDAnalysis/@triplePointList/plot.m @@ -78,7 +78,6 @@ warning('on','MATLAB:legend:PlotEmpty'); try axis(mP.ax,'tight'); end -set(mP.ax,'zlim',[0,1]); mP.micronBar.setOnTop if nargout == 0, clear h; end From 3dd546c0ab82942474c73da732662df467674fad Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 22 Feb 2016 07:51:15 +0100 Subject: [PATCH 080/120] tensor rotate should preserve type --- geometry/@tensor/rotate.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/geometry/@tensor/rotate.m b/geometry/@tensor/rotate.m index 3d850ab2a..d2ef10be9 100755 --- a/geometry/@tensor/rotate.m +++ b/geometry/@tensor/rotate.m @@ -22,6 +22,9 @@ % convert rotation to 3 x 3 matrix - (3 x 3 x N) for many rotation if ~isnumeric(R), R = matrix(R); end +% store tensor type +opt = T.opt; + % mulitply the tensor with respect to every dimension with the rotation % matrix for d = 1:T.rank @@ -32,4 +35,5 @@ end - +% rotating should not chage the type of a tensor +T.opt = opt; From dc3cbe7529c0b41841fc1893e3d312f5f4a03a4d Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 22 Feb 2016 07:51:36 +0100 Subject: [PATCH 081/120] better tensor plot --- geometry/@tensor/plot.m | 9 +++++++-- plotting/sphericalPlot.m | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/geometry/@tensor/plot.m b/geometry/@tensor/plot.m index 058673d5d..8ede4f236 100755 --- a/geometry/@tensor/plot.m +++ b/geometry/@tensor/plot.m @@ -151,9 +151,14 @@ function plot(T,varargin) if isa(d,'vector3d') d.antipodal = true; - quiver(S2,d,varargin{:}); + quiver(S2,d,varargin{:},T.CS); else - plot(S2,d,'contourf',varargin{:}); + plot(S2,d,'contourf',varargin{:},T.CS); + end + + if isNew && ~isa(T.CS,'crystalSymmetry') + pfAnnotations = getMTEXpref('pfAnnotations'); + pfAnnotations('parent',mtexFig.gca); end end diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index 7ef1129a7..049a4fc7f 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -46,7 +46,7 @@ % store hold status washold = getHoldState(ax); - CS = getClass(varargin,'symmetry',[]); + CS = getClass(varargin,'crystalSymmetry',[]); if isa(sP.proj,'plainProjection') From 92befdbe5e29ccbb3e0c2a06be1bcd74c6dc36ce Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 22 Feb 2016 07:51:48 +0100 Subject: [PATCH 082/120] new beta --- Makefile | 2 +- VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dd44eb85f..72cd60c9e 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ clean: # rule for making release -RNAME = mtex-4.3.beta1 +RNAME = mtex-4.3.beta2 RDIR = ../releases release: rm -rf $(RDIR)/$(RNAME)* diff --git a/VERSION b/VERSION index 7891cc674..5c75d7f6d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -MTEX 4.3.beta1 +MTEX 4.3.beta2 From 08f270b11ef9126eb3d4b7713035bf76544e1cbd Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sun, 28 Feb 2016 19:25:24 +0100 Subject: [PATCH 083/120] bug fix --- geometry/@vector3d/abs.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry/@vector3d/abs.m b/geometry/@vector3d/abs.m index f90bcefb7..4be58ca1e 100644 --- a/geometry/@vector3d/abs.m +++ b/geometry/@vector3d/abs.m @@ -1,4 +1,4 @@ function a = abs(v) % length of vector -a = sqrt(norm(v)); +a = norm(v); From 1c67dfbd36e6f8174cbeced1210ccc2161199e51 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sun, 28 Feb 2016 20:10:40 +0100 Subject: [PATCH 084/120] compatibility issue --- compatibility/8.4/isgraphics.m | 6 ++++++ startup_mtex.m | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 compatibility/8.4/isgraphics.m diff --git a/compatibility/8.4/isgraphics.m b/compatibility/8.4/isgraphics.m new file mode 100644 index 000000000..66bb03a51 --- /dev/null +++ b/compatibility/8.4/isgraphics.m @@ -0,0 +1,6 @@ +function out = isgraphics(h,type) + +out = ishandle(h) && strcmpi(get(h,'type'),type); + +end + diff --git a/startup_mtex.m b/startup_mtex.m index f11977c6d..b897e4fcc 100644 --- a/startup_mtex.m +++ b/startup_mtex.m @@ -125,7 +125,13 @@ function do_install(local_path) % set MTEX search path function setMTEXPath(local_path) -addpath_recurse(local_path,{'c','data','help','templates'}); +exclPath = {'c','data','help','templates'}; + +if ~MATLABverLessThan('8.5') + exclPath = [exclPath,'8.4']; +end + +addpath_recurse(local_path,exclPath); end From eaeffe2dd810abe56cd57c67147c8fc831ae2aa9 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sun, 28 Feb 2016 22:04:30 +0100 Subject: [PATCH 085/120] Miller might be a matter tensor --- geometry/@tensor/tensor.m | 3 +-- geometry/@vector3d/SchmidTensor.m | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/geometry/@tensor/tensor.m b/geometry/@tensor/tensor.m index 74f7b1bb2..914c26e7d 100755 --- a/geometry/@tensor/tensor.m +++ b/geometry/@tensor/tensor.m @@ -44,6 +44,7 @@ if isa(M,'vector3d') % conversion from vector3d T.M = shiftdim(double(M),ndims(M)); r = 1; + if isa(M,'Miller'), T.CS = M.CS; end elseif isa(M,'quaternion') % conversion from quaternion @@ -89,8 +90,6 @@ if ~isempty(args) T.CS = varargin{args}; varargin(args) = []; - else - T.CS = specimenSymmetry; end options = delete_option(varargin,{'doubleconvention','singleconvention','InfoLevel','noCheck'}); diff --git a/geometry/@vector3d/SchmidTensor.m b/geometry/@vector3d/SchmidTensor.m index 4a1d1b9af..b115fcffb 100644 --- a/geometry/@vector3d/SchmidTensor.m +++ b/geometry/@vector3d/SchmidTensor.m @@ -16,8 +16,8 @@ % % normalize and convert to tensor -tn = tensor(n./norm(n)); -tb = tensor(b./norm(b)); +tn = tensor(n.normalize,'noCheck'); +tb = tensor(b.normalize,'noCheck'); if check_option(varargin,'generalized') From 726da6beeb594571d379291632a9ef8b2ea1b3e4 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sun, 28 Feb 2016 22:04:46 +0100 Subject: [PATCH 086/120] fix --- geometry/@tensor/plot.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/geometry/@tensor/plot.m b/geometry/@tensor/plot.m index 8ede4f236..58d6b3aa8 100755 --- a/geometry/@tensor/plot.m +++ b/geometry/@tensor/plot.m @@ -126,6 +126,8 @@ function plot(T,varargin) error('Unknown plot type!') end +if isa(d,'function_handle'), d = d(1); end + if isa(d,'double') && ~isreal(d), d = real(d);end @@ -152,7 +154,7 @@ function plot(T,varargin) if isa(d,'vector3d') d.antipodal = true; quiver(S2,d,varargin{:},T.CS); - else + else plot(S2,d,'contourf',varargin{:},T.CS); end From 5b4b20adaf0cec9ecb488979f28bbd5f9df70a6a Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sun, 28 Feb 2016 22:05:47 +0100 Subject: [PATCH 087/120] fix --- geometry/@symmetry/ensureCS.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/geometry/@symmetry/ensureCS.m b/geometry/@symmetry/ensureCS.m index 8334c18aa..bfb03c2c0 100644 --- a/geometry/@symmetry/ensureCS.m +++ b/geometry/@symmetry/ensureCS.m @@ -7,8 +7,14 @@ if csOld.Laue == csNew.Laue, return;end % check for compatibility -axesOld = reshape(double(csOld.axes),3,3); -axesNew = reshape(double(csNew.axes),3,3); +try + axesOld = reshape(double(csOld.axes),3,3); + axesNew = reshape(double(csNew.axes),3,3); +catch + warning('MTEX:symmetry:missmatch',... + 'The symmetries %s and %s do not match!',char(csNew),char(csOld)); + return +end M = axesOld^(-1) * axesNew; % if compatible transform to new reference frame From 93bb1b840b61dbc4939e3bcc96c880dd1a2176e1 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sun, 28 Feb 2016 22:06:21 +0100 Subject: [PATCH 088/120] plot directions into grains, e.g., slip directions --- EBSDAnalysis/@grain2d/quiver.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 EBSDAnalysis/@grain2d/quiver.m diff --git a/EBSDAnalysis/@grain2d/quiver.m b/EBSDAnalysis/@grain2d/quiver.m new file mode 100644 index 000000000..e6d263bad --- /dev/null +++ b/EBSDAnalysis/@grain2d/quiver.m @@ -0,0 +1,21 @@ +function h = quiver(grains,dir,varargin) +% plot directions at grain boundaries +% +% Syntax +% quiver(gB,gB.direction,'linecolor','r') +% +% Example +% mtexdata fo +% grains = calcGrains(ebsd('indexed')) +% quiver(grains(1437).boundary,grains(1437).boundary.calcMeanDirection,'color','r') + + +varargin = [{'MaxHeadSize',0,'linewidth',2,'autoScaleFactor',0.25},varargin]; + +xy = grains.centroid; + +h = optiondraw(quiver(xy(:,1),xy(:,2),dir.x,dir.y),varargin{:}); + +if nargout == 0, clear h; end + +end From 42d9151596df71dabdf79e677e97ec11cd46aca4 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 1 Mar 2016 11:25:09 +0100 Subject: [PATCH 089/120] reactivate legend only if displayName is set --- EBSDAnalysis/@grain2d/plot.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EBSDAnalysis/@grain2d/plot.m b/EBSDAnalysis/@grain2d/plot.m index 89e198837..ea0da996c 100644 --- a/EBSDAnalysis/@grain2d/plot.m +++ b/EBSDAnalysis/@grain2d/plot.m @@ -54,7 +54,9 @@ h = plotFaces(grains.poly,grains.V,color,'parent', mP.ax,varargin{:}); % reactivate legend information - set(get(get(h(end),'Annotation'),'LegendInformation'),'IconDisplayStyle','on'); + if check_option(varargin,'displayName') + set(get(get(h(end),'Annotation'),'LegendInformation'),'IconDisplayStyle','on'); + end else % otherwise phase plot From 4463f65b84d0ce6075f1d644a6ac70ff0a67e0b9 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 1 Mar 2016 11:26:40 +0100 Subject: [PATCH 090/120] distinguish podal and antipodal --- EBSDAnalysis/@grain2d/quiver.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/EBSDAnalysis/@grain2d/quiver.m b/EBSDAnalysis/@grain2d/quiver.m index e6d263bad..381b6d757 100644 --- a/EBSDAnalysis/@grain2d/quiver.m +++ b/EBSDAnalysis/@grain2d/quiver.m @@ -9,10 +9,22 @@ % grains = calcGrains(ebsd('indexed')) % quiver(grains(1437).boundary,grains(1437).boundary.calcMeanDirection,'color','r') +xy = grains.centroid; + +if check_option(varargin,'antipodal') || dir.antipodal + + varargin = [{'MaxHeadSize',0,'linewidth',2,'autoScaleFactor',0.25},varargin]; + xy = [xy;xy]; + dir = [dir(:);-dir(:)]; + +else + + varargin = [{'MaxHeadSize',5,'linewidth',2,'autoScaleFactor',0.25},varargin]; + +end + -varargin = [{'MaxHeadSize',0,'linewidth',2,'autoScaleFactor',0.25},varargin]; -xy = grains.centroid; h = optiondraw(quiver(xy(:,1),xy(:,2),dir.x,dir.y),varargin{:}); From 9232a46f301edcb1d3fb91024b771db5cc971685 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 1 Mar 2016 11:27:05 +0100 Subject: [PATCH 091/120] add option 'noSymmetry' do Miller/dot_outer --- geometry/@Miller/dot_outer.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/geometry/@Miller/dot_outer.m b/geometry/@Miller/dot_outer.m index 0750eb2e9..db8362501 100644 --- a/geometry/@Miller/dot_outer.m +++ b/geometry/@Miller/dot_outer.m @@ -14,6 +14,11 @@ warning('Symmetry mismatch') end +if check_option(varargin,'noSymmetry') + d = dot_outer(vector3d(m1),vector3d(m2)); + return +end + % symmetrise m1 = symmetrise(m1,varargin{:}); s = [size(m1),length(m2)]; From 638fbb9707c914220513be371578fac7144fc2f4 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 1 Mar 2016 11:43:46 +0100 Subject: [PATCH 092/120] bug fix: show correct histogram for monophase materials --- EBSDAnalysis/@grain2d/hist.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EBSDAnalysis/@grain2d/hist.m b/EBSDAnalysis/@grain2d/hist.m index 6431c8487..d8592fd46 100644 --- a/EBSDAnalysis/@grain2d/hist.m +++ b/EBSDAnalysis/@grain2d/hist.m @@ -35,7 +35,8 @@ function hist(grains,varargin) % plot the result as a bar plot binCenter = 0.5*(bins(1:end-1)+bins(2:end)); -bar(binCenter,100*cumArea,'BarWidth',1.5,'parent',mtexFig.gca) +binWidth = 1 + 0.5*size(cumArea,2)>1; +bar(binCenter,100*cumArea,'BarWidth',binWidth,'parent',mtexFig.gca) xlim(mtexFig.gca,[bins(1),bins(end)]) xlabel(mtexFig.gca,'grain area') ylabel(mtexFig.gca,'relative volume (%)') From 409ac3b8c247c2501a3d5c38183e99ce439b8268 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 1 Mar 2016 17:09:35 +0100 Subject: [PATCH 093/120] bug fix for https://groups.google.com/forum/#!topic/mtexmail/hIlzkIt8P1o --- ODFAnalysis/@ODF/plotIPDF.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ODFAnalysis/@ODF/plotIPDF.m b/ODFAnalysis/@ODF/plotIPDF.m index 145f3b873..f5000c03b 100644 --- a/ODFAnalysis/@ODF/plotIPDF.m +++ b/ODFAnalysis/@ODF/plotIPDF.m @@ -35,7 +35,7 @@ function plotIPDF(odf,r,varargin) p = ensureNonNeg(odf.calcPDF(h,r(i),varargin{:})); % plot - h.smooth(p,'parent',mtexFig.gca,'doNotDraw',varargin{:}); + h.plot(p,'parent',mtexFig.gca,'doNotDraw','smooth',varargin{:}); mtexTitle(mtexFig.gca,char(r(i),'LaTeX')); end From 28775805d6c55c452e264b184450f2d1e3e936b0 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 1 Mar 2016 17:09:48 +0100 Subject: [PATCH 094/120] docu --- doc/BoundaryAnalysis/CSLBoundaries.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/BoundaryAnalysis/CSLBoundaries.m b/doc/BoundaryAnalysis/CSLBoundaries.m index 95c17a5a3..dde07f629 100644 --- a/doc/BoundaryAnalysis/CSLBoundaries.m +++ b/doc/BoundaryAnalysis/CSLBoundaries.m @@ -50,6 +50,20 @@ plot(gB3,'lineColor','g','linewidth',2,'DisplayName','CSL 3') hold off +%% Mark triple points +% Next we want to mark all triple points with at least 2 CSL boundaries + +% logical list of CSL boundaries +isCSL3 = grains.boundary.isTwinning(CSL(3,ebsd.CS),3*degree); + +% logical list of triple points with at least 2 CSL boundaries +tPid = sum(isCSL3(grains.triplePoints.boundaryId),2)>=2; + +% plot these triple points +hold on +plot(grains.triplePoints(tPid),'color','r') +hold off + %% Merging grains with common CSL(3) boundary % Next we merge all grains together which have a common CSL(3) boundary. % This is done with the command . From fbab6df271b3e2abc47668047547e0e3f3edd7da Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 1 Mar 2016 21:28:41 +0100 Subject: [PATCH 095/120] bug fix --- ODFAnalysis/@FourierComponent/calcTensor.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ODFAnalysis/@FourierComponent/calcTensor.m b/ODFAnalysis/@FourierComponent/calcTensor.m index b2ab45443..fea4c7066 100644 --- a/ODFAnalysis/@FourierComponent/calcTensor.m +++ b/ODFAnalysis/@FourierComponent/calcTensor.m @@ -12,7 +12,7 @@ TReuss.M = zeros([repmat(3,1,T.rank) 1 1]); TReuss.CS = specimenSymmetry; -for l = 0:T.rank +for l = 0:min(T.rank,component.bandwidth) % calc Fourier coefficient of odf odf_hat = Fourier(component,'order', l)./(2*l+1); From 47b30ff81048d3086e05469e1e8fe513ccfb6125 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 4 Mar 2016 14:45:24 +0100 Subject: [PATCH 096/120] some tensor fixes --- geometry/@tensor/ctranspose.m | 6 +++--- geometry/@tensor/matrix.m | 2 +- geometry/@tensor/size.m | 5 +++-- geometry/@tensor/symmetrise.m | 3 +++ geometry/@tensor/transpose.m | 10 +++++----- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/geometry/@tensor/ctranspose.m b/geometry/@tensor/ctranspose.m index 41cc5cb65..38d51655f 100644 --- a/geometry/@tensor/ctranspose.m +++ b/geometry/@tensor/ctranspose.m @@ -23,7 +23,7 @@ % check for symmetry % convert to a matrix - M = tensor42(T.M); + M = tensor42(T.M,T.doubleConvention); % invert the matrix M = ctranspose(M); @@ -33,7 +33,7 @@ w = w.' * w; M = M .* w; - % convert to back a 4 rank tensor - T.M = tensor24(M); + % convert back to a 4 rank tensor + T.M = tensor24(M,T.doubleConvention); end diff --git a/geometry/@tensor/matrix.m b/geometry/@tensor/matrix.m index dea9999ae..5d8ec5cb2 100755 --- a/geometry/@tensor/matrix.m +++ b/geometry/@tensor/matrix.m @@ -1,4 +1,4 @@ -function m= matrix(T,varargin) +function m = matrix(T,varargin) % return tensor as a matrix % % Syntax diff --git a/geometry/@tensor/size.m b/geometry/@tensor/size.m index b12fba6a5..0359cd36c 100644 --- a/geometry/@tensor/size.m +++ b/geometry/@tensor/size.m @@ -5,8 +5,9 @@ s = s(T.rank+1:end); if nargin == 1 - s = ones(1,2); - s(1:length(s)) = s; + if length(s) == 1 + s = [s,1]; + end elseif dim > numel(s) s = 1; else diff --git a/geometry/@tensor/symmetrise.m b/geometry/@tensor/symmetrise.m index 1e0695cff..535dcfde8 100755 --- a/geometry/@tensor/symmetrise.m +++ b/geometry/@tensor/symmetrise.m @@ -1,6 +1,9 @@ function T = symmetrise(T) % symmetrise a tensor according to its crystal symmetry +% for rank 0 and 1 tensors there is nothing to do +if T.rank <= 1, return; end + M_old = T.M; % make symmetric if neccasarry diff --git a/geometry/@tensor/transpose.m b/geometry/@tensor/transpose.m index 540ac1880..26ff5b4fd 100644 --- a/geometry/@tensor/transpose.m +++ b/geometry/@tensor/transpose.m @@ -14,7 +14,7 @@ case 2 - T.M = transpose(T.M); + T.M = permute(T.M,[2 1 3:ndims(T.M)]); case 3 @@ -23,17 +23,17 @@ % check for symmetry % convert to a matrix - M = tensor42(T.M); + M = tensor42(T.M,T.doubleConvention); % invert the matrix - M = transpose(M); + M = permute(M,[2 1 3:ndims(T.M)]); % make some corrections w = 1./(1+((1:6)>3)); w = w.' * w; M = M .* w; - % convert to back a 4 rank tensor - T.M = tensor24(M); + % convert back to a 4 rank tensor + T.M = tensor24(M,T.doubleConvention); end From bc6cccd481af02bfcff69256512f4d8053f078af Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 4 Mar 2016 14:46:05 +0100 Subject: [PATCH 097/120] tensor.diag to create diagonal tensors --- geometry/@tensor/tensor.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/geometry/@tensor/tensor.m b/geometry/@tensor/tensor.m index 914c26e7d..9ad2e5dbf 100755 --- a/geometry/@tensor/tensor.m +++ b/geometry/@tensor/tensor.m @@ -102,7 +102,7 @@ T = symmetrise(T); end end - + function [varargout] = calcTensor(obj,varargin) [varargout{1:nargout}] = obj.calcTensor(varargin{:}); end @@ -111,4 +111,13 @@ n = 0; end end + + methods (Static = true) + + function T = diag(d,varargin) + T = tensor(diag(d),varargin{:}); + end + + end + end From f6116638421e3281df840ebae1c833bb0937055c Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 4 Mar 2016 14:48:41 +0100 Subject: [PATCH 098/120] possible bug fix, talk to Christian about this --- EBSDAnalysis/@EBSDsquare/calcGND.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/EBSDAnalysis/@EBSDsquare/calcGND.m b/EBSDAnalysis/@EBSDsquare/calcGND.m index 555a0fa5a..976513fec 100644 --- a/EBSDAnalysis/@EBSDsquare/calcGND.m +++ b/EBSDAnalysis/@EBSDsquare/calcGND.m @@ -27,11 +27,18 @@ % compute the GND for i = 1:length(ebsd) - + + % the first two columns of the dislocation tensor are just + % the texture gradients kappa(1,:) = gX(i,:); kappa(2,:) = gY(i,:); - alpha = kappa - trace(kappa)*eye(3); + % as we do not know the texture gradient with respect to the z-direction + % we should add least guaranty that the trace of the tensor is zero, i.e., + % it is volume preserving + % TODO!!! + % alpha = kappa - trace(kappa)*eye(3); + kappa(3,3) = - kappa(1,1) - kappa(2,2); gnd(i) = norm(alpha,2); From 4b280c688cf2f191232c9f431f0ec7d0f805ff2b Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Fri, 4 Mar 2016 14:50:00 +0100 Subject: [PATCH 099/120] minor --- doc/html/helptoc.xml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/html/helptoc.xml b/doc/html/helptoc.xml index 97c65e110..9f8d104d3 100644 --- a/doc/html/helptoc.xml +++ b/doc/html/helptoc.xml @@ -97,6 +97,7 @@ repmat reshape rotate + rotate_outer scatter scatter3d size @@ -127,6 +128,7 @@ project2FundamentalRegion region rotate + rotate_outer round scatter smooth @@ -314,6 +316,7 @@ inv isMisorientation ldivide + log mean mldivide mtimes @@ -483,6 +486,7 @@ findByOrientation fliplr flipud + gridify inpolygon mtimes plot @@ -493,6 +497,7 @@ spatialProfile subSet subsasgn + subsind subsref Material Tensors (The Class @tensor)ChristoffelTensor @@ -533,6 +538,7 @@ rdivide real rotate + rotate_outer shearModulus size subsasgn @@ -811,7 +817,12 @@ Exploration of the relationship between estimation error and number of single orientations - GrainsGrain ReconstructionBasic grain reconstruction + GrainsFirst Steps and Function OverviewGrain reconstruction from EBSD data + Smoothing grain boundaries + Grain properties + Changing lists of grains + + Grain ReconstructionBasic grain reconstruction The grainId and how to select EBSD inside specific grains Misorientation to mean orientation Filling not indexed holes @@ -852,10 +863,11 @@ CSL BoundariesData import and grain detection Detecting CSL Boundaries - Merging grains with common CSL(3) boundary - Colorizing misorientations - Misorientations in the 3d fundamental zone - Analyzing the misorientation distribution function + Mark triple points + Merging grains with common CSL(3) boundary + Colorizing misorientations + Misorientations in the 3d fundamental zone + Analyzing the misorientation distribution function Triple pointsCalculation of triple points Index triple points by phase From 289cffc4f37392e603d3eb1de8f887c988076daf Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 5 Mar 2016 00:48:28 +0100 Subject: [PATCH 100/120] aligne b-Axis to the east --- geometry/@crystalSymmetry/crystalSymmetry.m | 7 ++--- geometry/@symmetry/fundamentalSector.m | 26 +++++++++++------- .../HSVOrientationMapping.m | 27 ++++++++++--------- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/geometry/@crystalSymmetry/crystalSymmetry.m b/geometry/@crystalSymmetry/crystalSymmetry.m index 5927b36a6..100d39edb 100644 --- a/geometry/@crystalSymmetry/crystalSymmetry.m +++ b/geometry/@crystalSymmetry/crystalSymmetry.m @@ -162,11 +162,8 @@ end function opt = get.plotOptions(cs) - % rotate the aAxis to the east - % but take only multiples of 90 degrees, - % since Matlab is not able to handle the values in between - %rho = -round(m.CS.aAxis.rho / 90 / degree)*90*degree; - rho = -cs.aAxis.rho; + % rotate the bAxis to the east + rho = -cs.bAxis.rho; opt = {'xAxisDirection',rho,'zAxisDirection','outOfPlane'}; end diff --git a/geometry/@symmetry/fundamentalSector.m b/geometry/@symmetry/fundamentalSector.m index d95d694e8..a55e518d6 100644 --- a/geometry/@symmetry/fundamentalSector.m +++ b/geometry/@symmetry/fundamentalSector.m @@ -43,13 +43,13 @@ end try - aAxis = cs.axes(1); + omega = cs.bAxis.rho; catch - aAxis = xvector; + omega = (1-NWSE(getMTEXpref('xAxisDirection')))*pi/2; end % rotate fundamental sector such that it start with the aAxis -N = rotate(N,aAxis.rho); +N = rotate(N,omega); % some special cases switch cs.id @@ -61,14 +61,20 @@ if isnull(dot(getMinAxes(cs),zvector)) N = zvector; end - case {4,7,10} % m11, 1m1, mm1 - N = getMinAxes(cs); + ind = angle(N,vector3d(cs.aAxis))< 45*degree; + case 4 + N = -getMinAxes(cs); + case {7,10} % m11, 1m1, mm1 + N = getMinAxes(cs); case 5 % 2/m11 + case 8 % 12/m1 N = rotate(N,-90*degree); - case {8,11} % 12/m1 112/m + case 11 case 12 % 222 case {13,14,15} % 2mm, m2m, mm2 N = cs.subSet(cs.isImproper).axis; % take mirror planes + ind = angle(N,vector3d(cs.aAxis))< 45*degree; + N(ind) = -N(ind); case 16 % mmm case 17 % 3 case 18 % -3 @@ -84,13 +90,13 @@ case 39 % 6m2 N = rotate(N,-30*degree); case 41 % 23 - N = vector3d([1 1 0 0],[1 -1 1 -1],[0 0 1 1]); + N = rotate(vector3d([1 1 0 0],[1 -1 1 -1],[0 0 1 1]),omega); case {42,43} % m-3, 432 - N = [vector3d(0,-1,1),vector3d(-1,0,1),xvector,yvector,zvector]; + N = rotate([vector3d(0,-1,1),vector3d(-1,0,1),xvector,yvector,zvector],omega); case 44 % -43m - N = [vector3d(1,-1,0),vector3d(1,1,0),vector3d(-1,0,1)]; + N = rotate([vector3d(1,-1,0),vector3d(1,1,0),vector3d(-1,0,1)],omega); case 45 % m-3m - N = [vector3d(1,-1,0),vector3d(-1,0,1),yvector]; + N = rotate([vector3d(1,-1,0),vector3d(-1,0,1),yvector],omega); end % this will be restricted later anyway diff --git a/tools/orientationMappings/HSVOrientationMapping.m b/tools/orientationMappings/HSVOrientationMapping.m index 6d21a38ff..c3d8876d7 100644 --- a/tools/orientationMappings/HSVOrientationMapping.m +++ b/tools/orientationMappings/HSVOrientationMapping.m @@ -59,9 +59,10 @@ function updatesR(oM) case {3,9} % 211, 112 oM.refl = -rotate(oM.sR.N,rotation('axis',cs.subSet(2).axis,'angle',90*degree)); case 6, % 121 - oM.refl = rotate(oM.sR.N,rotation('axis',cs.subSet(2).axis,'angle',90*degree)); - case {5}, oM.refl = rotate(oM.sR.N(2),90*degree); % 222 - case {8,11,12}, oM.refl = rotate(oM.sR.N(2),-90*degree); % 222 + oM.refl = rotate(oM.sR.N,rotation('axis',-cs.subSet(2).axis,'angle',90*degree)); + case {5}, oM.refl = rotate(oM.sR.N(2),-90*degree); % 2/m11 + case {8}, oM.refl = rotate(oM.sR.N(2),90*degree); % % 12/m1 + case {11,12}, oM.refl = rotate(oM.sR.N(2),-90*degree); % 222 case 17, oM.refl = -rotate(sum(oM.sR.N),90*degree); % 3 case 18, oM.refl = -rotate(sum(oM.sR.N(2:3)),90*degree); % -3 case 19 @@ -69,17 +70,17 @@ function updatesR(oM) if angle(oM.refl(1),oM.refl(2)) < 1*degree oM.refl = inv(r30) .* oM.sR.N(end-1:end); end - case 21, oM.refl = rotate(sum(oM.sR.N(2:3)),90*degree); % -31m, -3m1 - case 22, oM.refl = -rotate(sum(oM.sR.N(2:3)),90*degree); % 312 - case 24, oM.refl = -rotate(sum(oM.sR.N(2:3)),90*degree); % -31m, -3m1 + case 21, oM.refl = rotate(sum(oM.sR.N(2:3)),90*degree); % -31m, -3m1 + case 22, oM.refl = -rotate(sum(oM.sR.N(2:3)),90*degree); % 312 + case 24, oM.refl = -rotate(sum(oM.sR.N(2:3)),90*degree); % -31m, -3m1 case {25,27,28}, oM.refl = rotate(oM.sR.N(end),-45*degree); % 4,4/m,422 - case 26, oM.refl = rotate(oM.sR.N(end),-90*degree); % -4 - case 30, oM.refl = yvector; % -42m - case 31, oM.refl = -rotate(oM.sR.N(2),45*degree); % -4m2 + case 26, oM.refl = rotate(oM.sR.N(end),-90*degree); % -4 + case 30, oM.refl = rotate(oM.sR.N(2),45*degree); % -42m + case 31, oM.refl = -rotate(oM.sR.N(2),45*degree); % -4m2 case {33,35,36}, oM.refl = rotate(oM.sR.N(end),-30*degree); % 6,6/m, 622, - case 34, oM.refl = rotate(oM.sR.N(end),-60*degree); % -6 - case {41}, oM.refl = vector3d(-1,0,1); % 23, 432 - case {42,43}, oM.refl = vector3d(1,-1,0); % m-3 + case 34, oM.refl = rotate(oM.sR.N(end),-60*degree); % -6 + case {41}, oM.refl = sum(oM.sR.N(3:4))- sum(oM.sR.N(1:2)); % 23 + case {42,43}, oM.refl = oM.sR.N(end-2) - oM.sR.N(end-1); % 432, m-3 end % reduce fundamental sector by reflectors for black-white colorcoding @@ -113,7 +114,7 @@ function updatesR(oM) % compute angle of the points "sh" relative to the center point "center" % this should be between 0 and 1 - ref = -vector3d(oM.CS1.bAxisRec); + ref = vector3d(oM.CS1.aAxisRec); [radius,rho] = polarCoordinates(oM.sR,h_sR,wC,ref,'maxAngle',oM.maxAngle); if oM.maxAngle < inf From 1a61852ac840487b7883b890e182431dbdb02751 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 5 Mar 2016 00:50:06 +0100 Subject: [PATCH 101/120] fix mtex-toolbox/mtex#159 project2Fundamental region should return Miller implement Miller.rand, Miller.nan --- geometry/@Miller/Miller.m | 29 +++++++++++++++++++- geometry/@Miller/project2FundamentalRegion.m | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/geometry/@Miller/Miller.m b/geometry/@Miller/Miller.m index 52e22001a..82c70e253 100644 --- a/geometry/@Miller/Miller.m +++ b/geometry/@Miller/Miller.m @@ -358,7 +358,34 @@ end end + methods (Static = true) + + function v = nan(varargin) + s = varargin(cellfun(@isnumeric,varargin)); + v = vector3d.nan(s{:}); + h = Miller(v,varargin{:}); + end + + function v = ones(varargin) + s = varargin(cellfun(@isnumeric,varargin)); + v = vector3d.ones(s{:}); + h = Miller(v,varargin{:}); + end + + function v = zeros(varargin) + s = varargin(cellfun(@isnumeric,varargin)); + v = vector3d.zeros(s{:}); + h = Miller(v,varargin{:}); + end + + function h = rand(varargin ) + % vector of random vector3d - + s = varargin(cellfun(@isnumeric,varargin)); + v = vector3d.rand(s{:}); + h = Miller(v,varargin{:}); + + end + end end diff --git a/geometry/@Miller/project2FundamentalRegion.m b/geometry/@Miller/project2FundamentalRegion.m index c45d55c8c..c1174282b 100644 --- a/geometry/@Miller/project2FundamentalRegion.m +++ b/geometry/@Miller/project2FundamentalRegion.m @@ -10,4 +10,4 @@ % Output % h - @Miller -h = project2FundamentalRegion@vector3d(h,h.CS,varargin{:}); +h = Miller(project2FundamentalRegion@vector3d(h,h.CS,varargin{:}),h.CS); From 3ebe910ceaf936028ab6a070ab4009bfb64d7da8 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Sat, 5 Mar 2016 00:52:11 +0100 Subject: [PATCH 102/120] prepare for MTEX 4.3.0 --- Makefile | 2 +- VERSION | 2 +- doc/ReleaseNotes/changelog.m | 62 ++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 72cd60c9e..da331fc0e 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ clean: # rule for making release -RNAME = mtex-4.3.beta2 +RNAME = mtex-4.3.0 RDIR = ../releases release: rm -rf $(RDIR)/$(RNAME)* diff --git a/VERSION b/VERSION index 5c75d7f6d..93876f232 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -MTEX 4.3.beta2 +MTEX 4.3.0 diff --git a/doc/ReleaseNotes/changelog.m b/doc/ReleaseNotes/changelog.m index d35fcae7a..f8650ac39 100644 --- a/doc/ReleaseNotes/changelog.m +++ b/doc/ReleaseNotes/changelog.m @@ -1,6 +1,68 @@ %% MTEX Changelog % % +%% MTEX 4.3 - 03/2016 +% +% *Alignment of Miller plots* +% +% Starting with MTEX 4.3 plot with respect to the crystal coordinate system +% are always aligned such that the b-axis points towards east. This follows +% the convention given in the International Table of Crystallography. This +% change effects: inverse pole figure plots, ipf keys, misorientation axes +% plots. The alignment can be adjusted using the option |xAxisAlignment| +% +% plot(Miller(1,0,0,cs),'xAxisAlignment',30*degree) +% +% *Vector field plot at grain centers or grain boundaries* +% +% There are three new commands +% +% quiver(ebsd,dir) +% quiver(grains,dir) +% quiver(grains.boundary,dir) +% +% that allow to visualize directions for EBSD data, grains and at grain +% boundaries. |dir| should be a list of |vector3d| and may represent e.g. +% slip directions, polarization direction, etc. +% +% *EBSD as data as image* +% +% Until MTEX 4.2 EBSD data have been always considered as a one dimensional +% list of data, i.e., the often present structure of the data in a regular +% grid was completely ignored. Starting with MTEX 4.3 EBSD data can be +% converted in a regular grid by +% +% ebsd = ebsd.gridify +% +% Missing data are represented as NaN in the regular representation. +% Gridified EBSD data may be addressed analogously like matrixes, i.e., +% +% ebsd(100,200) +% +% will give pixel 100 in y direction and 200 in x direction. Analogously. +% +% ebsd(50:100,:) +% +% will give the stripe if pixels with y coordinate between 50 and 100. +% +% *Orientation gradients and GND* +% +% Gridified EBSD data allows also to compture orientation gradients by +% +% ebsd.gradientX +% ebsd.gradientY +% +% as well as an estimate of the gemeometrically neccessary dislocation +% density (GND) by +% +% ebsd.calcGND +% +% *Auxilary new function* +% +% * grain2d.calcParis - Percentile Average Relative Indented Surface +% * tensor.diag +% * +% %% MTEX 4.2 - 11/2015 % % MTEX 4.2 introduces basic functionality for triple junction analysis in From 8fa6a880848480937ace6166fe133506ce9a01de Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 11:47:33 +0100 Subject: [PATCH 103/120] calcMDF also takes orientations fixes mtex-toolbox/mtex#158 --- geometry/@orientation/calcMDF.m | 47 ++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/geometry/@orientation/calcMDF.m b/geometry/@orientation/calcMDF.m index 6fbc734f5..6dc6aa13e 100644 --- a/geometry/@orientation/calcMDF.m +++ b/geometry/@orientation/calcMDF.m @@ -1,5 +1,5 @@ -function mdf = calcMDF(ori,varargin) -% computes an MDF from individuel orientations +function mdf = calcMDF(mori,varargin) +% computes an MDF from individuel orientations or misorientations % % The function *calcMDF* applies one of the following algorithms to compute % an MDF from a list of orientations. @@ -11,20 +11,25 @@ % Syntax % % % use kernel density estimation with a 10 degree kernel -% mdf = calcMDF(ori,'halfwidth',10*degree) +% mori = grains.boundary.misorientation +% mdf = calcMDF(mori,'halfwidth',10*degree) +% +% % compute an uncorrelated MDF +% mdf = calcMDF(grains('phase1').meanorientation) % % % use grain area as weights for the orientations -% mdf = calcMDF(grains.meanOrientation,'weights',grains.area) +% mdf = calcMDF(grains('phase1').meanOrientation,'weights',grains('phase1').diameter) % % % use a specific kernel % psi = AbelPoissonKernel('halfwidth',10*degree) -% mdf = calcMDF(ori,'kernel',psi) +% mdf = calcMDF(mori,'kernel',psi) % % % compute the MDF as a Fourier series of order 16 -% mdf = calcMDF(ori,'order',16) +% mdf = calcMDF(mori,'order',16) % % Input % ori - @orientation +% mori - misorientation % % Output % mdf - @ODF @@ -46,8 +51,32 @@ % See also % orientation/calcFourierMDF orientation/calcKernelMDF orientation/calcBinghamMDF ebsd_demo EBSD2mdf EBSDSimulation_demo -if check_option(varargin,'antipoal') - ori = [ori(:);inv(ori(:))]; +% if orientations have been specified +if isa(mori.SS,'specimenSymmetry') + + % compute an ODF first + odf1 = calcFourierODF(mori,varargin{:}); + + if nargin > 1 && isa(varargin{1},'orientation') + + % maybe a second ODF is needed + odf2 = calcFourierODF(varargin{1},varargin{:}); + + % compute the MDF + mdf = calcMDF(odf1,odf2); + + else + + % compute the MDF + mdf = calcMDF(odf1); + + end + + return +end + +if check_option(varargin,'antipoal') && mori.CS == mori.SS + mori = [mori(:);inv(mori(:))]; end -mdf = calcODF(ori,'halfwidth',7.5*degree,varargin{:}); \ No newline at end of file +mdf = calcODF(mori,'halfwidth',7.5*degree,varargin{:}); \ No newline at end of file From f3023cd6af7e8d5f1ba5d0229dfdebf03b4e25de Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 12:35:15 +0100 Subject: [PATCH 104/120] docu --- EBSDAnalysis/@EBSD/calcMisorientation.m | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/EBSDAnalysis/@EBSD/calcMisorientation.m b/EBSDAnalysis/@EBSD/calcMisorientation.m index c63b59a00..e7f5be039 100644 --- a/EBSDAnalysis/@EBSD/calcMisorientation.m +++ b/EBSDAnalysis/@EBSD/calcMisorientation.m @@ -1,15 +1,24 @@ function [mori,ori2] = calcMisorientation(ebsd1,varargin) -% calculate uncorelated misorientations between two ebsd phases +% calculate uncorrelated misorientations between two ebsd phases % % Syntax -% mori = calcMisorientation(ebsd,'sampleSize',1000) -% mori = calcMisorientation(ebsd,'minDistance',100) -% mori = calcMisorientation(ebsd1,ebsd2) -% [ori1,ori2] = calcMisorientation(ebsd1) -% plot(axis(ori1,ori2)) +% +% % 1000 uncorrelated misorientations of phase1 +% mori = calcMisorientation(ebsd('phase1'),'sampleSize',1000) +% +% % uncorrelated misorientations with minimum distance 100 +% mori = calcMisorientation(ebsd('phase1'),'minDistance',100) +% +% % uncorrelated misorientations between phase1 and phase2 +% mori = calcMisorientation(ebsd('phase1'),ebsd('phase2')) +% +% % compute pairs of orientations to be used to compute axis +% % distributions in specimen coordinates +% [ori1,ori2] = calcMisorientation(ebsd('phase1')) +% plot(axis(ori1,ori2),'contourf') % % Input -% ebsd, ebsd1, ebsd2 - @EBSD +% ebsd - @EBSD % % Output % m - @orientation, such that From 87177ae48134e410833603d61e0d50c657a69b56 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 12:35:57 +0100 Subject: [PATCH 105/120] do not annotate specimen plots --- plotting/sphericalPlot.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index 049a4fc7f..a129be031 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -292,7 +292,7 @@ function circ(sP,theta,varargin) function plotLabels(sP,CS,varargin) - if check_option(varargin,'noLabel'), return; end + if check_option(varargin,'noLabel') || isempty(CS), return; end sR = sP.sphericalRegion; h = sR.vertices; From 9ef5c6ea6f0e6bca346aa07609a7791c6e9965d5 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 12:37:42 +0100 Subject: [PATCH 106/120] revert bad change --- EBSDAnalysis/@EBSDsquare/calcGND.m | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/EBSDAnalysis/@EBSDsquare/calcGND.m b/EBSDAnalysis/@EBSDsquare/calcGND.m index 976513fec..eeb9d4e16 100644 --- a/EBSDAnalysis/@EBSDsquare/calcGND.m +++ b/EBSDAnalysis/@EBSDsquare/calcGND.m @@ -34,12 +34,9 @@ kappa(2,:) = gY(i,:); % as we do not know the texture gradient with respect to the z-direction - % we should add least guaranty that the trace of the tensor is zero, i.e., - % it is volume preserving - % TODO!!! - % alpha = kappa - trace(kappa)*eye(3); - kappa(3,3) = - kappa(1,1) - kappa(2,2); - + % we have to do something here TODO!! + alpha = kappa - trace(kappa)*eye(3); + gnd(i) = norm(alpha,2); end From 5a0a10c40cf08212672bf12529fa88b46243915b Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 12:38:27 +0100 Subject: [PATCH 107/120] when interpolating set uncovered regions to nan --- geometry/@vector3d/interp.m | 8 ++++++++ geometry/@vector3d/smooth.m | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/geometry/@vector3d/interp.m b/geometry/@vector3d/interp.m index 719a09a41..74f57ef93 100644 --- a/geometry/@vector3d/interp.m +++ b/geometry/@vector3d/interp.m @@ -25,6 +25,14 @@ M = psi.RK(cos(so(:,1:4))); end + % set point to nan which are to far away + if check_option(varargin,'cutOutside') + minO = min(omega,[],2); + delta = 4*quantile(minO,0.5); + M(so(:,1:4)>delta) = NaN; + end + + M = repmat(1./sum(M,2),1,size(M,2)) .* M; M = sparse(i,j(:,1:4),M,size(omega,1),size(omega,2)); diff --git a/geometry/@vector3d/smooth.m b/geometry/@vector3d/smooth.m index 1e463cd64..40de30b80 100644 --- a/geometry/@vector3d/smooth.m +++ b/geometry/@vector3d/smooth.m @@ -45,7 +45,7 @@ if size(S2G,1) == 1 || size(S2G,2) == 1 S2G = plotS2Grid(sP(j).sphericalRegion,'resolution',2.5*degree,varargin{:}); - cdata = interp(v,cdata,S2G); + cdata = interp(v,cdata,S2G,'cutOutside'); elseif ~isa(sP(j).proj,'plainProjection') From 5450db46eab6e1e283298d0208abff0de0910390 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 12:39:52 +0100 Subject: [PATCH 108/120] a bit more tolerance for sphericalRegion/checkInside --- geometry/@sphericalRegion/checkInside.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry/@sphericalRegion/checkInside.m b/geometry/@sphericalRegion/checkInside.m index 0ca305a3b..c74e2d35a 100644 --- a/geometry/@sphericalRegion/checkInside.m +++ b/geometry/@sphericalRegion/checkInside.m @@ -13,7 +13,7 @@ inside = true(size(v)); v = normalize(vector3d(v)); for i = 1:length(sR.N) - inside = inside & (dot(subSet(sR.N,i),v) >= sR.alpha(i)-1e-6); + inside = inside & (dot(subSet(sR.N,i),v) >= sR.alpha(i)-1e-4); end end From 0e241d497c69709d21bade73b660ba8e4494f538 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 14:45:54 +0100 Subject: [PATCH 109/120] reduce now works also for hex grids --- EBSDAnalysis/@EBSD/reduce.m | 43 +++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/EBSDAnalysis/@EBSD/reduce.m b/EBSDAnalysis/@EBSD/reduce.m index 6397b7f25..321f3f0d0 100644 --- a/EBSDAnalysis/@EBSD/reduce.m +++ b/EBSDAnalysis/@EBSD/reduce.m @@ -1,9 +1,8 @@ function ebsd = reduce(ebsd,fak) % reduce ebsd data by a factor % -% % Syntax -% ebsd = reduce(ebsd,2) % take every second pixel horiz. and vert. +% ebsd = reduce(ebsd) % take every second pixel horiz. and vert. % ebsd = reduce(ebsd,3) % take every third pixel horiz. and vert. % % Input @@ -13,16 +12,38 @@ % ebsd - @EBSD % -% generate regular grid -ext = ebsd.extend; -dx = max(ebsd.unitCell(:,1))-min(ebsd.unitCell(:,1)); -dy = max(ebsd.unitCell(:,2))-min(ebsd.unitCell(:,2)); +if nargin == 1, fak = 2; end + +if length(ebsd.unitCell) == 4 + + % generate regular grid + ext = ebsd.extend; + dx = max(ebsd.unitCell(:,1))-min(ebsd.unitCell(:,1)); + dy = max(ebsd.unitCell(:,2))-min(ebsd.unitCell(:,2)); + + % detect position within grid + iy = round((ebsd.prop.y - ext(3))/dy); + ix = round((ebsd.prop.x - ext(1))/dx); -% detect position within grid -iy = round((ebsd.prop.y - ext(3))/dy); -ix = round((ebsd.prop.x - ext(1))/dx); + ebsd = ebsd.subSet(~mod(ix,fak) & ~mod(iy,fak)); + ebsd.unitCell = fak*ebsd.unitCell; + +elseif length(ebsd.unitCell) == 6 % hexgrid + + + % generate regular grid + ext = ebsd.extend; + dx = max(ebsd.unitCell(:,1))-min(ebsd.unitCell(:,1)); + dy = max(ebsd.unitCell(:,2))-min(ebsd.unitCell(:,2)); + + % detect position within grid + iy = round((ebsd.prop.y - ext(3))/dy*4/3); + ix = round((ebsd.prop.x - ext(1))/dx*2); -ebsd = ebsd.subSet(~mod(ix,fak) & ~mod(iy,fak)); -ebsd.unitCell = fak*ebsd.unitCell; + ebsd = ebsd.subSet(~mod(iy,fak) & ~mod(ix+iy,2*fak)); + + ebsd.unitCell = fak*ebsd.unitCell; + +end end \ No newline at end of file From cbecf971d88d0157d6978aa516bf89273e88aeba Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 15:47:03 +0100 Subject: [PATCH 110/120] fixes mtex-toolbox/mtex#152 --- ODFAnalysis/@FourierComponent/calcMDF.m | 3 +-- ODFAnalysis/@ODF/calcAngleDistribution.m | 2 +- ODFAnalysis/@ODF/calcFourier.m | 2 +- ODFAnalysis/@ODF/calcMDF.m | 12 +++--------- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/ODFAnalysis/@FourierComponent/calcMDF.m b/ODFAnalysis/@FourierComponent/calcMDF.m index 1167de7fe..200823a02 100644 --- a/ODFAnalysis/@FourierComponent/calcMDF.m +++ b/ODFAnalysis/@FourierComponent/calcMDF.m @@ -2,8 +2,7 @@ % calculate the uncorrelated misorientation distribution function (MDF) from one or two ODF % get bandwidth -L = get_option(varargin,'bandwidth',32); -L = min([odf1.bandwidth,odf2.bandwidth,L]); +L = min([odf1.bandwidth,odf2.bandwidth]); % compute Fourier coefficients of mdf f_hat = [odf1.f_hat(1) * odf2.f_hat(1); zeros(deg2dim(L+1)-1,1)]; diff --git a/ODFAnalysis/@ODF/calcAngleDistribution.m b/ODFAnalysis/@ODF/calcAngleDistribution.m index 73747bec0..8fa65abd8 100644 --- a/ODFAnalysis/@ODF/calcAngleDistribution.m +++ b/ODFAnalysis/@ODF/calcAngleDistribution.m @@ -66,7 +66,7 @@ end % evaluate the ODF at the grid - f = eval(odf,S3G); %#ok + f = max(0,eval(odf,S3G)); %#ok % integrate for k = 1:numel(omega) diff --git a/ODFAnalysis/@ODF/calcFourier.m b/ODFAnalysis/@ODF/calcFourier.m index c8bf2622f..cc3aed72e 100644 --- a/ODFAnalysis/@ODF/calcFourier.m +++ b/ODFAnalysis/@ODF/calcFourier.m @@ -22,7 +22,7 @@ if nargin > 1 && isnumeric(varargin{1}) L = max(varargin{1},4); else - L = get_option(varargin,'bandwidth',32); + L = get_option(varargin,'bandwidth',min(odf.bandwidth,64)); end f_hat = zeros(deg2dim(L+1),1); diff --git a/ODFAnalysis/@ODF/calcMDF.m b/ODFAnalysis/@ODF/calcMDF.m index 77be2e6ff..366583a0f 100644 --- a/ODFAnalysis/@ODF/calcMDF.m +++ b/ODFAnalysis/@ODF/calcMDF.m @@ -27,18 +27,12 @@ else % Fourier method - % determine bandwidth - L = get_option(varargin,'bandwidth',32); - % convert to FourierODF - odf1 = FourierODF(odf1,L); - - % extract Fourier coefficients - L = min(odf1.components{1}.bandwidth,L); - + odf1 = FourierODF(odf1,varargin{:}); + % is second argument also an ODF? if nargin > 1 && isa(varargin{1},'ODF') - odf2 = FourierODF(varargin{1},L); + odf2 = FourierODF(varargin{1},odf1.components{1}.bandwidth); else odf2 = odf1; end From 30fd8e4f96cfb7d82308fd25e0e48ce9573b2b29 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 21:45:32 +0100 Subject: [PATCH 111/120] fixed mtex-toolbox/mtex#160 --- geometry/@Miller/Miller.m | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/geometry/@Miller/Miller.m b/geometry/@Miller/Miller.m index 82c70e253..925bb0021 100644 --- a/geometry/@Miller/Miller.m +++ b/geometry/@Miller/Miller.m @@ -360,24 +360,12 @@ methods (Static = true) - function v = nan(varargin) + function h = nan(varargin) s = varargin(cellfun(@isnumeric,varargin)); v = vector3d.nan(s{:}); h = Miller(v,varargin{:}); end - function v = ones(varargin) - s = varargin(cellfun(@isnumeric,varargin)); - v = vector3d.ones(s{:}); - h = Miller(v,varargin{:}); - end - - function v = zeros(varargin) - s = varargin(cellfun(@isnumeric,varargin)); - v = vector3d.zeros(s{:}); - h = Miller(v,varargin{:}); - end - function h = rand(varargin ) % vector of random vector3d From 9f6bb21e22d088cb354e83c3771957959b0ebaee Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Mon, 7 Mar 2016 22:01:04 +0100 Subject: [PATCH 112/120] fix mtex-toolbox/mtex#132 --- plotting/sphericalPlot.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plotting/sphericalPlot.m b/plotting/sphericalPlot.m index a129be031..d07be2ce5 100644 --- a/plotting/sphericalPlot.m +++ b/plotting/sphericalPlot.m @@ -15,8 +15,8 @@ TR % BL % BR % - minData = 0 - maxData = 0 + minData = NaN + maxData = NaN dispMinMax = false end From a55d3b6ebd85e47a31045450f2a5f77b46035462 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 8 Mar 2016 09:18:28 +0100 Subject: [PATCH 113/120] bug fix, make smooth work with hex data --- EBSDAnalysis/@EBSDsquare/EBSDsquare.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EBSDAnalysis/@EBSDsquare/EBSDsquare.m b/EBSDAnalysis/@EBSDsquare/EBSDsquare.m index 4579b7e35..7655fca2b 100644 --- a/EBSDAnalysis/@EBSDsquare/EBSDsquare.m +++ b/EBSDAnalysis/@EBSDsquare/EBSDsquare.m @@ -43,7 +43,7 @@ if check_option(varargin,'uniCell') ebsd.unitCell = get_option(varargin,'unitCell',[]); else - ebsd.unitCell = 0.5 * [dxy(1) * [1;1;-1;-1],dxy(1) * [1;-1;-1;1]]; + ebsd.unitCell = 0.5 * [dxy(1) * [1;1;-1;-1],dxy(2) * [1;-1;-1;1]]; end end From 86ad243f01d839d16dadc1871c9caab600b6551a Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 8 Mar 2016 10:17:32 +0100 Subject: [PATCH 114/120] reshape KAM to fit gridified EBSD size --- EBSDAnalysis/@EBSD/KAM.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EBSDAnalysis/@EBSD/KAM.m b/EBSDAnalysis/@EBSD/KAM.m index c4f1d74c7..2e088c27c 100644 --- a/EBSDAnalysis/@EBSD/KAM.m +++ b/EBSDAnalysis/@EBSD/KAM.m @@ -74,4 +74,4 @@ % compute kernel average misorientation kam = sparse(Dl(ind),Dr(ind),omega(ind)+0.00001,length(ebsd),length(ebsd)); kam = kam+kam'; -kam = full(sum(kam,2)./sum(kam>0,2)); +kam = reshape(full(sum(kam,2)./sum(kam>0,2)),size(ebsd)); From 3f87c108c2d9c01e1429664ea22d36ea74c169e0 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 8 Mar 2016 10:17:54 +0100 Subject: [PATCH 115/120] allways try to switch to painters for pdf output --- plotting/saveFigure.m | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plotting/saveFigure.m b/plotting/saveFigure.m index 4e01bf0b5..b91b341ec 100644 --- a/plotting/saveFigure.m +++ b/plotting/saveFigure.m @@ -36,11 +36,10 @@ function saveFigure(fname,varargin) %end % try to switch to painters mode for vector formats - % by converting RGB graphics to indexed graphics - if ~strcmpi(get(gcf,'renderer'),'painters') && isRGB - - try - convertFigureRGB2ind; + if ~strcmpi(get(gcf,'renderer'),'painters') + try + % converting RGB graphics to indexed graphics + if isRGB, convertFigureRGB2ind; end set(gcf,'renderer','painters'); catch warning('MTEX:export','Unable to switch to painter''s mode. You may need to export to png or jpg'); From 67ed1ded13c09aaa39ca04ea2c59c8963005550d Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 8 Mar 2016 10:20:40 +0100 Subject: [PATCH 116/120] new syntax axis(mori,CS) return misorientation axis with respect to phase specified by CS --- geometry/@orientation/axis.m | 29 ++++++++++++++++++++++------- geometry/plotAxisDistribution.m | 21 ++++++++++----------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/geometry/@orientation/axis.m b/geometry/@orientation/axis.m index 50317bbc5..7bd37780a 100644 --- a/geometry/@orientation/axis.m +++ b/geometry/@orientation/axis.m @@ -15,10 +15,10 @@ % a = axis(o1,o2) % % % the misorientation axis with respect to csCube is computed by -% a = axis(inv(o2)*o1) +% a = axis(inv(o1)*o2,csCube) % % % the misorientation axis with respect to csHex is computed by -% a = axis(inv(o1)*o2) +% a = axis(inv(o1)*o2,csHex) % % % compute the misorientation axis ignoring symmetry % a = axis(inv(o1)*o2,'noSymmetry') @@ -33,8 +33,9 @@ % See also % orientation/angle - -if nargin >= 2 && isa(varargin{1},'quaternion') +% axis(ori1,ori2) should return the misorientation axis in specimen +% coordinates +if nargin >= 2 && isa(varargin{1},'orientation') o2 = varargin{1}; @@ -70,6 +71,7 @@ % given by o2 * l(il) * q.axis or equivalently by a = q2 .* r(irMax) .* axis@quaternion(q); + else % project to Fundamental region to get the axis with the smallest angle @@ -78,8 +80,21 @@ end a = axis@quaternion(o1); - - % add symmetry to axis - if isa(o1.SS,'crystalSymmetry'), a = Miller(a,o1.SS); end + + % crystal symmetry specified -> apply it + if nargin >= 2 && isa(varargin{1},'crystalSymmetry') + + cs = varargin{1}; + + else % no symmetry specified - take the disjoint + + cs = disjoint(o1.CS,o1.SS); + + end + + if o1.antipodal, cs = cs.Laue; end + + % add symmetry to axis + if isa(cs,'crystalSymmetry'), a = Miller(a,cs); end end diff --git a/geometry/plotAxisDistribution.m b/geometry/plotAxisDistribution.m index aeb7ebe67..fedd2d19d 100644 --- a/geometry/plotAxisDistribution.m +++ b/geometry/plotAxisDistribution.m @@ -6,6 +6,7 @@ % plotAxisDistribution(cs) % random axis distribution % plotAxisDistribution(cs1,cs2) % random misorientation axis distribution % plotAxisDistribution(mori) % axes in crystal coordinates +% plotAxisDistribution(mori,cs1) % axes in crystal coordinates % plotAxisDistribution(ori1,ori2) % axes in specimen coordinates % plotAxisDistribution(odf) % @@ -37,13 +38,8 @@ end elseif isa(obj,'orientation') - if nargin > 1 && isa(varargin{1},'orientation') - % pairs of orientations given - axes in specimen coordinates - obj = axis(obj,varargin{1}); - else - % misorientation given axis in crystal reference frame - obj = Miller(obj.axis,calcDisjoint(obj.CS,obj.SS,varargin{:})); - end + obj = axis(obj,varargin{:}); + else cs1 = obj.CS; cs2 = obj.SS; @@ -52,12 +48,16 @@ if isa(obj,'vector3d') - h = plot(obj,'symmetrised','FundamentalRegion',varargin{:}); + h = plot(obj,'symmetrised','FundamentalRegion',varargin{:}); else - dcs = calcDisjoint(cs1,cs2,varargin{:}); - + if isa(obj,'orientation') && isa(varargin{1},'crystalSymmetry') + dcs = varargin{1}; + else + dcs = calcDisjoint(cs1,cs2,varargin{:}); + end + % plotting grid sR = fundamentalSector(dcs,varargin{:}); if isa(obj,'symmetry') @@ -90,7 +90,6 @@ end end - end function d = pos(d) From 096fe0027a65e7dcaf32643cb55e4350bf66a661 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 8 Mar 2016 10:20:51 +0100 Subject: [PATCH 117/120] updated changelog --- doc/ReleaseNotes/changelog.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/ReleaseNotes/changelog.m b/doc/ReleaseNotes/changelog.m index f8650ac39..74aee54ca 100644 --- a/doc/ReleaseNotes/changelog.m +++ b/doc/ReleaseNotes/changelog.m @@ -57,11 +57,11 @@ % % ebsd.calcGND % -% *Auxilary new function* +% *Auxilary new functionality* % % * grain2d.calcParis - Percentile Average Relative Indented Surface -% * tensor.diag -% * +% * tensor.diag +% * works now also for EBSD data on Hex grids % %% MTEX 4.2 - 11/2015 % From 1b7f7b005863b9ba619c56420953985d92139651 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 8 Mar 2016 15:17:03 +0100 Subject: [PATCH 118/120] docu --- EBSDAnalysis/@grain2d/quiver.m | 19 +++++++----- doc/EBSDAnalysis/EBSDSharpPlot.m | 4 +-- doc/ReleaseNotes/changelog.m | 33 +++++++++++---------- doc/html/helptoc.xml | 51 ++++++++++++++++---------------- 4 files changed, 56 insertions(+), 51 deletions(-) diff --git a/EBSDAnalysis/@grain2d/quiver.m b/EBSDAnalysis/@grain2d/quiver.m index 381b6d757..c64475602 100644 --- a/EBSDAnalysis/@grain2d/quiver.m +++ b/EBSDAnalysis/@grain2d/quiver.m @@ -1,13 +1,21 @@ function h = quiver(grains,dir,varargin) -% plot directions at grain boundaries +% plot directions at grain centers % % Syntax -% quiver(gB,gB.direction,'linecolor','r') +% quiver(grains,dir,'linecolor','r') % -% Example % mtexdata fo % grains = calcGrains(ebsd('indexed')) -% quiver(grains(1437).boundary,grains(1437).boundary.calcMeanDirection,'color','r') +% quiver(grains,grains.meanRotation.axis,'color','r') +% +% Input +% grains - @grain2d +% dir - @vector3d +% +% Options +% antipodal - +% maxHeadSize +% xy = grains.centroid; @@ -23,9 +31,6 @@ end - - - h = optiondraw(quiver(xy(:,1),xy(:,2),dir.x,dir.y),varargin{:}); if nargout == 0, clear h; end diff --git a/doc/EBSDAnalysis/EBSDSharpPlot.m b/doc/EBSDAnalysis/EBSDSharpPlot.m index 6736b98f7..6ab7ba517 100644 --- a/doc/EBSDAnalysis/EBSDSharpPlot.m +++ b/doc/EBSDAnalysis/EBSDSharpPlot.m @@ -40,7 +40,7 @@ % increase the contrast for the main group we restrict the colorrange from % 20 degree to 29 degree. -caxis([20 30]); +caxis([90 100]); % by the following lines we colorcode the outliers in purple. cmap = colormap; @@ -55,7 +55,7 @@ plot(ebsd,color) % set scaling of the angles to 20 - 29 degree -caxis([20 30]); +caxis([90 100]); % colorize outliers in purple. cmap = colormap; diff --git a/doc/ReleaseNotes/changelog.m b/doc/ReleaseNotes/changelog.m index 74aee54ca..84ba399bc 100644 --- a/doc/ReleaseNotes/changelog.m +++ b/doc/ReleaseNotes/changelog.m @@ -5,32 +5,33 @@ % % *Alignment of Miller plots* % -% Starting with MTEX 4.3 plot with respect to the crystal coordinate system -% are always aligned such that the b-axis points towards east. This follows -% the convention given in the International Table of Crystallography. This -% change effects: inverse pole figure plots, ipf keys, misorientation axes -% plots. The alignment can be adjusted using the option |xAxisAlignment| +% Starting with MTEX 4.3 plots with respect to the crystal coordinate +% system, i.e., inverse pole figure plots, misorientation axis plot, ipf +% keys, are always aligned such that the b-axis points towards east. This +% follows the convention given in the International Table of +% Crystallography. The alignment can be adjusted using the +% option |xAxisAlignment| % % plot(Miller(1,0,0,cs),'xAxisAlignment',30*degree) % -% *Vector field plot at grain centers or grain boundaries* +% *Plotting vector fields at grain centers or grain boundaries* % % There are three new commands % -% quiver(ebsd,dir) -% quiver(grains,dir) -% quiver(grains.boundary,dir) +% * +% * +% * % % that allow to visualize directions for EBSD data, grains and at grain -% boundaries. |dir| should be a list of |vector3d| and may represent e.g. -% slip directions, polarization direction, etc. +% boundaries. The input argument |dir| should be a list of |vector3d| and +% may represent e.g. slip directions, polarization direction, etc. % -% *EBSD as data as image* +% *EBSD data in raster format* % % Until MTEX 4.2 EBSD data have been always considered as a one dimensional -% list of data, i.e., the often present structure of the data in a regular -% grid was completely ignored. Starting with MTEX 4.3 EBSD data can be -% converted in a regular grid by +% list of data, i.e., the often present structure of a regular grid was +% completely ignored. Starting with MTEX 4.3 EBSD data can be converted in +% a regular grid by % % ebsd = ebsd.gridify % @@ -53,7 +54,7 @@ % ebsd.gradientY % % as well as an estimate of the gemeometrically neccessary dislocation -% density (GND) by +% density (GND) using the command % % ebsd.calcGND % diff --git a/doc/html/helptoc.xml b/doc/html/helptoc.xml index 9f8d104d3..0a444366c 100644 --- a/doc/html/helptoc.xml +++ b/doc/html/helptoc.xml @@ -97,7 +97,6 @@ repmat reshape rotate - rotate_outer scatter scatter3d size @@ -128,7 +127,6 @@ project2FundamentalRegion region rotate - rotate_outer round scatter smooth @@ -490,6 +488,7 @@ inpolygon mtimes plot + quiver reduce rotate shift @@ -538,7 +537,6 @@ rdivide real rotate - rotate_outer shearModulus size subsasgn @@ -965,29 +963,30 @@ Colorcoding according to inverse pole figure - Release NotesMTEX ChangelogMTEX 4.2 - 11/2015 - MTEX 4.1 - 09/2015 - MTEX 4.0.0 - 10/2014 - MTEX 3.5.0 - 12/2013 - MTEX 3.4.2 - 06/2013 - MTEX 3.4.1 - 04/2013 - MTEX 3.4.0 - 03/2013 - MTEX 3.3.2 - 01/2013 - MTEX 3.3.1 - 07/2012 - MTEX 3.3.0 - 06/2012 - MTEX 3.2.3 - 03/2012 - MTEX 3.2.1 - 11/2011 - MTEX 3.2 - 05/2011 - MTEX 3.1 - 03/2011 - MTEX 3.0 - 10/2010 - MTEX 2.0 - 10/2009 - MTEX 1.2 - 05/2009 - MTEX 1.1 - 12/2008 - MTEX 1.0 - 06/2008 - MTEX 0.4 - 04/2008 - MTEX 0.3 - 10/2007 - MTEX 0.2 - 07/2007 - MTEX 0.1 - 03/2007 + Release NotesMTEX ChangelogMTEX 4.3 - 03/2016 + MTEX 4.2 - 11/2015 + MTEX 4.1 - 09/2015 + MTEX 4.0.0 - 10/2014 + MTEX 3.5.0 - 12/2013 + MTEX 3.4.2 - 06/2013 + MTEX 3.4.1 - 04/2013 + MTEX 3.4.0 - 03/2013 + MTEX 3.3.2 - 01/2013 + MTEX 3.3.1 - 07/2012 + MTEX 3.3.0 - 06/2012 + MTEX 3.2.3 - 03/2012 + MTEX 3.2.1 - 11/2011 + MTEX 3.2 - 05/2011 + MTEX 3.1 - 03/2011 + MTEX 3.0 - 10/2010 + MTEX 2.0 - 10/2009 + MTEX 1.2 - 05/2009 + MTEX 1.1 - 12/2008 + MTEX 1.0 - 06/2008 + MTEX 0.4 - 04/2008 + MTEX 0.3 - 10/2007 + MTEX 0.2 - 07/2007 + MTEX 0.1 - 03/2007 List of Known BugsOpen Issues From 5aa9bd6718f08475c536f90d89d3a9f9c0bc1c44 Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 8 Mar 2016 15:17:13 +0100 Subject: [PATCH 119/120] bug fix --- EBSDAnalysis/@EBSD/calcTensor.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EBSDAnalysis/@EBSD/calcTensor.m b/EBSDAnalysis/@EBSD/calcTensor.m index cc33c1996..0fd26b50e 100755 --- a/EBSDAnalysis/@EBSD/calcTensor.m +++ b/EBSDAnalysis/@EBSD/calcTensor.m @@ -38,7 +38,7 @@ % initialize avarage tensors TVoigt = T{1}; -TVoigt.M = zeros(size(T{1})); +TVoigt.M = zeros(repmat(3,1,TVoigt.rank)); TVoigt.CS = specimenSymmetry; TReuss = TVoigt; From 4b0d75325f9a5cfaf4eddede0c7c40942333e6ea Mon Sep 17 00:00:00 2001 From: Ralf Hielscher Date: Tue, 8 Mar 2016 15:17:26 +0100 Subject: [PATCH 120/120] quiver for EBSD --- EBSDAnalysis/@EBSD/quiver.m | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 EBSDAnalysis/@EBSD/quiver.m diff --git a/EBSDAnalysis/@EBSD/quiver.m b/EBSDAnalysis/@EBSD/quiver.m new file mode 100644 index 000000000..d1a9cea22 --- /dev/null +++ b/EBSDAnalysis/@EBSD/quiver.m @@ -0,0 +1,37 @@ +function h = quiver(ebsd,dir,varargin) +% plot directions at ebsd centers +% +% Syntax +% quiver(ebsd,dir,'linecolor','r') +% +% mtexdata small +% quiver(ebsd,ebsd.rotations.axis) +% +% Input +% ebsd - @grain2d +% dir - @vector3d +% +% Options +% antipodal - +% maxHeadSize +% + +xy = [ebsd.prop.x(:),ebsd.prop.y(:)]; + +if check_option(varargin,'antipodal') || dir.antipodal + + varargin = [{'MaxHeadSize',0,'linewidth',2,'autoScaleFactor',0.5},varargin]; + xy = [xy;xy]; + dir = [dir(:);-dir(:)]; + +else + + varargin = [{'MaxHeadSize',5,'linewidth',2,'autoScaleFactor',0.5},varargin]; + +end + +h = optiondraw(quiver(xy(:,1),xy(:,2),dir.x,dir.y),varargin{:}); + +if nargout == 0, clear h; end + +end