1

Delaunay 三角形分割を使用して、ポリゴンを三角形に分割しています。私は大規模なコードで FEM に取り組んでおり、私の「チェックポイント」の 1 つは対称性です (データが対称的である場合、出力も対称的でなければなりません)。ただし、ドロネー三角形分割を制御できないため、対称性が失われます。

私の問題を説明する小さなコードを書きました。2 つの互いに素な三角形と、それらが交差する大きな四角形を考えます。これらの三角形の減算を四角形で三角測量したいと思います。

clear all
close all
warning off % the warning is about duplicate points, not important here

figure
hold on

p =[.3 .3
.4 .3
.3 .4
.7 .6
.6 .7
.7 .7]; % coordinates of the points for the triangles

px = 1/3;
py = 1/3;
lx = 1/3;
ly = 1/3; % size and position of the rectangle

% rearrange the polygon with clockwise-ordered vertices
[x1,y1]=poly2cw([px; px+lx; px+lx; px],[py; py; py+ly; py+ly]); % rectangle

patch(x1,y1, 1, 'EdgeColor', 'k');

for i=1:2

    pc = p(3*i-2:3*i,:); % current triangle
    % rearrange the polygon with clockwise-ordered vertices
    [x0,y0]=poly2cw(pc(:,1),pc(:,2)); % triangle

    [x2,y2] = polybool('intersection',x1,y1,x0,y0); % intersection
    [x3,y3] = polybool('subtraction',x0,y0,x2,y2); % subtraction

    DT = delaunayTriangulation(x3,y3);

    triplot(DT,'Marker','o')

end
XL = xlim; xlim(XL+[-1 +1]*diff(XL)/10);
YL = ylim; ylim(YL+[-1 +1]*diff(YL)/10);
axis equal;
box on;

ドロネー三角形分割

ご覧のとおり、ドロネー三角形分割は両方の三角形で同じ動作をしないため、対称性が失われます。

対称性を回復する簡単な方法はありますか?

私はMatlab R2013aを使用しています。

4

2 に答える 2

0

これはバグではないようです。実際、結果はデー​​タから得られます。

私はあなたのコードで少し遊んだ

clear all
close all
warning off % the warning is about duplicate points, not important here

figure
hold on

p =[.3 .3
.4 .3
.3 .4
.7 .6
.6 .7
.7 .7]; % coordinates of the points for the triangles

px = 1/3;
py = 1/3;
lx = 1/3;
ly = 1/3; % size and position of the rectangle

% rearrange the polygon with clockwise-ordered vertices
[x1,y1]=poly2cw([px; px+lx; px+lx; px],[py; py; py+ly; py+ly]); % rectangle

patch(x1,y1, 1, 'EdgeColor', 'k');

for i=1:2

    pc = p(3*i-2:3*i,:); % current triangle
    % rearrange the polygon with clockwise-ordered vertices
    [x0,y0]=poly2cw(pc(:,1),pc(:,2)); % triangle

    [x2,y2] = polybool('intersection',x1,y1,x0,y0); % intersection
    [x3,y3] = polybool('subtraction',x0,y0,x2,y2); % subtraction

    % This is for R2013a
    %DT = delaunayTriangulation(x3,y3);
    %triplot(DT,'Marker','o');

    % This is for R2011b
    %DT = DelaunayTri(x3,y3);
    %triplot(DT,'Marker','o');

    % This is plain delaunay version
    DT = delaunay(x3,y3);
    triplot(DT,x3,y3,'Marker','o')
    
    % we break here to analyze the first triangulation
    break

end
XL = xlim; xlim(XL+[-1 +1]*diff(XL)/10);
YL = ylim; ylim(YL+[-1 +1]*diff(YL)/10);
axis equal;
box on;

% % % % % % % % % % % % % % % % % %
% Checking the triangulation
% % % % % % % % % % % % % % % % % %

% Wrong triangulation for i=2 is hard-coded
DT2     = [
    2 1 6
    6 5 2
    5 3 2
    5 4 3
    2 3 1 ];

figure;
hold all;
triplot(DT2,x3,y3,'Marker','o', 'Color','r', 'LineWidth',1)
axis equal;
axis tight;
box on;
XL = xlim; xlim(XL+[-1 +1]*diff(XL)*0.5);
YL = ylim; ylim(YL+[-1 +1]*diff(YL)*0.5);

% circumcircle: http://www.mathworks.com/matlabcentral/fileexchange/17300
ca = linspace(0,2*pi);
cx = cos(ca);
cy = sin(ca);

hl = [];
for k=1:size(DT2,1)
    tx  = x3(DT(k,:));
    ty  = y3(DT(k,:));
    [r,cn]=circumcircle([tx,ty]',0);
    if ~isempty(hl)
        %delete(hl);
    end
    fprintf('Circle %d: Center at (%.23f,%.23f); R=%.23f\n',k,cn,r);
    text( cn(1),cn(2), sprintf('c%d',k) );
    hl = plot( cx*r+cn(1), r*cy+cn(2), 'm-' );
    drawnow;
    %pause(3); %if you prefere to go slowly 
end

そして、これは私が見る出力です:

円 1: (0.28333333333333333000000,0.35000000000000003000000) の中心; R=0.05270462766947306400000 円 2: (0.34999999999999998000000,0.34999999999999998000000) の中心; R=0.02357022603955168100000 円 3: (0.2833333333333338000000,0.34999999999999992000000) の中心; R=0.05270462766947289800000 円 4: (0.35000000000000003000000,0.2833333333333355000000) の中心; R=0.05270462766947290500000 円 5: (0.35000000000000003000000,0.2833333333333333000000) の中心; R=0.05270462766947312000000

そして図:

ここに画像の説明を入力

したがって、円 1 と 3、および円 4 と 5 はほぼ同じです。したがって、対応する 4 つの点が float 数学精度内の同じ円上にあるため、あなたの結果と私の結果の違いは、丸め誤差からも生じる可能性があります。そのようなものに依存しない信頼できる結果を得るには、ポイントを再設計する必要があります。

楽しんでください;o)

于 2013-04-26T14:57:49.133 に答える