-
Notifications
You must be signed in to change notification settings - Fork 5
/
pwa_cell.m
53 lines (51 loc) · 2.3 KB
/
pwa_cell.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
41
42
43
44
45
46
47
48
49
50
51
52
53
function CellInfo = pwa_cell(pwafun)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Create the cell descriptions and boundary descriptions using %
% information about the vertices and the triangulation. %
% %
% Input: %
% pwafun.X: Vertices %
% pwafun.T: Triangulation %
% %
% Output: %
% CellInfo.Ebar: Cell descriptions %
% CellInfo.Fbar: Boundary descriptions %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Obtain dimensions of Triangulation
[m n] = size(pwafun.T);
% Create cell descriptions
for i = 1:m,
CellInfo.Ebar{i} = [];
for j = 1:n,
Index = 1:n;
Index(j)=[];
% M = [pwafun.X(pwafun.T(i,Index),:) ones(n-1,1)];
% Ebar = [1 -(M(:,2:end)\M(:,1))'];
M = [pwafun.X(pwafun.T(i,Index),:) ones(n-1,1)];
Ebar = null(M)';
xbar = [pwafun.X(pwafun.T(i,j),:) 1]';
if all(Ebar*xbar < 0),
Ebar = -Ebar;
end
CellInfo.Ebar{i} = [CellInfo.Ebar{i}; Ebar];
end
end
% Create boundary descriptions
for i = 1:m-1,
for j = i+1:m
Index = intersect(pwafun.T(i,:),pwafun.T(j,:));
if ~isempty(Index) && length(Index)==n-1,
% M = [pwafun.X(Index,:) ones(n-1,1)];
% if rank(M(:,2:end))==length(M(:,2:end)),
% CellInfo.Fbar{i,j} = [(M(:,2:end)\M(:,1))';eye(n-1)];
% else
% error('Computation of Fbar should be updated!');
% end
M = [pwafun.X(Index,:) ones(n-1,1)]';
CellInfo.Fbar{i,j} = M*[eye(n-2,n-1);-ones(1,n-2) 1];
CellInfo.Fbar{j,i} = CellInfo.Fbar{i,j};
end
end
end