function mu = bc_metric(vertex, face, map, dimension)

% target dimension: 2 or 3

MyDifferential = diff_operator(vertex, face);

switch dimension
    case 2
        f = complex(map(1,:), map(2,:));
        mu = (MyDifferential.Dc*(f.')) ./ (MyDifferential.Dz*(f.'));
    case 3
        dXdu = transpose(MyDifferential.Dx* map(1,:)');
        dXdv = transpose(MyDifferential.Dy* map(1,:)');
        
        dYdu = transpose(MyDifferential.Dx* map(2,:)');
        dYdv = transpose(MyDifferential.Dy* map(2,:)');
        
        dZdu = transpose(MyDifferential.Dx* map(3,:)');
        dZdv = transpose(MyDifferential.Dy* map(3,:)');
        
        E = dXdu.^2 + dYdu.^2 + dZdu.^2;
        G = dXdv.^2 + dYdv.^2 + dZdv.^2;
        F = dXdu.*dXdv + dYdu.*dYdv + dZdu.*dZdv;

        mu = (E - G + 2 * 1i * F) ./ (E + G + 2*sqrt(E.*G - F.^2));
        mu = mu.';
    otherwise
        error('Dimension must be 3 or 2.')
end


end
