function bc = normaliseBaryCoords( bc )
%bc = normaliseBaryCoords( bc )
%   Force all elements of bc to be in the range 0..1 with a sum of 1.
%   bc may be a matrix in which each row is a set of barycentric
%   coordinates.
    if false
        m = min(bc,[],2);
        m = min(m,0);
        newbc = bc - m*ones(1,size(bc,2));
      % newbc = max(bc,0);
        sumbc = sum(newbc,2);
        bc = newbc ./ (sumbc * ones(1,size(newbc,2)));
    else
        for i=1:size(bc,1)
            negs = bc(i,:) < 0;
            numneg = numel(find(negs));
            if numneg==2
                bc(i,:) = 0;
                bc(i,~negs) = 1;
            elseif numneg==1
                bc1 = bc(i,:) - bc(i,negs);
                bc(i,:) = bc1/sum(bc1);
            end
        end
    end
end
