• Remix
  • Share
  • New Entry

  • Jr

  • /
  • Christmas tree

on 25 Nov 2023
  • 15
  • 15
  • 0
  • 0
  • 505
drawframe(1);
Write your drawframe function below
%source: https://www.mathworks.com/matlabcentral/fileexchange/65525-rotating-christmas-tree?s_tid=srchtitle&fbclid=IwAR0B3hz_CL4OO6cyOihvmr48XQKhfY-OKfo8LxDQnLLMPoyMUf9CpcErhsw
function drawframe(f)
figure('color', [204 102 255]/255)
hold on;
N = 6^5;
c = f;
k = randi(6,c,1);
l = randperm(N,c);
q = @(x) rand(N,1);
a = q()*2*pi;
z = q();
r = .4*(1-z);
t = q();
x = r.*cos(a);
y = r.*sin(a);
P = {'ro','ys','md','b^','kh','c*'};
scatter3(x.*t,y.*t,z,[],[zeros(N,1) (t.*r).^.5 zeros(N,1)],'*')
plot3(0,0,1.05,'rp','markers',12,'markerf','r')
for i = 1:6
L = l(k==i);
plot3(x(L),y(L),z(L),P{i},'markers',10,'linew',3);
end
[X,Y,Z] = cylinder(.025,30);
surf(X,Y,-Z*.1)
view(3, 9), axis equal off
for i = 1:9:c*9,
set(gca,'vie',[i, 9]); drawnow,
end
end
Animation
Remix Tree