function H=r(c) [b,i]=sort(c);h=60*[6*(i(1)~=3),2,4](i);H=(h(3)-h(2))*(1+(b(3)-b(2))/(b(3)-b(1)))/2+h(2);

end % only necessary to separate function from test driver in the same file

r1=r([0 182 255])
r2=r([127 247 103])
r3=r([0 0 1])
r4=r([255 165 245])