function [R centres]=rayonscir(tri,X);

Dt=size(tri);
Nt=Dt(1);
Pt=Dt(2);
D=size(X);
N=D(1);
P=D(2);
R=zeros(Nt,1);
centres=zeros(Nt,P);
for i=1:Nt
    %construit la base des points pour le simplexe i;
    Xi=X(tri(i,:),:);
    vect=zeros(P,Pt-1);
    for j=1:Pt-1
        vect(:,j)=(Xi(j+1,:)-Xi(1,:))';
    end
    A=zeros(Pt-1);
    B=zeros(Pt-1,1);
    for j=1:Pt-1
        for k=1:Pt-1
            A(j,k)=vect(:,k)'*vect(:,j);
        end
        B(j)=(1/2)*norm(vect(:,j))^2;
    end
    %if abs(rcond(A))>=10^(-10)
        x=A^(-1)*B;
        x=A\B;
        O=zeros(P,1);
        for j=1:Pt-1
            O=O+x(j)*vect(:,j);
        end
        R(i)=norm(O);

        centres(i,:)=O'+Xi(1,:);
    %else
    %    R(i)=Inf;
    %end
end

II=ones(Nt,1);
for i=1:Nt
    for j=1:P
        if centres(i,j)<0
            II(i)=0;
        end
        if centres(i,j)>1
            II(i)=0;
        end
    end
end

% figure
% if P==2
% plot(X(:,1),X(:,2),'.')
% hold on
% ii=find(II==0);
% tt=tri(ii,:);
% trimesh(tt,X(:,1),X(:,2))
% end
% if P==3
%     plot3(X(:,1),X(:,2),X(:,3),'.')
%     hold on
%     ii=find(II==0);
%     tt=tri(ii,:);
%     for j=1:4
%         plot3(X(tt(:,j),1),X(tt(:,j),2),X(tt(:,j),3),'or')
%         hold on
%     end
% end
