= mod(i-1,3)+1; i2 = mod(i ,3)+1; i3 = mod(i+1,3)+1; pp = vertex(:,faces(i2,:)) - vertex(:,faces(i1,:)); qq = vertex(:,faces(i3,:)) - vertex(:,faces(i1,:)); % normalize the vectors pp = pp ./ repmat( sqrt(sum(pp.^2,1)), [3 1] ); qq = qq ./ repmat( sqrt(sum(qq.^2,1)), [3 1] ); % compute angles a = 1 ./ tan( acos(sum(pp.*qq,1)) ); a = max(a, 1e-2); % avoid degeneracy W = W + make_sparse(faces(i2,:),faces(i3,:), a, n, n ); W = W + make_sparse(faces(i3,:),faces(i2,:), a, n, n ); end D = spdiags(full( sum(W,1) ), 0, n,n); L = D - W; L1 = L; L1(boundary,:) = 0; L1(boundary + (boundary-1)*n) = 1; Rx = zeros(n,1); Rx(boundary) = x0; Ry = zeros(n,1); Ry(boundary) = y0; x = L1 \ Rx; y = L1 \ Ry; S S0 : S0 ⇥ S S0 ⇥ S ⇥ x S0 \⇥S0, = 0 Formation of the linear system: Formation of the RHS and resolution: Discretization of :