mtex-toolbox / mtex

MTEX is a free Matlab toolbox for quantitative texture analysis. Homepage:
http://mtex-toolbox.github.io/
GNU General Public License v2.0
281 stars 185 forks source link

calcUnitCell bug when ebsd map xy are very far from zero #1722

Open vtvivian opened 1 year ago

vtvivian commented 1 year ago

What do you want to do? I want to translate an EBSD map xy coordinates to very far from zero to match some other global coordinate frame on my sample.

I found a bug when trying to update the unit cell where the step size changes I can reproduce it with an example dataset, code below.

I think it comes from line 42 in calcUnitCell: because uniquetol uses a tolerance that multiplies by the xy values it ended up deleting lots of datapoints that were not duplicates.

% remove dublicates from the coordinates
xy = uniquetol(xy,0.01/sqrt(size(xy,1)),'ByRows',true);

For the moment I can guarantee I have no duplicate xy points so fixed by just commenting out that line, not sure now how to fix it for the general case?

What code do you use?

mtexdata single

ebsd.extend
% ans =
% 
%      6    16     4    14
ebsd.unitCell
% ans =
% 
%    -0.0500   -0.0500
%     0.0500   -0.0500
%     0.0500    0.0500
%    -0.0500    0.0500
gridify(ebsd).dx
% ans =
% 
%     0.1000
ebsd2 = ebsd + [-3500 10]; %big random xy-shift
ebsd2.extend
% ans =
% 
%    -3494       -3484          14          24
ebsd2.unitCell 
% ans =
% 
%    -0.0500    0.0500
%     0.0500    0.0500
%     0.0500   -0.0500
%    -0.0500   -0.0500
ebsd2=updateUnitCell(ebsd2);
ebsd2.unitCell 
% ans =
% 
%     0.3000   -0.0500
%    -0.3000   -0.0500
%    -0.3000    0.0500
%     0.3000    0.0500
gridify(ebsd2).dx 
% ans = 
%     0.6000

What result do you get

What result do you expect

What MTEX version do you use? 5.8.1