image thumbnail

Mathworks Rubik version 2

by

 

04 Apr 2013 (Updated )

Display, tester and solver of the Rubik's game, including "full cubes".

sol=Color2FRU(S,Cube)
function sol=Color2FRU(S,Cube)
%Color2FRU - Convert Color space to FrontRightUp(and others)
%     sol=Color2FRU(S,Cube)
if isempty(S)
	sol=zeros(0,2);
	return
end
S(mod(S(:,2),4)==0,:)=[];
if isempty(S)
	sol=zeros(0,2);
	return
end
sol=zeros(size(S,1),3);
sol(:,3)=S(:,2);
C=zeros(1,6);
for i=1:6
	C(i)=Cube.Color(i,Cube.RotLayerCube(i,5));
end
for i=1:size(S,1)
	j=find(C==S(i));
	sol(i)=floor((j+1)/2);
	sol(i,2)=rem(j-1,2)*2-1;
end

Contact us