%
%  macm 202 -- 20 jan 03 -- djm
%
%  w4mRPS.m:  colour plot of min(transpose(A) P) for modified RPS
%    - to run, type "w4mRPS" at the MATLAB prompt

%  modified RPS matrix
Pmatrix = [0 -1 2 ; 1 0 -1 ; -1 1 0];

S = 2/sqrt(3);  ds = S/120;  x = 0:ds:S;  y = 0:ds:S;

f = zeros(size(y,2),size(x,2));

for j=1:size(x,2)
    for k=1:size(y,2)
        vect = [y(k) ; 0.5*(sqrt(3)*x(j)-y(k))];
        vect = [vect ; 1-vect(1,1)-vect(2,1)];
        f(k,j) = min(transpose(vect)*Pmatrix);
    end
end

figure(1)
pcolor(x-ds/2,y-ds/2,f);  shading flat;  hold on
colorbar;  colormap(jet)

fill([0 1/2 1/2 0 0]*S,[0 sqrt(3)/2 1 1 0]*S,'w')
fill([1 1/2 1/2 1 1]*S,[0 sqrt(3)/2 1 1 0]*S,'w')
axis([0 1 0 1]*S)

colormap;  colorbar;  grid on
title('\bf nelder-mead triangulation for modified RPS')
xlabel('\bf a1-axis')
ylabel('\bf a2-axis')
zlabel('\bf a3-axis')
hold on