• Remix
  • Share
  • New Entry

on 30 Nov 2023
  • 10
  • 39
  • 1
  • 0
  • 555
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent speed
acc = 1.97;
dth = pi/4;
th = (0:dth:2*pi-dth)' ;
offset = (f-1)^acc*dth/48;
th = th + offset;
if f==1
speed = 0;
else
speed(end+1) = offset;
end
x = [reshape(cos(th)*(1:2), numel(cos(th)*(1:2)),1); 0];
y = [reshape(sin(th)*(1:2), numel(sin(th)*(1:2)),1); 0];
shp = alphaShape(x,y,0.75);
p = plot(shp);
p.FaceColor = [0.2, 0.75, 0.6];
p.FaceAlpha = 0.6;
xlim([-1.2 1.2])
ylim([-1.2 1.2])
hold on
xs = (0:(f-1))/24-1;
ys = 2*speed/((48-1)^acc*dth/48)-1;
plot(xs,ys,'r')
plot(xs(end),ys(end),'.',MarkerSize=10)
text(xs(end),ys(end),"Speed","FontSize",12)
hold off
axis equal
axis off
end
Animation
Remix Tree