- /
-
Grand_prix
on 12 Oct 2024
- 15
- 163
- 0
- 1
- 1179
Cite your audio source here (if applicable):
drawframe(6);
Write your drawframe function below
function drawframe(nf)
t = linspace(0, 2*pi, 200);
xi = 7 * cos(t) + sin(2*t);
yi = 7 * sin(t) + cos(5*t);
xo = 9 * cos(t) + sin(2*t);
yo = 9 * sin(t) + cos(5*t);
n = length(xi);
for i = 1:nf
clf;
fill([-20 20 20 -20], [-20 -20 20 20], 'g');
hold on;
fill(11 * cos(t) + sin(2*t), 11 * sin(t) + cos(5*t), [0.5 0.5 0.5], 'EdgeColor', 'k');
fill(6 * cos(t) + sin(2*t), 6 * sin(t) + cos(5*t), 'g', 'EdgeColor', 'k');
plot([6.15, 11.17],[2.02, 2.43], 'w',"LineStyle", ':','LineWidth', 4);
plot([6.55, 11.17],[2.05, 2.43], 'k',"LineStyle", ':','LineWidth', 4);
i1 = mod(floor(i * n / 75), n) + 1;
i2 = mod(floor(i * n / 85), n) + 1;
d1 = atan2(yi(mod(i1+1, n)+1) - yi(i1), xi(mod(i1+1, n)+1) - xi(i1));
d = atan2(yo(mod(i2+1, n)+1) - yo(i2), xo(mod(i2+1, n)+1) - xo(i2));
r = @(x, y, a) [cos(a) -sin(a); sin(a) cos(a)] * [x; y];
l = 2;
w = 1;
c1 = r([-l/2, l/2, l/2, -l/2], [-w/2, -w/2, w/2, w/2], d1);
patch(c1(1,:) + xi(i1), c1(2,:) + yi(i1), 'r');
c2 = r([-l/2, l/2, l/2, -l/2], [-w/2, -w/2, w/2, w/2], d);
patch(c2(1,:) + xo(i2), c2(2,:) + yo(i2), 'b');
xlim([-15, 15]);
ylim([-15, 15]);
if i >= 75
if mod(i, 2) < 1
text(0, 10, 'RED IS WINNER', 'Color', 'r', 'FontSize', 24, 'FontWeight', 'bold', 'HorizontalAlignment', 'center', 'FontName', 'Arial');
end
end
end
% close(v);
end