- /
-
Christmas Tree Illusion (modified)
on 1 Dec 2023
- 9
- 40
- 0
- 0
- 600
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);
c = [0.1 0.1 0.87 0.1];
plot3(x,y,-h,Color=c);
% 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',8);
plot3(x,y,-h,'g*','MarkerIndices',3:4:length(h),'MarkerSize',4);
for k = 2:N
th = th + 2*pi/N;
x = h .* sin(-th);
y = h .* cos(-th);
plot3(x,y,-h,Color=c);
plot3(x,y,-h,'rp','MarkerIndices',1:4:length(h),'MarkerSize',8);
plot3(x,y,-h,'g*','MarkerIndices',3:4:length(h),'MarkerSize',4);
end
hold off
end