function cube();

figure(1);
clf;
view(3);

vert = [0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1];

faces = [1 2 6 5;2 3 7 6;3 4 8 7;4 1 5 8;1 2 3 4;5 6 7 8];

h=patch('Vertices',vert,'Faces',faces,'FaceVertexCData',hsv(8), ...
      'FaceColor','interp');
axis([-0.5 1.5 -0.5 1.5 -0.5 1.5]);
axis square;

for i=1:120
  vert = trans(pi/60,vert);
  delete(h);

  h=patch('Vertices',vert,'Faces',faces,'FaceVertexCData',hsv(8), ...
          'FaceColor','interp');
  drawnow;
end

return

function v=trans(a,vr);

B= [-1.0000    0.5774    1.0000
          0   -1.1547    1.0000
     1.0000    0.5774    1.0000];

%B = [-1 -1 1; 0 1 1; 1 0 1];

R=[cos(a) -sin(a) 0;sin(a) cos(a) 0;0 0 1]; 

T = B*R*inv(B);

v = (T*vr')';

return