• /
• # Christmas Tree Illusion

on 7 Nov 2023
• 17
• 153
• 1
• 3
• 572
drawframe(1);
Write your drawframe function below
function drawframe(f)
% You'll see three rotation patterns: clockwise, counterclockwise, and both.
% If you look up and down or look away for a moment, you get the opposite rotation,
% and if you look at the one that looks like it's going around backwards, you get both rotations mixed up.
N = 4; % number of ornament strings
th0 = 0:pi/20:2*pi*1.5;
h = th0;
maxh = max(h);
dAz = pi/(2*48);
maxAz = 2*pi - dAz;
off = (f-1) * dAz;
th = th0 - off;
x = h .* sin(-th);
y = h .* cos(-th);
plot3(x,y,-h,'b');
% plot3(x,y,-h,'b-p','MarkerIndices',1:4:length(h),'MarkerSize',10);
xlim([-12 12])
ylim([-12 12])
zlim([-10 0.5])
view(0,0)
axis off
hold on
plot3(x,y,-h,'rp','MarkerIndices',1:4:length(h),'MarkerSize',10);
plot3(x,y,-h,'g*','MarkerIndices',3:4:length(h),'MarkerSize',8);
% plot3(x,y,-h,'b*','MarkerIndices',3:4:length(h),'MarkerSize',8);
for k = 2:N
th = th + 2*pi/N;
x = h .* sin(-th);
y = h .* cos(-th);
plot3(x,y,-h,'b');
plot3(x,y,-h,'rp','MarkerIndices',1:4:length(h),'MarkerSize',10);
plot3(x,y,-h,'g*','MarkerIndices',3:4:length(h),'MarkerSize',8);
% plot3(x,y,-h,'b-p','MarkerIndices',1:4:length(h),'MarkerSize',10);
% plot3(x,y,-h,'b*','MarkerIndices',3:4:length(h),'MarkerSize',8);
end
hold off
end