function creparametrize(x,ce,cc)
global ini_Val

%Initialization
nn=ini_Val.ncontrol;
N=(nn-1)*ini_Val.samp_reparam;
gaussp=linspace(0,1,N);

Invariant_sample_bis = precal_generic(gaussp); 

[C,C1,C2] = interpolate(Invariant_sample_bis,x);

au = sqrt(C1(:,1).^2 + C1(:,2).^2);

arclength=zeros(size(gaussp));
arclength(1)=0;
for i=2:length(au)
    arclength(i)=arclength(i-1) + (au(i-1)+au(i))/2*Invariant_sample_bis.gweight;
end

%*------Concentration Parameters-------
%---------------------------------------
if isfield(ini_Val,'i_tube')
    k= cc*(1./(C(:,1)+0.05)).^ce+1;
else
    %k= cc*(abs(C1(:,1).*C2(:,2)-C2(:,1).*C1(:,2))./(C1(:,1).^2 + C1(:,2).^2) + abs(C1(:,2)./(C(:,1)+0.1))).^ce+1;
    k= cc*(abs(C1(:,1).*C2(:,2)-C2(:,1).*C1(:,2))./(C1(:,1).^2 + C1(:,2).^2)).^ce+1;
end
%figure(307)
%hold off
%plot(gaussp,k,'r-')
%hold on
% smooth the curvature
k = smooth(k,ini_Val.smoo_reparam);
%figure(307)
%plot(gaussp,k,'g-')
%pause



g=zeros(size(gaussp));
for i=2:length(g)
    g(i)=g(i-1) + (k(i-1)+k(i))/2*Invariant_sample_bis.gweight;
end
arcl_equi=linspace(0,g(end),(nn-ini_Val.p+1));
for i=2:nn-ini_Val.p
%for i=ini_Val.p-1:nn-ini_Val.p
    [val, index]=min(abs(g-arcl_equi(i)));
    if g(index)>=arcl_equi(i)
        index=index-1;
    end
    
    uc(i)=(arcl_equi(i)*(gaussp(index+1)-gaussp(index)) + ...
    gaussp(index)*g(index+1) - gaussp(index+1)*g(index)) ...
    / (g(index+1)-g(index));
end
uc(nn-ini_Val.p+1)=1;
%ini_Val.U(4:end-3)=uc;
ini_Val.U((ini_Val.p+1):end-ini_Val.p)=uc;
precal_gauss;

