function [A,b] = mkp2d(P,T,ID,k,f)

n = size(P,2);
m = size(T,2);
Avlnka = zeros(n,n);
bvlnka = zeros(n,1);

for p=1:m
    Tp = T(:,p);
    u = P(:,Tp(2))-P(:,Tp(1));
    v = P(:,Tp(3))-P(:,Tp(1));
    Rp = [u,v];
    obsahTp = abs(det(Rp))/2;
    
    Bp = inv(Rp)'*[-1 1 0;-1 0 1];
    Ap = k(p)*Bp'*Bp*obsahTp;
 
    bp = (f(p)*obsahTp/3) * [1;1;1];
    
    Avlnka(Tp,Tp) = Avlnka(Tp,Tp) + Ap;
    bvlnka(Tp) = bvlnka(Tp) + bp;
end

idx = setdiff(1:n,ID);
A = Avlnka(idx,idx);
b = bvlnka(idx);
