- /
-
XMas tree1
on 24 Oct 2024
- 29
- 142
- 0
- 1
- 1915
Cite your audio source here (if applicable): 《圣诞结》陈奕迅
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent Ll S1 S2 H1 H2
if f==1
ax=gca;hold on;
set(gcf,'Color',[0,9,33]/255);
set(ax,'Position',[-1/4,-1/3,1+1/2,1+2/3],'XLim',[-7,7],'YLim',[-7,7],'ZLim',[-6,18],'Color',[0,9,33]/255);
hold on;view(-40,15);
ax.DataAspectRatio=[1,1,1.2];
XMT=@(h,r,a,z)deal((h-z)./h.*r.*cos(a.*z),(h-z)./h.*r.*sin(a.*z), z);
OFS=@(x,y,z,p)deal(x+rand(size(x)).*p-p/2,y+rand(size(y)).*p-p/2, z+rand(size(z)).*p-p/2);
% 绘制圣诞树主体,参考:Hanchu Wang (2023). Rotating Christmas Tree
% (https://www.mathworks.com/matlabcentral/fileexchange/103980-rotating-christmas-tree)
F='MarkerFaceAlpha';E='MarkerEdgeAlpha';
h=10.05;
r=h/(1+sqrt(5));
[X,Y,Z]=XMT(h,r,100*pi,rand(3000,1).*h);
[X,Y,Z]=OFS(X,Y,Z,.1);
scatter3(X,Y,Z,12,[213,194,100]./255,'filled',F,.9,E,.9)
[X,Y,Z]=XMT(h,r,100*pi,rand(500,1).*h);
[X,Y,Z]=OFS(X,Y,Z,1.5);
scatter3(X,Y,Z,8,[255,255,255]./255,'filled',F,.2,E,.2)
[X,Y,Z]=XMT(h,r,20*pi,linspace(0,1,1000)*h);
scatter3(X,Y,Z,90,[213,194,100]./255,'filled',F,.2,E,.2)
scatter3(X,Y,Z,12,[255,255,255]./255,'filled',F,.9,E,.9)
plot3(0,0,10.5,'p', 'MarkerSize',25,'MarkerFaceColor',[255,223,153]/255,'MarkerEdgeColor','none','LineWidth', 1);
Ll=scatter3(0,0,10.5,8000,'o','MarkerFaceColor','w','MarkerEdgeColor','w',F,0,E, 0.1);
a=100;
b=(.5:a)'/a;
c=(-cos(b*2*pi)+1).^.2;
f=b-.5;
r=f'.^2+f.^2;
h=abs(ifftn(exp(5i*rand(a))./r.^1.05)).*(c*c')./2-2;
[X,Y]=meshgrid(linspace(-10,10,a));[X,Y,h]=OFS(X,Y,h,.1);
scatter3(X(:),Y(:),h(:),8,[91,131,253]./255,'filled',F,.2,E,.2)
h=abs(ifftn(exp(5i*rand(a))./r.^1.05)).*(c*c')./1.5-2.5;
[X,Y]=meshgrid(linspace(-10,10,a));[X,Y,h]=OFS(X,Y,h,.2);
scatter3(X(:),Y(:),h(:),8,[91,131,253]./255,'filled',F,.1,E,.1)
S1=rand(90,3);
S1(:,1:2)=S1(:,1:2).*16-8;
S1(:,3)=S1(:,3).*20;
S2=rand(120,3);
S2(:,1:2)=S2(:,1:2).*16-8;
S2(:,3)=S2(:,3).*20;
H1=plot3(S1(:,1),S1(:,2),S1(:,3),'*','Color',[.8,.8,.8]);
H2=plot3(S2(:,1),S2(:,2),S2(:,3),'.','Color',[.6,.6,.6]);
else
Ll.SizeData=8000+sin(f/5).*1600;
S1(:,3)=S1(:,3)-.05;S2(:,3)=S2(:,3)-.005;
S1(S1(:,3)<0,3)=S1(S1(:,3)<0,3)+20;
S2(S2(:,3)<0,3)=S2(S2(:,3)<0,3)+20;
H1.XData=S1(:,1);H1.YData=S1(:,2);H1.ZData=S1(:,3);
H2.XData=S2(:,1);H2.YData=S2(:,2);H2.ZData=S2(:,3);
view([f,15]);
end
end