File: CheckSymmtricLines.m

package info (click to toggle)
openems 0.0.35%2Bgit20190103.6a75e98%2Bdfsg.1-3.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,544 kB
  • sloc: cpp: 40,417; python: 2,028; yacc: 580; makefile: 459; lex: 350; sh: 176; ruby: 19
file content (34 lines) | stat: -rw-r--r-- 728 bytes parent folder | download | duplicates (3)
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;