function [x, TrigoBasis, Ostar, fstar, Mth] = func_emissionProjection_Trigo(m, Qstar, param, kast, lawtype)
% Computes fstar and its projection on the trigonometric basis.

% Stationary law.
pistar = func_stationaryLaw(Qstar);

% True emission laws and their projection onto Sm
meshlength = 10000;
x=linspace(0,1,meshlength);

% Density of the emission laws.
fstar = func_emissionDensities(x,param,kast,lawtype);

% Trigonometric basis
TrigoBasis=ones(m,meshlength);
for i=1:m
    TrigoBasis(i,:)=(sqrt(2)+(1-sqrt(2)).*(i==1)).*(cos(pi.*(i-1).*x)');  
end

% True law of the observations
Ostar = zeros(m,kast);
Ostar = (1/meshlength).*TrigoBasis*(fstar');

Mth = zeros(m,m,m);
for b=1:m
    Mth(:,b,:) = Ostar * diag(pistar) * Qstar * diag(Ostar(b,:)) * Qstar * Ostar';
end
