• Remix
  • Share
  • New Entry

on 12 Nov 2023
  • 13
  • 16
  • 0
  • 0
  • 596
drawframe(1);
Write your drawframe function below
function drawframe(f)
if f==1
%% Setup cheap graphic
knot;
K=findobj('type','surface');
%% Setup twin axes
% We know the figure is square, so we can places these next to
% eachother in a simplistic way.
% Not that AX1 xdir is 'reverse' so it mirrors AX2.
AX_del = gca;
AX1 = axes('position',[0 0 .5 1],'xdir','reverse');
AX2 = axes('position',[ .5 0 .5 1]);
% Both sides get the same limits so they are identical, except for
% AX1 being xdir reverse.
Q=5.5;
axis([AX1 AX2], [ -Q Q -Q Q -Q Q ], 'off');
% Note: If the figure weren't square, we'd need to expand the xlims to
% account for the figure to properly fill the space.
xl = xlim(AX1);
xlim([AX1 AX2],[0 xl(2)]);
%% Rotation transforms
% Each side gets a transform. Copyobj the knot into one side, and
% reparent the og knot into the other.
TX = [ hgtransform('parent',AX1,'tag','tx1') hgtransform('parent',AX2,'tag','tx2') ];
K.Parent = TX(1);
copyobj(K,TX(2));
% I'd rather delete this knot
set(AX_del, 'visible','off')
% Lights on opposite sides so it looks like it's from the same
% side.
camlight(AX1,'right')
camlight(AX2,'left')
colormap(hsv) % continous colormap
set([AX1 AX2],'dataaspectratio',[1 1 1])
else
TX = [ findobj('tag','tx1') findobj('tag','tx2') ];
end
%% Rotate around Y
% This lets us see all parts of the knot and gives it the odd looping
% into itself illusion.
set(TX, 'Matrix', makehgtform('zrotate',(f-1)*2*pi/48,'yrotate', (f-1)*2*pi/48));
end
Animation
Remix Tree