function chebyshev_moms=cubature_tens_chebyshev_facet(nodes,weights,...
    chebyshev_exponents)

% Compute the cubature on the facet, having cubature nodes/weights of an
% algebraic rule with nodes "nodes" and weights "weights" of degree of
% precision "ade", of all the chebyshevs having total degree inferior or
% equal to "ade".
% As output we provide these moments in the column vector "chebyshev_moms",
% ordered as in "chebyshev_exponents", with total degree as
% "chebyshev_total_degrees".

XN=nodes(:,1); YN=nodes(:,2); ZN=nodes(:,3);
chebyshev_moms=[];
for index=1:size(chebyshev_exponents,1)
    i=chebyshev_exponents(index,1);
    j=chebyshev_exponents(index,2);
    k=chebyshev_exponents(index,3);
    
    % Tensorial Chebyshev polynomials x-primitive.
    switch i
        case 0
            f=@(x,y,z) x.*cos(j*acos(y)).*cos(k*acos(z));
        case 1
            f=@(x,y,z) ((x.^2)/2).*cos(j*acos(y)).*cos(k*acos(z));
        otherwise
            f=@(x,y,z) (i*cos((i+1)*acos(x))/(i^2-1)-x.*cos((i-1)*acos(x))/(i-1)).*cos(j*acos(y)).*cos(k*acos(z));
    end
    
    FXYZN=feval(f,XN,YN,ZN);
    chebyshev_momsL=weights'*FXYZN;
    chebyshev_moms=[chebyshev_moms; chebyshev_momsL];
end