Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/regular s2quadrature #1572

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
faster but less accurate unique function
ralfHielscher committed Jul 21, 2021
commit 5a9903d222809e78d172cd89956d580e1f1f34c7
9 changes: 7 additions & 2 deletions geometry/@orientation/unique.m
Original file line number Diff line number Diff line change
@@ -27,13 +27,18 @@

[~,ndx,pos] = unique@rotation(ori,varargin{:});

else
elseif length(ori)<2000
rot = rotation(symmetrise(ori,varargin{:}));

[~,~,pos] = unique(rot,varargin{:});

[~,ndx,pos] = unique(min(reshape(pos,size(rot)),[],1));


else

ori = ori.project2FundamentalRegion;
[~,ndx,pos] = unique@rotation(ori,varargin{:});

end

ori = ori.subSet(ndx);
41 changes: 28 additions & 13 deletions geometry/@rotation/unique.m
Original file line number Diff line number Diff line change
@@ -22,26 +22,41 @@
% unique
%

a = r.a(:);
b = r.b(:);
c = r.c(:);
d = r.d(:);
i = r.i(:);

abcd = [a.^2,b.^2,c.^2,d.^2,a.*b,a.*c,a.*d,b.*c,b.*d,c.*d,i];
a = r.a(:); b = r.b(:); c = r.c(:); d = r.d(:);

tol = get_option(varargin,'tolerance',1e-3);
if length(r) < 1000 && ~check_option(varargin,'tolerance')

abcd = [a.^2,b.^2,c.^2,d.^2,a.*b,a.*c,a.*d,b.*c,b.*d,c.*d, r.i(:)];

tol = get_option(varargin,'tolerance',1e-3);

% in case it should not be sorted
if check_option(varargin,'stable')
[~,ir,iu] = unique(round(abcd./tol),'rows','stable');
else
[~,ir,iu] = uniquetol(abcd,tol,'ByRows',true,'DataScale',1);
end

else % faster but less accurate


tol = get_option(varargin,'tolerance',5*degree);

% ensure upper hemisphere
ind = d < 0;
a(ind) = -a(ind); b(ind) = -b(ind);
c(ind) = -c(ind); d(ind) = -d(ind);

[~,ir,iu] = uniquetol([a,b,c,d],tol / 100 / degree, ...
'ByRows',true,'DataScale',1);

% in case it should not be sorted
if check_option(varargin,'stable')
[~,ir,iu] = unique(round(abcd./tol),'rows','stable');
else
[~,ir,iu] = uniquetol(abcd,tol,'ByRows',true,'DataScale',1);
end

% remove duplicated points
r.a = a(ir);
r.b = b(ir);
r.c = c(ir);
r.d = d(ir);
r.i = i(ir);
r.i = r.i(ir);