-
Notifications
You must be signed in to change notification settings - Fork 9
/
triSmooth.m
46 lines (38 loc) · 988 Bytes
/
triSmooth.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
function smooth= triSmooth(t)
% TRISMOOTH Laplacian smoothing matrix for triangles
%
% Usage
% [smooth] = triSmooth(t)
%
% Edited June 24, 2010 by WDB
% Cornell Univeristy
%
% Routine generates a Laplacian smoothing matrix for higher level Tikhonov
% regularization. Smoothing of triangles is not weighted by their area
% since it is assumed that triangle size gradients vary smoothly.
%
% Variables
% T - Index terms for triangles with coordinates defined in P. Same as
% triId in CHECKSCALES and MAKENEWMESH
smooth = eye(length(t));
for i=1:length(t)
clear common
common= [];
a = t(i,:);
for j= 1:length(t)
b=t(j,:);
tmp = intersect(a,b);
if length(tmp)==2
common= [common j];
end
end
nneighbor= length(common);
if nneighbor==1
id= common;
smooth(i,id)= -1;
elseif nneighbor==2
smooth(i,common)= -1/2;
else
smooth(i,common)=-1/3;
end
end