-
Notifications
You must be signed in to change notification settings - Fork 0
/
identifyBoundary.m
40 lines (40 loc) · 1.3 KB
/
identifyBoundary.m
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
35
36
37
38
39
40
function [fronteira, B1, B2, B3, B4] = identifyBoundary(nodeCoordinates, boundaryParameter)
coordx = nodeCoordinates(:, 2);
coordy = nodeCoordinates(:, 3);
k = boundary(coordx, coordy, boundaryParameter);
fronteira = [coordx(k), coordy(k)];
ymax = max(fronteira(:,2));
xmax = max(fronteira(:,1));
xmin = min(fronteira(:,1));
B1 = []; % esquerda
B2 = []; % baixo
B3 = []; % direita
B4 = []; % cima
s = []; % índices já utilizados
for i = 1:size(fronteira,1)
if fronteira(i,2) == ymax
B4 = [B4; fronteira(i,:)];
s = [s;i];
end
if fronteira(i,1) == xmin
B1 = [B1; fronteira(i,:)];
s = [s;i];
end
if fronteira(i,1) == xmax
B3 = [B3; fronteira(i,:)];
s = [s;i];
end
end
s = unique(s); % retirar índices repetidos (cantos)
for i = 1:size(fronteira,1)
if ~ismember(i,s)
B2 = [B2; fronteira(i,:)]; % B2 contém os pontos da fronteira não utilizados
end
end
B2 = [B2; xmax min(B3(:,2))]; % adicionar ponto final
B2 = [0 0; B2]; % adicionar ponto inicial
B1 = unique(B1, 'rows');
B2 = unique(B2, 'rows');
B3 = unique(B3, 'rows');
B4 = unique(B4, 'rows');
end