gusucode.com > 三维模仿源码程序 > 三维模仿源码程序/MathRubik2/FRU2Color.m

    function sol=FRU2Color(S,Cube)
%FRU2Color - Convert FrontRightUp(and others) to Color space
%     sol=FRU2Color(S,Cube)
if isempty(S)
	sol=zeros(0,3);
	return
end
S(mod(S(:,3),4)==0,:)=[];
if isempty(S)
	sol=zeros(0,3);
	return
end
sol=zeros(size(S,1),2);
sol(:,2)=S(:,3);
for i=1:size(S,1)
	j = 2*S(i,1)-1+(S(i,2)+1)/2;
	sol(i)=Cube.Color(j,Cube.RotLayerCube(j,5));	% color of mid cube
end