1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
function result = CheckSymmtricLines(lines)
% function result = CheckSymmtricLines(lines)
%
% check mesh lines for symmetry
%
% Note: make sure lines are sorted and unique
%
% CSXCAD matlab interface
% -----------------------
% author: Thorsten Liebig (C) 2012
result = false;
tolerance = 1e-10;
NP = numel(lines);
range = lines(end)-lines(1);
center = 0.5*(lines(end)+lines(1));
% check all lines for symmetry
for n=1:NP/2
if (abs((center-lines(n))-(lines(end-n+1)-center)) > range*tolerance/NP)
return;
end
end
% check central point to be symmetry-center
if (mod(NP,2))
if (abs(lines((NP+1)/2)-center) > range*tolerance/NP)
return;
end
end
% if all checks pass, return true
result = true;
|