• Remix
  • Share
  • New Entry

on 7 Nov 2023
  • 13
  • 20
  • 0
  • 0
  • 1562
drawframe(1);
Write your drawframe function below
function drawframe(f)
global thetaB thetaS sCircleHdl pntsHdl patchHdl pntsTheta CPnts
if f==1
N=7;
ax=gca;
ax.XLim=[-2 2];
ax.YLim=[-2 2];
ax.XColor='none';
ax.YColor='none';
axis equal
hold(ax,'on');
% grid on
thetaB=0;
thetaS=0;
pntsTheta=0:2*pi/N:2*pi;
for i=1:(length(pntsTheta)-1)
plot([cos(pntsTheta(i)),cos(pntsTheta(i)+pi)].*2,...
[sin(pntsTheta(i)),sin(pntsTheta(i)+pi)].*2,...
'Color',[0.8 0.8 0.8],'LineWidth',1.5)
end
if mod(N,2)==0
for i=1:(length(pntsTheta)-1)
plot([cos(pntsTheta(i)+2*pi/N/2),cos(pntsTheta(i)+2*pi/N/2+pi)].*2,...
[sin(pntsTheta(i)+2*pi/N/2),sin(pntsTheta(i)+2*pi/N/2+pi)].*2,...
'Color',[0.8 0.8 0.8],'LineWidth',1.5)
end
end
tempT=0:0.1:2*pi+0.1;
CPnts=[cos(tempT);sin(tempT)];
plot(CPnts(1,:).*2,CPnts(2,:).*2,'Color',[0.2098 0.4059 0.6412],'LineWidth',2);
sCircleHdl=plot(cos(thetaB)+CPnts(1,:),sin(thetaB)+CPnts(2,:),...
'Color',[0.3098 0.5059 0.7412],'LineWidth',2);
pntsHdl=plot(cos(pntsTheta+thetaS)+cos(thetaB),...
sin(pntsTheta+thetaS)+sin(thetaB),...
'Color',[0.2157 0.3765 0.5725],'LineWidth',2,'Marker','o',...
'MarkerFaceColor',[0 0 0],'MarkerEdgeColor',[0 0 0],'MarkerSize',6);
patchHdl=fill(cos(pntsTheta(1:end-1)+thetaS)+cos(thetaB),...
sin(pntsTheta(1:end-1)+thetaS)+sin(thetaB),...
[0.8500 0.3250 0.0980],'EdgeColor','none','FaceAlpha',0.1);
else
tthetaB=thetaB-8*f*pi/200;
tthetaS=thetaS+8*f*pi/200;
sCircleHdl.XData=cos(tthetaB)+CPnts(1,:);
sCircleHdl.YData=sin(tthetaB)+CPnts(2,:);
pntsHdl.XData=cos(pntsTheta+tthetaS)+cos(tthetaB);
pntsHdl.YData=sin(pntsTheta+tthetaS)+sin(tthetaB);
patchHdl.XData=cos(pntsTheta(1:end-1)+tthetaS)+cos(tthetaB);
patchHdl.YData=sin(pntsTheta(1:end-1)+tthetaS)+sin(tthetaB);
end
end
Animation
Remix Tree