- /
-
rotating square
on 26 Oct 2024
- 17
- 65
- 0
- 0
- 516
Cite your audio source here (if applicable):
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent dt xys xs ys xc yc plts M
if(f == 1)
tc = linspace(0, 2*pi, 41);
dt = tc(2) - tc(1);
xc = cos(tc); yc = sin(tc);
ts = linspace(0, 2*pi, 5);
xs = interp1(ts, 0.8*cos(ts), tc);
ys = interp1(ts, 0.8*sin(ts), tc);
xs(end) = []; ys(end) = [];
xc(end) = []; yc(end) = [];
plts = plot([xc;xs], [yc;ys], '-ok', MarkerSize=8, LineWidth=2 );
axis equal
M = [cos(dt), sin(dt); -sin(dt), cos(dt)];
else
xys = M*[xs; ys];
xs = xys(1,:); ys = xys(2,:);
for j = 1:numel(plts)
plts(j).XData = [xc(j), xs(j)];
plts(j).YData = [yc(j), ys(j)];
end
drawnow;
end
end
Movie
Audio
This submission does not have audio.