function [Cx,Cy] = BSplineCurve(p,punti)
np = size(punti,2);
ndiv = np-p+1;
U = [repmat(0,1,p),linspace(0,1,ndiv),repmat(1,1,p)]
kmax = length(U)-p-1;
uvalue = linspace(0,1,100);

Nip = zeros(length(uvalue),kmax);
for k=1:kmax,
    for i=1:length(uvalue),
        u = uvalue(i);
        Nip(i,k) = BSplineEval(k,p,U,u);
    end
end

Cx = zeros(length(uvalue),1);
Cy = zeros(length(uvalue),1);
for k=1:kmax,
    Cx = Cx+Nip(:,k)*punti(1,k);
    Cy = Cy+Nip(:,k)*punti(2,k);
end

