image thumbnail

Mathworks Rubik version 2

by

 

04 Apr 2013 (Updated )

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

hOut=PlotSurf(Coor,Image)
function hOut=PlotSurf(Coor,Image)
%PlotSurf - Plot an image in a 3D-surface

if max(Image(:))>1
	Image=double(Image);
end
b=true(1,3);
iX=find(abs(Coor(1,:)-Coor(2,:))>1e-4);
iY=find(abs(Coor(1,:)-Coor(4,:))>1e-4);
b(iX)=false;b(iY)=false;
iZ=find(b);
fprintf('iX,iY,iZ : %d,%d,%d\n',iX,iY,iZ)

[m,n]=size(Image);
XYZ=cell(1,3);
XYZ{iX}=(0:n-1) /(n-1)*(Coor(2,iX)-Coor(1,iX))+Coor(1,iX);
XYZ{iY}=(0:m-1)'/(m-1)*(Coor(3,iY)-Coor(1,iY))+Coor(1,iY);
XYZ{iX}=XYZ{iX}(ones(1,m),:);
XYZ{iY}=XYZ{iY}(:,ones(1,n));
XYZ{iZ}=zeros(m,n)+Coor(1,iZ);
h=surface(XYZ{1},XYZ{2},XYZ{3},Image,'CDataMapping','direct','EdgeColor','none');
if nargout
	hOut=h;
end

Contact us